regionprops and standard deviation (binary image)

23 ビュー (過去 30 日間)
marie semaan
marie semaan 2018 年 1 月 26 日
コメント済み: marie semaan 2018 年 1 月 31 日
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

採用された回答

Walter Roberson
Walter Roberson 2018 年 1 月 26 日
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.
  5 件のコメント
Walter Roberson
Walter Roberson 2018 年 1 月 29 日
s = regionprops(binaryimage,'all')
[~, objidx] = max(allPerimeters);
obj_pixels = OriginalImage(s(objidx).PixelIdxList);
if length(unique(obj_pixels)) == 1
sprintf('all pixels in the object are exactly the same! All of them have value %d\n', obj_pixels(1));
else
std(double(obj_pixels))
end
Depending how your image was constructed and how you are constructing your binary image, the situation could either be an improbable coincidence or something to be expected. You could post your image and your code that creates the binary image for us to examine.
marie semaan
marie semaan 2018 年 1 月 30 日
Thank you

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 1 月 30 日
You can get the standard deviation of the gray levels in the blob with the largest perimeter more directly (than by using PixelIdxList) like this:
% Get blob with largest perimeter.
binaryImage = bwpropfilt(binaryImage, 'Perimeter', 1);
% Get standard deviation of pixels in that blob
stdGrayLevels = std(double(grayImage(binaryImage)))
  1 件のコメント
marie semaan
marie semaan 2018 年 1 月 31 日
Thank you for your help. I prefer to use the above code in my case. i have tried your code but it did not work.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by