Skip to content

Instantly share code, notes, and snippets.

@MichaelTr7
Last active February 6, 2022 22:38
Show Gist options
  • Save MichaelTr7/7d3d6cbe99493dbd24db1190ce3db262 to your computer and use it in GitHub Desktop.
Save MichaelTr7/7d3d6cbe99493dbd24db1190ce3db262 to your computer and use it in GitHub Desktop.
Retrieving histogram of greyscale image in MATLAB (without imhist() and histogram() functions).
clc;
clear;
clf;
Image = rgb2gray(imread("peppers.png"));
Bins = zeros(256,1);
for Intensity = 0: 255
Bins(Intensity+1) = nnz(Image == Intensity);
end
plot((0:255),Bins);
xlabel("Pixel Intensity"); ylabel("Number of Occurences");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment