how to extract pixels from a image {black and white only }

조회 수: 4 (최근 30일)
DB
DB 2017년 2월 16일
답변: Voss 2022년 5월 28일
I want to extract pixels [black and white ] above image ,how to get it ? and give me answer below questions ? Thanks Advance .........
1. find the horizontally number of ON pixels in each row..?[on=white pixels]
2. find the horizontally number of OFF pixels in each row and column as well..?[off=black pixels]
3. Plot the histogram in y direction for the ON pixel
4 how to display histogram for that pixels only .......

답변 (1개)

Voss
Voss 2022년 5월 28일
data = imbinarize(rgb2gray(imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/160786/image.jpeg')));
% 1. find the horizontally number of ON pixels in each row..?[on=white pixels]
n_white_per_row = sum(data,2)
n_white_per_row = 111×1
1 2 3 9 10 7 5 16 18 13
% 2. find the horizontally number of OFF pixels in each row and column as well..?[off=black pixels]
n_black_per_row = sum(~data,2)
n_black_per_row = 111×1
235 234 233 227 226 229 231 220 218 223
n_black_per_column = sum(~data,1)
n_black_per_column = 1×236
108 107 111 111 109 107 106 107 108 106 105 102 105 102 99 101 100 97 90 95 98 93 92 93 89 87 81 89 92 91
% 3. Plot the histogram in y direction for the ON pixel
barh(n_white_per_row,'EdgeColor','none','BarWidth',1)
set(gca(),'YDir','reverse','YLim',[0.5 size(data,1)+0.5])
% 4 how to display histogram for that pixels only .......
% I don't know what "that" means.

카테고리

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