Azzera filtri
Azzera filtri

Labeling growing regions in image processing

4 visualizzazioni (ultimi 30 giorni)
Kazekage Sama
Kazekage Sama il 28 Nov 2013
Commentato: Image Analyst il 28 Nov 2013
I am working on the detection of the MSER (maximally stable extremal regions) in MATLAB. I trying to build my own code and hence I avoided MATLAB pre-defined functions to accomplish this task. The algorithm threshold an intensity image using threshold value “T”, and then by “T+1”. Obviously there will be some pixels with value of 1 that are common in both cases, and the new pixels will either correspond to a growing region or to a new region. Then for the image resulting from threshold “T”, I want to label the connected pixels. For the “T+1” threshold image, I want to use the same label for the same pixels “that are common with the previous threshold” and the new pixels surrounding this old regions (growing regions), while assigning a new label for the new regions.
Here is an example
Image threshold (T):
1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 0 0 1 1
1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1
1 1 1 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1
1 1 1 0 1 0 0 0 0 1 0 1 1 0 0 0 1 1 1 0
1 1 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 0
0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0
1 1 1 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 1
1 1 1 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0
1 1 1 1 0 1 0 1 1 0 1 0 0 0 0 1 1 0 1 1
0 1 1 1 0 1 0 0 0 0 1 1 0 0 0 1 1 1 1 1
0 1 1 1 0 0 1 0 1 0 0 0 0 0 0 1 1 1 1 1
0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1
0 0 1 1 1 0 0 1 0 0 0 0 0 1 1 1 1 1 0 0
Regions labeled:
1 1 1 1 1 1 1 1 1 1 1 1 0 8 0 9 0 0 9 9
1 1 1 1 0 0 0 0 0 0 0 0 0 8 0 0 9 9 0 9
1 1 1 0 0 0 0 0 0 2 0 0 0 0 8 0 9 9 0 9
1 1 1 0 1 0 0 0 0 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1 1 1 1 0 1 0 0 0 0 0 0 0 0 0
0 0 0 1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 1
0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0
1 0 1 0 1 1 0 0 1 1 1 1 0 1 0 1 1 0 0 1
0 0 0 1 1 1 1 0 0 0 0 0 1 1 0 1 0 1 1 0
0 0 0 1 0 0 1 0 0 0 0 1 0 0 1 1 0 0 1 1
0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0
1 0 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0
1 0 1 0 0 0 1 0 1 1 0 1 0 1 0 1 0 0 0 0
1 1 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 [1] [1]
Those two 1s in bottom-right corner need to be labeled as 9 since they correspond to region labeled by 9 at threshold (T).
is there any way to achieve this?

Risposte (1)

Image Analyst
Image Analyst il 28 Nov 2013
I don't think it can be done in the general case. Let's say you had dark blobs on a white background. And at threshold 50 you had 7 blobs. Then when you raise the threshold to 51, you might have 3 blobs, or even 1 blob that now contains all of the prior 7 blobs. There is no way that you can give 7 labels to the one blobs - it can have only 1 label, so which would you pick?
  2 Commenti
Kazekage Sama
Kazekage Sama il 28 Nov 2013
Thank you for the quick response. Basically I have possibilities when increase the threshold:
- a new region appears that is not neighboring any old pixels: give it a new label.
- new pixels neighboring old pixels: assign any label of the surrounding pixels labels to these pixels.
and in case regions merge, use the lowest label.
the important thing is to keep using the previous labels at least as initial labels, which might be re-labeld afterwards.
Image Analyst
Image Analyst il 28 Nov 2013
If you say that you're going to use the lowest label, then you can get the new binary image and label it. Then pass in the old labeled image as the original image and find the lowest non-zero number in the blob by looking at PixelList
measurements = regionprops(newLabeledImage, oldLabeledImage, 'PixelList', 'PixelIdxList');
You can think of several ways to get the lowest non-zero value in the old labeled image. Then loop over all the blobs replacing the pixels of the blob in the new labeled image with the label you got from the old labeled image.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by