MATLAB sum of pixel between 0 and 100 intensity

1 次查看(过去 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)

回答(1 个)

KSSV
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

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by