MATLAB sum of pixel between 0 and 100 intensity
3 views (last 30 days)
Show older comments
Hello. I trying to generate an image into histogram and in that image i have to calculate the sum of pixels. Then after that i have to change it to grayscale but how do i calculate sum of pixel between 0 and 100 intensity of the grayscale image? I tried adding the code y=(x<=100) but the value suddenly change to binary.
ths is my code
clc;
clear;
I=imread('image.jpg');
imhist(I);
pixelCounts=imhist(I);
numberOfPixels = sum(pixelCounts)
x=rgb2gray(I);
y=(x<=100)
0 Comments
Answers (1)
KSSV
on 20 Jun 2020
If I is your image.
idx = I >= 0 & I <= 100 ; % this gives logical indices of the pixels present
N1 = nnz(idx(:)) ; % this gives total
N2 = sum(idx(:)) ; % this gives total
0 Comments
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!