Detect black pixels in arbitrary region of a an image
4 ビュー (過去 30 日間)
古いコメントを表示
I want help to detecting black pixels in arbitrary region of a an image in matlab , i want to detect black line on right of below image and If the new image has a black line on the right then let the user know about the black line in the image.
1 件のコメント
Image Analyst
2020 年 1 月 5 日
What do you mean by "below right"? Do you mean the last line of the image, and on the right half? If so, that contradicts "arbitrary region" which seems to indicate that it could be anywhere in the image.
Is there any requirement on the size of the line region? Or is one pixel big enough?
What do you mean by "below image"? The image is everything. Even the bottom of the image is in the image, not below it. Do you have some kind of medical image screenshot where you have the image in the center and then black surround with some kind of text annotation there? You forgot to attach images where you show where there ARE and ARE NOT a black line region that you want to detect. Please attach one image of each type.
回答 (1 件)
awezmm
2020 年 1 月 5 日
編集済み: awezmm
2020 年 1 月 5 日
if img is the variable name of your original rgb image:
redChannel = img(:,:,1);
greenChannel = img(:,:,2);
blueChannel = img(:,:,3);
% black pixels are where red channel and green channel and blue channel in an rgb image are 0;
blackpixelsmask = redChannel == 0 & greenChannel == 0 & blueChannel == 0;
% show binary image where the black pixels were
imshow(blackpixelsmask)
% check and alert if any pixels where black by checking binary image for any '1' elements
if any(blackpixelsmask(:))
% alert user
disp("black pixels in image found!")
end
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!