필터 지우기
필터 지우기

Comparing two binary images: if a pixel is 1 in both images, write a 1 into a new image, otherwise, write a 0.

조회 수: 4 (최근 30일)
Hello everyone,
I have a somewhat noisy image and I would like to reduce or clear the noise.
To do so, I performed and opening. Since I don't want to lose any information of the objects' surface, I think it is easiest, to "compare" the two pictures, the original and the opened one. Meaning, when I have a 1 in the original image and a 1 in the opened image, I want to write a 1 into a third, new image. When I have a 1 in the original picture and a 0 in the opened picture I want to write a 0 in the new, third image. And when there are two 0s, I of couse want a 0 in the new image.
If you click on the link, you see the original image on the left and the opened image in the middle. It should look like a mixture of the first to images with all the surface information...
I tried to multipy the images (result=ImgOpen*ImgOrg), which in my opinion should lead to the desired result (1*1=1; 1*0=0), but the result looks like the image on the right...?!
Do you understand what I mean? It's a little hard to describe that in another language. Sorry!
Thank you! Thymes

채택된 답변

Walter Roberson
Walter Roberson 2012년 10월 22일
result = ImgOpen .* ImgOrg;
The * operator is mathematical matrix multiplication, not element-by-element multiplication.
Note: the answer given for your other question is still correct,
result = ImgOpen & ImgOrg;
  댓글 수: 2
Walter Roberson
Walter Roberson 2022년 2월 18일
You should open a new question about that; it is not related to the current topic.
Note: "compare" of two images is not well-defined unless you define it precisely. "FInd 12 mistakes in the second image" is a quite different technique than "Decide which kind of brain tumour this patient has" or "Figure out where in the world this picture was taken".

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

추가 답변 (2개)

Julian
Julian 2012년 10월 23일
Hello and thank you!
I tried it with the element-by-element multiplication with .* and the result is again on the right.
Do I think wrong, or shouldn't the surface of the main structure be much more like the one of the original picture on the right? I thought that this might be due to the size and shape of the sructuring element, but when I increased it's size it looked even worse...
Any ideas?

Julian
Julian 2012년 10월 23일
Ok, I found the mistake in my thoughts. imopen performs dilation and erosion with the same structuring element. I chose the wrong size of it, deleting to many informations in the first place. I added a second structuring element with a bigger size and perform the dilation with it.
That works :)

Community Treasure Hunt

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

Start Hunting!

Translated by