5
$\begingroup$

I first cut out the window from the image of the house, paint it yellow, and then overlay it on the image of the house.

I have two questions:

(1) Why did the yellow window and the house get misaligned when I added them together?

(2) Is there a way to change the color of the window directly in the image of the house without cutting it out? Maybe I can use Image Mask to do this?

Thank you.

img = ExampleData[{"TestImage", "House"}];
rTop = 169; yTop = 135.622;
rBot = 121; yBot = 87.027;
cLef = 106; xLef = 140.4;
cRig = 141; xRig = 105.6;
iwin = ImageTake[img, {rBot, rTop}, {cLef, cRig}];
iwiny = ImageRecolor[iwin, ColorsNear[White, 0.2] -> Yellow]
ImageAdd[img, iwiny]

result of my code

$\endgroup$

1 Answer 1

8
$\begingroup$

Use ImageCompose with position instead of ImageAdd.

ImageCompose[img, iwiny, {rBot, cLef}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.