How many white pixels in selected pixels?

조회 수: 1 (최근 30일)
Dinuka Ravimal
Dinuka Ravimal 2020년 6월 7일
편집: Image Analyst 2020년 6월 12일
I'm selecting one particular column and then selecting 100 rows on image. That means I'm extracting 100 pixels from image. Now I want to know how to find how many white pixels (>200 gray value) are in the selected pixels. Could you please write down that code?
clc
clear
% read image
im = imread('6.jpg');
imshow(im)
% convert to gray scale image
imgray = rgb2gray(im);
% size of the gray image
[r,c] = size(imgray);
% ask user to enter column number
fprintf('Column Number Should be between 1 and %d \n',c);
col = input('Please Select a column: ');
% ask user to input starting row number
fprintf('Rows should be bwtween 1 and %d \n',r);
start_row = input('Please Select starting Row Number: ');
% ask user to input ending row number
end_row = input('Please Select ending Row Number: ');
% extracted rows from the column
ext_rows = imgray(start_row:end_row,col);
I want to know how many white pixels (>200 value) in selected pixels?
  댓글 수: 3
Dinuka Ravimal
Dinuka Ravimal 2020년 6월 7일
Thank you so much, it's working.
Image Analyst
Image Analyst 2020년 6월 7일
Stijn, can you move it down to the official Answers section instead of the comment section which is used for asking for more clarification? You can get "reputation points" if you put it down there, unlike up here, and if Dinuka accepts the answer.

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2020년 6월 7일
If A is an array and you want to find how many values > 200 use:
nnz(A>200)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by