title: Modifying bilinear interpolation matlab code to enlarge an image instead
body: <p>I am trying to modify this code to enlarge an image instead of shrinking it by when I change the
  eliminate the factor line and made shrinking factor= 2 and multiply by s where s is used, I didn't get the right output. Can anyone point me to what I am doing wrong.
  Here is the code:</p>
  <pre><code>    image=imread('b100.jpg');
      factor=1.5;
      shriking_factor= 1/factor;
      [r c d] = size(image);
      rn = floor(shriking_factor*r);
      cn = floor(shriking_factor*c);
      s = shriking_factor;
      im_zoom = zeros(rn,cn,d);
          for i = 1:rn;
              x1 = cast(floor(i/s),'uint16');
              x2 = cast(ceil(i/s),'uint32');
              if x1 == 0
                 x1 = 1;
          end
          x = rem(i/s,1);
          for j = 1:cn;
              y1 = cast(floor(j/s),'uint32');
              y2 = cast(ceil(j/s),'uint16');
              if y1 == 0
                  y1 = 1;
              end
              ctl = image(x1,y1);
              cbl = image(x2,y1);
              ctr = image(x1,y2);
              cbr = image(x2,y2);
              y = rem(j/s,1);
              tr = (ctr*y)+(ctl*(1-y));
              br = (cbr*y)+(cbl*(1-y));
              im_shrink(i,j) = (br*x)+(tr*(1-x));
          end
      end
      image_shrink = cast(im_shrink,'uint8');
      imshow(image_shrink)
  </code></pre>