How to replace image portion with processed image?

I have one rgb image. I crop one portion by using imcrop function. After lots of processing I want to place that processed portion into the same place of the orginal image. How can I do that. I tried by using imfusion but its not worked.

 채택된 답변

Image Analyst
Image Analyst 2015년 12월 9일
Since you cropped it, you know what the starting and stopping rows and columns are. So just assign:
originalImage(row1:row2, col1:col2, :) = processedImage;

댓글 수: 4

Thank u. I crop the image using imrect. But how can I find the starting and stopping rows and columns are.
h = imrect;
position = getPosition(h);
handles.croppedImage = imcrop(handles.orginalImage, position);
position is [leftColumn, topRow, width, height] I believe - isn't it? So to get the other side you just simply add the width or height to the first side.
col1 = position(1);
col2 = col1 + position(3);
row1 = position(2);
row2 = row1 + position(4);
Yes. I got it. Thank you Sir.
Thank you Image Analyst

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Gosselin Thibault
Gosselin Thibault 2018년 7월 12일

0 개 추천

Hello everybody ! Sorry to view this long date post only but i've the same problem and your solution don't work on my program.
I have this error message : "Unable to perform assignment because the size of the left side is 118-by-325 and the size of the right side is 912-by-1200."
for this line code : Icrop1(row1:row2, col1:col2) = I;
Thank you for your help !!

댓글 수: 4

Without your program, all I can say is to make sure your (badly-named) I is 118-by-325. Use imresize() if you think that's appropriate.
I fixed my problem; i have just interchanged the originalImage and the processedImage. So yes it was very badly named !
But this solution did not resolve my problem because I also draw a curve on the modified image. I do not know how to draw the equivalent curve on the initial image.
Thank you for your repply and you help !
Duyen Ho
Duyen Ho 2018년 11월 24일
how did you fix the problem? im getting the same error
He said he had
processedImage(row1:row2, col1:col2, :) = originalImage;
when he should have had
originalImage(row1:row2, col1:col2, :) = processedImage;
like I said. When he "interchanged the originalImage and the processedImage" he got my code and it worked. In short, the bigger matrix is on the left, and the smaller submatrix is on the right.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

질문:

2015년 12월 9일

댓글:

2018년 11월 24일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by