regionprops does not work?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I do have a labelled matrix that I have checked. I want to find the index of the each region using PixelIdxRegion. But it returns a structure array with empty. There is no value at all. Could anybody explain it? This matrix is gotten from a segmentation function. I have checked the regionprops with another segmentation function, it worked. So I think if there is any requirement on the labelled matrix. The data type I have checked, no problem.
Thank you very much.
0 comentarios
Respuestas (1)
Image Analyst
el 23 de Sept. de 2012
Editada: Image Analyst
el 23 de Sept. de 2012
Of course it works, especially when you call it with the proper arguments. There is no 'PixelIdxRegion' that you can ask for. But I don't even know what to tell you to ask for because I'm not sure what you're asking for. The "index of the region" is simply the value of your labeled matrix for that region. If that's all you want, you don't need to call regionprops at all. If you do call regionprops you get an array of structures, where the index of the structure is what region you're looking at the measurements of. See my image segmentation demo for a thoroughly documented example: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 If your return arg from regionprops is empty, then you passed in a labeled image that was all 100% black (value 0 or false).
3 comentarios
Image Analyst
el 24 de Sept. de 2012
Editada: Image Analyst
el 24 de Sept. de 2012
The index of each label is the label. Let's say you have a binary image of 10 blobs. Then you call bwlabel. Now you have an integer image where each blob is a number, instead of "true" or "1" or "white". Let's look at blob #5. Why do I call it blob #5? Well because when I labeled it, the labeling routine called that particular blob "blob #5" and assigned a value of 5 to all of that blob's pixels. So the label is 5 and the index is 5 - they're one in the same. In fact if you then call regionprops on the labeled image, you'll get some measurements:
measurements = regionprops(labeledImage, 'area');
Now measurements is an array of 10 structures. Let's say I want the area of blob #5. Well I just use an index of 5 into measurements like this:
blob5area = measurements(5).Area; % 5 is the index for blob #5
Perhaps I don't know what you mean when you say you want the index of the label. Other possibilities are to get the linear indexes of the pixels in each blob by asking for PixelIdxList, getting the value of the pixels in each blob by asking for PixelList, or extracting just the index (label) of a particular blob as a new image using ismember():
imageOfOnlyBlob5 = ismember(labeledImage, 5);
You're going to have to be more precise in describing what you want so that I can tell you exactly how to get it. Or better yet, let's just skip this step for now, and you tell me exactly what you want to do if you had whatever it is that you think you need. That would mean uploading an image and telling us what you want to measure. For example, let's say you had the "index of the region" or label of the index, or the index of the label, or region of the label, or label of the region, or whatever it is or whatever you call it. Then what? What would you do then?
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!