location of pixel from minimum and maximum value is in histogram

조회 수: 7 (최근 30일)
Yudawan Hidayat
Yudawan Hidayat 2020년 4월 9일
댓글: Image Analyst 2020년 4월 16일
can you help me, please? I want to know where the location of pixel from minimum and maximum value is in histogram ?

답변 (2개)

Image Analyst
Image Analyst 2020년 4월 9일
See if this is what you want:
% Read in image.
grayImage = imread('pout.tif');
subplot(2, 1, 1);
imshow(grayImage);
% Get histogram.
[counts, grayLevels] = imhist(grayImage);
subplot(2, 1, 2);
bar(grayLevels, counts, 1);
grid on;
title('Histogram of image', 'FontSize', 20);
% Get the min and max gray levels directly from the image.
minGLImage = min(grayImage(:))
maxGLImage = max(grayImage(:))
% Get the min and max gray levels from the histogram (instead of directly from the image).
minGL = grayLevels(find(counts, 1, 'first'))
maxGL = grayLevels(find(counts, 1, 'last'))
% Should be the same as from the image.
% Get the rows and columns where these occur in the image.
[minRows, minColumns] = find(grayImage == minGL);
[maxRows, maxColumns] = find(grayImage == maxGL);
% Plot these locations over the image in the graphical overlay.
subplot(2, 1, 1);
hold on; % Don't blow away image.
plot(minColumns, minRows, 'b.', 'MarkerSize', 25);
plot(maxColumns, maxRows, 'r.', 'MarkerSize', 25);
title('Red = max. Blue = min.', 'FontSize', 20);

Yudawan Hidayat
Yudawan Hidayat 2020년 4월 13일
this is can't work in rgb image bro :(
  댓글 수: 5
Yudawan Hidayat
Yudawan Hidayat 2020년 4월 16일
I want to find the matrix value of the min and max histogram
Image Analyst
Image Analyst 2020년 4월 16일
I really don't know what this means. I've given you several guesses. Please define what a "max histogram" is because I don't know. All I know is that an image has one histogram, not several - no min histogram, no max histogram, no "any-kind-of-other" histogram, just one simple gray level histogram. And do you want the number of counts in the histogram bin? Or the values of pixels in the bins? Or the edges (min gray level and max gray level) that define one of the bins (like the one with the most counts in it)? Please give an example.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for USB Webcams에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by