To find the common elements of two binary images, you can use the logical AND operation. This will give you a new binary image with elements that are 1 if and only if the corresponding elements of the original images were both 1. Here's an example:
main.m569 chars20 lines
In this code, we first load the two binary images and convert them to logical arrays using the imbinarize function. We then apply the logical AND operation to obtain a new binary image that contains only the common elements of the two input images.
Finally, we use the logical indexing feature of MATLAB to remove the non-common elements from the original images. We display the original images and the common elements using a subplot.
gistlibby LogSnag