Comparing two binary images: if a pixel is 1 in both images, write a 1 into a new image, otherwise, write a 0.
1 view (last 30 days)
Show older comments
Julian
on 22 Oct 2012
Commented: Walter Roberson
on 18 Feb 2022
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
0 Comments
Accepted Answer
Walter Roberson
on 22 Oct 2012
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 Comments
Walter Roberson
on 18 Feb 2022
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".
More Answers (2)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!