如何从regionprops中绘制对象的箱形图?

时间:2015-08-24 06:02:46

标签: matlab image-processing

actual graph

我想绘制平均值和百分位数,如图所示。我尝试了一些代码来绘制框图,但我得到了不同的东西 output

I = propsSynthesizeImage;
imshow(I)
title('Synthetic Image')
% Create a Binary Image
% Segment the grayscale image by creating a binary image containing    the    objects in the image.
BW = I > 0;
imshow(BW)
title('Binary Image')
s = regionprops(BW, I, {'Centroid','PixelValues','BoundingBox'});
imshow(I);
numObj = numel(s);
title('Standard Deviation of Regions');
hold on
for k = 1 : numObj
    s(k).StandardDeviation = std(double(s(k).PixelValues));
    text(s(k).Centroid(1),s(k).Centroid(2), ...
        sprintf('%2.1f', s(k).StandardDeviation), ...
        'EdgeColor','b','Color','r');
end
figure
boxplot(1:numObj,[s.StandardDeviation])
xlabel('Region Label Number');
ylabel('Standard Deviation');
hold off

1 个答案:

答案 0 :(得分:1)

箱形图可视化分布。目前,您正在绘制标量。

要绘制分布(并让Matlab找到中位数,分位数等),绘制

boxplot(1:numObj,{s.PixelValues})

请注意,boxplot不会显示标准偏差(相反,它会显示四分位间范围),如果基础像素值具有多模态分布,则可能会产生误导性结果。