How do I set up a for loop to replace specific pixels of a color image (with a value of 0) with specific pixels of another color image?

I would like overlap a small picture (200x300) into a specific area of a big picture (2000x2600). How would I set up a for loop to make this action take place with two color photos?

 채택된 답변

Try this (untested):
% Find logical indexes of where there is 0 in image1.
zeroPixels = image1 == 0;
% Replace them with the same pixels from image 2
image1(zeroPixels) = image2(zeroPixels);
If that doesn't work, let me know.

댓글 수: 5

This method did not work. The issue is that the zero pixels of image 1 is not the exact size of image 2. Idk if there is a way to resize image 2 to fit those dimensions. I was hoping there was a way I would say I want to replace pixels (500-700 x 1000-1300) from image 1 with pixels (0-200 x 0-300) of image for an example.
You can do that - that's simply copying and pasting. I've attached a demo for that. You'd have to basically adapt my demo to handle color images.
I tried the demo. it is very useful. Thank you. Is there any way to just copy the cropped image to a set of dimensions already known instead of clicking where to paste?
Sure. Feel free to hard code in coordinates if you want, instead of having the user click where to paste it.
@Image Analyst please have a look at this problem Texture mapping

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

추가 답변 (0개)

질문:

2014년 2월 28일

댓글:

2018년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by