Plotting histogram of image data present in a stack
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Deepa Maheshvare
le 14 Oct 2020
Commenté : Ameer Hamza
le 14 Oct 2020
Hi All,
I have looked at the examples shown here to underetand how to plot histogram of a single image data. But
it's not clear to me how the data in a stack can be plotted.
For exmaple, I tried
f = "Test_Image.tiff";
img_data = imfinfo(f);
imhist(img_data)
test_image stack.
This returns
double, uint8, int8, logical, uint16, int16, single, uint32, int32
Instead its type was struct.
Any suggestions?
0 commentaires
Réponse acceptée
Ameer Hamza
le 14 Oct 2020
iminfo just read the metadata of the image. Use imread() to read the image as matrix
f = "Test_Image.tiff";
img_data = imread(f);
imhist(img_data)
If it is an rgb image, then first convert it to grayscale too
f = "Test_Image.tiff";
img_data = rgb2gray(imread(f));
imhist(img_data)
6 commentaires
Ameer Hamza
le 14 Oct 2020
By default imhist() uses 256 bins. You can get the counts using output of imhist()
[binCount, binLoc] = imhist(imgs(:));
To get min and max values
mean(imgs(:))
min(imgs(:))
max(imgs(:))
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!