function I = rpimage(resid,C)
%
%  Create an image with the helices marked from the
%  cross-correlation matrix
%
   aarxr = [227 458];
   aappar = [206 477];
%
%  basic image
   I0 = uint8(round(255*abs(C)));
%
%  helix information about RXR/PPAR
   hrxr = [ 233 240; 265 285; 294 302; 306 315; 334 338; 345 351;
            355 360; 364 375; 387 407; 414 418; 422 437; 451 454 ];
   hppar = [ 208 225; 230 238; 252 258; 262 264; 277 301; 311 332;
             351 354; 364 376; 381 392; 404 424; 431 459; 467 473 ];
%
%  build the index tables
% 
%  find the first and last residues in the rxr common sequence
   for irxr = 1:length(resid)
      if(resid(irxr)==aarxr(1)), break, end
   end
   for jrxr = irxr+1:length(resid)
      if(resid(jrxr)==aarxr(2)), break, end
   end
   lrxr = aarxr(2) - aarxr(1) + 1;
%
%  first and last residues of common ppar sequence
   for ippar = jrxr+1:length(resid)
      if(resid(ippar)==aappar(1)), break, end
   end
   for jppar = ippar+1:length(resid)
      if(resid(jppar)==aappar(2)), break, end
   end
   lppar = aappar(2) - aappar(1) + 1;
%
%  compute the helix indices for output
   krxr = hrxr - aarxr(1) + 1;
   kppar = hppar - aappar(1) + lrxr + 1;
%
%  construct the image
   jbuf = 5;
   imsize = lrxr + lppar + jbuf;
%
%  copy the basic images
   I(1:lrxr,1+jbuf:lrxr+jbuf) = I0(irxr:jrxr,irxr:jrxr);
   I(1:lrxr,imsize-lppar+1:imsize) = I0(irxr:jrxr,ippar:jppar);
   I(lrxr+1:lrxr+lppar,1+jbuf:lrxr+jbuf) = I0(ippar:jppar,irxr:jrxr);
   I(lrxr+1:lrxr+lppar,imsize-lppar+1:imsize) = I0(ippar:jppar,ippar:jppar);
   I(1:imsize,1:jbuf) = uint8(0);
   I(imsize-jbuf+1:imsize,jbuf+1:imsize) = uint8(0);
%
%  mark the helices
   for k = 1:12
      I(imsize-jbuf+1:imsize,krxr(k,1)+jbuf:krxr(k,2)+jbuf) = uint8(200);
      I(krxr(k,1):krxr(k,2),1:jbuf) = uint8(200);
      I(imsize-jbuf+1:imsize,kppar(k,1)+jbuf:kppar(k,2)+jbuf) = uint8(100);
      I(kppar(k,1):kppar(k,2),1:jbuf) = uint8(100);
   end
%
return
