How to calculate no. of pixels having value greater than a particular RGB value?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to calculate the no. of pixels having value greater than a particular RGB value for eg. lets say 180. (pic(mm,nn,1) > 180 && pic(mm,nn,2) > 180 && pic(mm,nn,3) > 180).
0 commentaires
Réponses (3)
Azzi Abdelmalek
le 6 Nov 2013
Modifié(e) : Azzi Abdelmalek
le 6 Nov 2013
idx=pic>180
out=sum(idx(:))
0 commentaires
Image Analyst
le 6 Nov 2013
% Extract the individual red, green, and blue color channels and threshold them.
binaryR = rgbImage(:, :, 1) > 180;
binaryG = rgbImage(:, :, 2) > 180;
binaryB = rgbImage(:, :, 3) > 180;
% AND the binary images together to find out where ALL THREE are > 180.
binaryImage = binaryR & binaryG & binaryB;
% Count the number of pixels where it's true that all 3 are > 180;
pixelCount = sum(binaryImage(:));
4 commentaires
Anbarasan Rajan
le 8 Nov 2018
pixelCount=sum(binaryImage(:)); i think this will only give us the total pixel intensity. for example, if 10 pixels are having the intensity of 50, this comment will give us 500 which is the total intensity value of the pixels present in thet image.
if i'm wrong please let me know.
Guillaume
le 8 Nov 2018
"if i'm wrong please let me know."
You're wrong. binaryImage is 1 when all 3 channels of the pixel is above the threshold, and 0 otherwise. Hence the sum is the number of pixels, Image Analyst could have used nnz instead:
pixelCount = nnz(binaryImage);
suganya sri
le 13 Nov 2017
how to find pixel value in somelocation, pls anybody help me
1 commentaire
Image Analyst
le 13 Nov 2017
pixelValue = impixel(yourImage, row, column);
Voir également
Catégories
En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!