MATLAB Answers

Drawing the gradient histogram of a grey image's one

20 views (last 30 days)
Hi folks,
I'm trying to plot the differential/gradient of a gray image's histogram, to highlight the points of interest more readily.
Searching for a function that does this hasn't yielded anything, but I'm unsure how to go about this in Matlab.
Is there a tutorial or something similar you can point me towards please?
Thanks in advance

  0 Comments

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 9 May 2020
See imgradient(): https://www.mathworks.com/help/images/ref/imgradient.html. Can you further clarify your question about the histogram.

  20 Comments

Ameer Hamza
Ameer Hamza on 12 May 2020
You can calculate the gradient vector like this
I = imread('image.jpeg');
I = rgb2gray(I);
[N, edges] = histcounts(I, 50);
edges = (edges(1:end-1)+edges(2:end))/2; % mid-points of histogram edges
N([1 end]) = 0;
grad = gradient(N, edges);
plot(edges, grad);
The point at which gradient change direction is the same as the locations given by findpeaks.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 13 May 2020
If you want you can use kmeans() to partition the histogram into sections. Personally I don't think it does a very good job but it will find the peak regions.

  0 Comments

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!