how can i get the original from cropped image?
3 次查看(过去 30 天)
显示 更早的评论
Hi, I have a cropped image which size is 460*460 and i want to get the position of this image compared to the original image, to recover back the original image which size is 512*512 without using imresize.
Thanks in advance for your answers.
0 个评论
回答(1 个)
Bjorn Gustavsson
2018-1-11
Huh?
Do you want to put the 460x460 image back into an equally sized region somewhere in a 512x512 image? How does that "recover the original image"? You might have more or less anything in the original image pixels that were outside the 460x460 crop: the yeti playing scrabble with big-foot, unicorns debating the teodice problem, Cinderella power-lifting...
The only situation I can dream up where your question makes sense is if you have a hole smaller than 460x460 in your original image and want to insert the 460x460 image in the correct location with the best fit. The case I make up is something like this:
Imcroped = Im027(34+[1:256],54+[1:256]);
Imholey([100:250],100:250) = nan;
Where you want to find the best coordinates to insert Imcroped into Imholey. This you can solve, with somewhat reasonable start-guesses, like this:
fitfcn = @(pars,ImH,ImC) sum(nanmean((ImC-interp2((1:size(ImH,2))',1:size(ImH,1),ImH,pars(1)+(1:size(ImC,2))',pars(2)+(1:size(ImC,1)))).^2))
par0 = [40 40]; % Needs reasonably good initial point...
par1 = fminsearch(@(pars) fitfcn(pars,Imholey,Imcrop),par0)
This gives you the x0, y0 coordinates of the cropped-out image in the "original" image.
HTH
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!