Detect black pixels in arbitrary region of a an image
11 views (last 30 days)
Show older comments
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 Comment
Image Analyst
on 5 Jan 2020
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.
Answers (1)
awezmm
on 5 Jan 2020
Edited: awezmm
on 5 Jan 2020
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 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!