Hello StackOverflow Community,
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 imrect 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.
What I’ve done so far by debugging:
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.
I tried to round the coordinates of the imrect, but that didn’t worked aswell.
I also adressed manually paddedImg with the values, e.g.
paddedImg(1:5,20:50) = 1;, which works.
edit:
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.
paddedImg(r:sizeR+r-1,c:sizeC+c-1) = croppedIm;
Sincerely
edit: 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.
paddedImg(r:sizeR+r-1,c:sizeC+c-1) = croppedIm;