MATLAB sum of pixel between 0 and 100 intensity

2 ビュー (過去 30 日間)
Muhammad Akmal Mohd Halim
Muhammad Akmal Mohd Halim 2020 年 6 月 20 日
回答済み: KSSV 2020 年 6 月 20 日
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 Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by