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

1 回表示 (過去 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 件のコメント
Falak Memon
Falak Memon 2022 年 2 月 17 日
i want to compare two images which are segmented already
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 :)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by