four neighbourhoods of a set or matrix

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
Image Analyst le 23 Fév 2014

0 votes

You can use connected components determination with bwlabel() or bwconncomp().

8 commentaires

Can you kindly clarify how this can be done? For instance, I did the following:
I=[4 3 5; 5 3 2; 5 3 2];
bwlabel(I)
ans =
1 1 1
1 1 1
1 1 1
But, where are the four neighbours of the matrix?
Thanks.
Image Analyst
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
med-sweng le 5 Mar 2014
For instance, I will start from a specific region (set) of the image, and then start to grow on that based on some criteria. Say that my starting region from "I" was [5 3 2]. How can I find the 4-neighbourhood of the "set". This is the main issue.
Thanks.
Image Analyst
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.
med-sweng
med-sweng le 5 Mar 2014
Modifié(e) : med-sweng le 5 Mar 2014
Yes, but the issue is the in the pseudocode I'm trying to implement, where it mentions the following:
select 4-neighbours (pixels) of C but not included in C
Provided that here C is a set, to which pixels meeting some criteria will be added, through a while-loop. And, eventually this C will be a part/whole of the original image, and the first C will be a starting configuration (part of the image) that we start from.
How can you explain the neighbourhood in the above context?
Thanks.
Image Analyst
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?
med-sweng
med-sweng le 5 Mar 2014
Modifié(e) : med-sweng le 5 Mar 2014
Thanks so much for this thorough explanation. Can it be supported by some code that may explain the concept through a simple example? It seems it is getting to the point, but not yet clear much about it. Thanks for your patience. And, is the concept to do with "region growing"?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange

Question posée :

le 23 Fév 2014

Commenté :

le 5 Mar 2014

Community Treasure Hunt

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

Start Hunting!

Translated by