Creating a labelmatrix from a non-binary matrix for regionprops
Show older comments
I have an RGB image that I've imported into MATLAB using imread(), and I have code that has converted each cells value from RGB values into a single value (e.g. going from [1;2;1] to [34]). I'm using this to record unique labels for each cell, which correspond to labels of object's I've segmented previously. A small section of the matrix would like this:
0 0 0 52 52 52 0 0 0
0 0 52 52 31 31 31 0 0
0 52 52 0 0 31 31 31 31
0 0 0 0 0 31 31 0 0
I'm currently trying to run regionprops on the matrix with single values, thinking it would automatically interpret the matrix as a labelmatrix. This doesn't seem to be the case though as the 'label' property is not present in the output. I have areas in my matrix where objects are touching each other, and thus converting the single matrix to binary and running regionprops on that will lead to unwanted merging of objects.
Is there a way to get regionprops to recongize my matrix as a labelmatrix as-is? Or at least convert my matrix into a labelmatrix?
Accepted Answer
More Answers (0)
Categories
Find more on Region and Image Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!