Matlab: Find a point in an image based on its surroundings
How would you identify specific points in an image based on the pixels around the point(s) that you wish to identify?
For example, if I had an image with lots of different colors but I only wanted to find the blue areas which are next to green areas and ignore everything else.
I'm sure the first step in this example would be to pass a filter over the image to remove all colors apart from green and blue but I wouldn't kn开发者_开发技巧ow where to go from there in eliminating green and blue parts which are not adjacent.
[0] I assume that you are looking for direct neighboring regions.
[1] Since you are sure that the first step is to remove all colors except green and blue, i'll continue from there.
[2] Next, all you need to do is to segment blue from [1] and turn that into logical map or a black/white image
[3] dilate [2] to your desired size
[4] then, segment green from [1] and turn that into a logical map or a black/white image
[5] multiply [3] to [4], the leftovers would be the region that has green next to blue.
Segment the image into the different colours that you are trying to find (lets say green and blue), For each set of segmented colour regions use connected components to find the centroids of each blob. This should give you the locations of all the red blobs, and green blobs
Now just measure the distance between each of the centroids and only keep the ones that are close enough?
精彩评论