How can I find minima in specific regions & closest bin to value in Histogram?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi all,
As part of my work I am producing greyscale images that produce similar histogram profiles (see. fig). The information I am trying to obtain from each is
1) Peak count greyscale value
2) The greyscale value of the minima shown in region X
3) The closest greyscale value that corresponds to 25% of the peak pixel count in region Y. So for histogram shown in fig; the bin with value approx 3000000 in region Y (12000000* 0.25) .
Peak value I have already successfully calculated. Can anyone point me in the direction of how to tackle 2) & 3)? Any help would be greatly apprechiated.
Thanks, Joe
0 件のコメント
採用された回答
Image Analyst
2018 年 12 月 9 日
Try this:
% Read in image.
grayImage = imread('pout.tif');
imshow(grayImage, []);
% Get histogram
counts = imhist(grayImage);
plot(counts, '-', 'LineWidth', 2);
xlabel('Gray Level', 'FontSize', 15);
ylabel('Count', 'FontSize', 15);
title('Histogram', 'FontSize', 15);
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Find max count and what gray level it's at.
[maxCount, glAtMaxCount] = max(counts)
% Find the min in region X
minCount = min(counts(1:glAtMaxCount-1))
glAtMinCount = find(counts(1:glAtMaxCount-1) <= minCount) % Might be more than one.
% Find the closest greyscale value that corresponds to 25% of the peak pixel count in region Y
temp = counts;
temp(1:glAtMaxCount) = maxCount;
gl25 = find(temp < 0.25 * maxCount, 1, 'first')
% Put red line there
hold on;
line([gl25, gl25], ylim, 'Color', 'r', 'LineWidth', 2);
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!