MATLAB sum of pixel between 0 and 100 intensity
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
KSSV
2020-6-20
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!