필터 지우기
필터 지우기

how to check the value 0 in row (200 till 240) ,whole column is true?

조회 수: 1 (최근 30일)
Nurul Najmah
Nurul Najmah 2015년 5월 5일
댓글: Walter Roberson 2015년 5월 5일
i have binary image (320 columns 240 rows).
i want to check the value of row(200-240) is all white(0).

답변 (1개)

Walter Roberson
Walter Roberson 2015년 5월 5일
subimage = YourImage(200:240, :);
if all(subimage(:) == 0)
disp('rows were all pure white');
else
disp('there was at least one pixel somewhere in one of the rows that was not pure white');
end
  댓글 수: 2
Nurul Najmah
Nurul Najmah 2015년 5월 5일
it never show row all pure white eventhough its all white..
Walter Roberson
Walter Roberson 2015년 5월 5일
Untested code:
rows_of_interest = 200:240;
subimage = YourImage(rows_of_interest, :);
rowmax = max(subimage,2);
row_is_all_blank = rowmax == 0;
if all(row_is_all_blank)
disp('all rows were all pure white');
else
disp('Some rows had non white.');
disp('row# contains');
rows_with_nonblank = rows_of_interest(~row_is_all_blank);
max_in_nonblank_row = rowmax(~row_is_all_blank);
fprintf(' %3d %3d\n', [rows_with_nonblank(:), max_in_nonblank_row(:)].' );
end
Keep in mind that your question was not to figure out which rows were all white: your question was to figure out whether all of that portion of the image is white, where you defined white as strictly being equal to 0, not (for example) the very next shade up.
Also keep in mind that when it comes to images, "white" is associated with the maximum value, and the value associated with 0 is typically "black". This code uses your definition of white as being 0 rather than as white being the maximum value.

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

Community Treasure Hunt

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

Start Hunting!

Translated by