four neighbourhoods of a set or matrix
Afficher commentaires plus anciens
It may be clear when you need to check if some pixels are neighbours to a specific region you are interested in in some image.
But, when asked to find the pixels that are considered 4-neighbourhood to some set or matrix, how can we do that?
Thanks.
Réponses (1)
Image Analyst
le 23 Fév 2014
0 votes
You can use connected components determination with bwlabel() or bwconncomp().
8 commentaires
med-sweng
le 5 Mar 2014
Image Analyst
le 5 Mar 2014
What is the "specifi region" in that image that you are interested in? What is the foreground? If you're interested in the whole thing, then this is right - it's telling you the whole thing is one region because (the badly-named) I has just one value.
med-sweng
le 5 Mar 2014
Image Analyst
le 5 Mar 2014
Modifié(e) : Image Analyst
le 5 Mar 2014
If you're at pixel (row, column), then the 4 neighbors are grayImage(row-1, column), grayImage(row, column-1), grayImage(row, column+1), and grayImage(row+1, column). You might want to look into a linked list / Djikstra's method of visiting the pixels.
Image Analyst
le 5 Mar 2014
Yes, if you're doing a depth-first search (ala Djisktra) then you may get to a point where some of the 4 neighbors have already been processed. They are in C. You don't want to include those in the list of pixels to visit in the future because they've already been processed . For example, let's say we have a square ring. So you move around the ring, doing your processing, and keeping track of what pixels you've visited in the ring. But when you come full circle and get back to your starting point, you don't want to process that one, right? Because you've already process it. So you need to skip that one. So with a recursive search, like region growing, you have a list of pixels that have already been processed and a list of the pixels to be processed. You have the current 4 you're looking at, plus a whole backlog of other pixels you've put on the list of pixels to process but haven't gotten to yet. If you move onto a pixel that's already been processed, you don't want to process it again, so you skip it and move on to some other pixel on the "to be processed" list. Does that explain it better, or just make your head spin?
Image Analyst
le 5 Mar 2014
Catégories
En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!