MATLAB: Regionprops and standard deviation (binary image)

binary imageImage Processing Toolboxregionpropsstd

Hi everyone, i am using the function" regionprops" to get the largest perimeter in my binary image. I have got the value of the largest perimeter but still need to have its standard deviation. Does anyone know how to get this std? Thank you very much

Best Answer

When you do the regionprops() also ask for 'PixelIdxList' . When you find the region with the largest perimeter, extract its PixelIdxList. Use that PixelIdxList to index the 2D image, and take std() of the pixels that are returned.
If your original image was color, then sometimes the easiest is to break it into 3 variables and use PixelIdxList on each. That is not the only way, but it is easy to understand whereas the conversion of 2D linear indices to appropriate 3D indices can be a bit tricky to understand.