Removing grey pixels from an image
1 次查看(过去 30 天)
显示 更早的评论
Hi I have an image in which there are black pixels and gray ones. I am trying a way to remove the gray pixels and just keep the black ones. I dont want to do im2bw because I believe it will just turn the gray to black. Thanks for the help
2 个评论
回答(2 个)
Image Analyst
2012-2-7
You can't replace with nothing because the image must remain rectangular. So try this
imageArray(imageArray ~= 0) = 255;
That will turn all pixels not equal to zero (pure black) to 255 (pure white). If you need 1 instead of 255 (like it's a logical or floating point image) then just use 1 instead of 255.
imageArray(imageArray ~= 0) = 1;
0 个评论
Shiva Arun Kumar
2012-2-7
Why would this not work?
bw=im2bw(I,0)
Where I is the image that was read in.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modify Image Colors 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!