Image Processing B&W Picture Calculate Color Percentage
7 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to do image processing on a B&W image.
I want to select a certain grayscale color and find out the perfectage of pixels that are lighter than that value.
Any starting points or code to help would be greatly appreciated. Thanks!
0 件のコメント
回答 (1 件)
Shunichi Kusano
2019 年 9 月 9 日
編集済み: Shunichi Kusano
2019 年 9 月 9 日
Hi Andar, this is the sample code.
img = imread('cameraman.tif');
imshow(img);
th = 100; % threshold to select brighter pixels
totalPixelNumber = numel(img);
%% method 1: making binary image
bw1 = img > th;
imshow(bw1)
nnz(bw1) / totalPixelNumber * 100% percentage
%% method2: finding brighter pixels directly
pixels = find(img > th);
length(pixels) / totalPixelNumber * 100% percentage
hope this helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!