Regionprops returns NaN as centroid value for a Label
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi This I encountered while trying to relabel my labeling matrices for each of the 97 images I have. My Image Labels as got from below command: unique(filteredimagelabels{19}.L(filteredimagelabels{19}.L~=0)) % Here 19 number is my Image No.19
ans =
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
17
18
19
20
21
22
Total number of labels present in this Label matrix, as in the below command: length(unique(filteredimagelabels{19}.L(filteredimagelabels{19}.L~=0)))
ans =
21
After I applied region props, to the above Label matrix to generate new centroids and other properties, as in the below command:
testforimage19=regionprops(filteredimagelabels{19}.L,{'Centroid','Pixelidxlist'});
The number of fields I am getting in my testforimage19 are 22 (to the expected 21).
I checked my Centroid values for each of the fields in the testforimage19, turns out to be that: testforimage19(16).Centroid % 16 is ofcourse the ROI/Label in Image 19
ans =
NaN NaN
and, I also tried to get Pixel-ids (indices of label 16, for which Centroids were NaN, as seen above)
testforimage19(16).PixelIdxList
ans =
Empty matrix: 0-by-1
What mistake am I doing? I need some inputs. If not clear, shall try to explain more.
Thanks in advance
Harish
0 Commenti
Risposta accettata
Image Analyst
il 29 Ago 2013
Why/how are you filtering before calling regionprops? Why did blob #16 get removed? It gives results based on the label number, and since you didn't pass it a blob labeled 16, what would you expect it to pass back for that blob number? The only thing it could do is pass back something like null or nan. Yes, this is confusing but you brought it upon yourself when you passed it a labeled image with one of the labels missing. Normally one passes in a labeled image with all the labels there and you do the filtering AFTER calling regionprops, not before like you did it. Explain why you are filtering before, because this is why #16 got removed in image #19.
Più risposte (1)
Anand
il 29 Ago 2013
The regionprops function tries searching for the component with label 16, which you seem to have filtered out. So, this component doesn't exist. So, whats the centroid of a component that has no pixels in it or is non-existant?
NaN seems like a good answer to me.
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!