필터 지우기
필터 지우기

How to add two images excluding simalar elements

조회 수: 3 (최근 30일)
D_coder
D_coder 2019년 3월 21일
댓글: Walter Roberson 2019년 3월 22일
The figure below shows two images and their addition. Is there a simple code or a function to avoid adding the highlighted area (triangle) in black
example.png
  댓글 수: 1
Guillaume
Guillaume 2019년 3월 21일
What do you define as "addition" of two images? For that matter, what do you define as image?
It looks like what you're asking may be the symmetric difference
It's actually really unclear what in your figure you call an image. Is the black rectangle part of the image? In that case, what is the result of the addition of black on black. Similarly, what is the result of addition of white on white. And if the highlighted rectangle is not added, what colour should it be? black? white?

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

답변 (1개)

Walter Roberson
Walter Roberson 2019년 3월 21일
mask = repmat(any(first_image ~= second_image, 3), 1, 1, 3);
total = first_image;
total(mask) = total(mask) + second_image(mask);
However, keep in mind that with white being fully saturated, if you add anything to it you are going to get a white result, so adding images will not give you the result you show. Adding the two images would give you white everywhere except the place the red overlaps.
  댓글 수: 9
D_coder
D_coder 2019년 3월 22일
no it doesnt work
Walter Roberson
Walter Roberson 2019년 3월 22일
Not many of us can be bothered to take your composite image and crop out sections of it in order to get images to test with. You should post the original images.

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by