title: Put cropped part of image back in original dimensions
body: <p>Hello StackOverflow Community,</p>
  
  <p>I've got a problem since two days with a larger image and a ROI, which is part of the image.
  I want to use <code>imrect</code> for selecting the ROI and cropping the ROI out, so that I have a smaller amount of data to process.
  After processing I want to re-map the cropped image back to the original position of the image.</p>
  
  <p>What I've done so far by debugging:</p>
  
  <pre><code>function paddedImg = putCroppedImgBack(croppedIm, Pos, origDim)
  paddedImg = zeros(origDim);
  r = round(Pos(1));
  c = round(Pos(2));
  if(r ==0) % because ML addresses a matrix not with 0 like in cpp
       r=1;
  end
  sizeR = size(croppedIm,1);
  sizeC = size(croppedIm,2);
  paddedImg(r:sizeR,c:sizeC) = croppedIm; %this part doesn't work!
  %Subscripted assignment dimension mismatch.
  </code></pre>
  
  <p>I tried to <code>round</code> the coordinates of the <code>imrect</code>, but that didn't worked aswell.
  I also adressed manually <code>paddedImg</code> with the values, e.g. 
  <code>paddedImg(1:5,20:50) = 1;</code>, which works.</p>
  
  <p><strong>edit:</strong>
  Found the solution after I started the post here....  sometimes I should ask StackOverflow a little bit earlier than spending a whole day with a sleepless night.</p>
  
  <p><code>paddedImg(r:sizeR+r-1,c:sizeC+c-1) = croppedIm;</code></p>
  
  <p>Sincerely</p>