How to detect between any two pixels (preferably far) there exist an number of foreground pixels of an image (foreground=white and background=black)???
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have to count black pixels between two white pixels in any direction???
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/192077/image.jpeg)
0 个评论
回答(1 个)
Guillaume
2018-7-18
improfile (with the default 'nearest' interpolation) should give you all the pixels between your two points. It's then trivial to sum the pixels that are 0.
numblackpixels = sum(improfile(yourimage, locationofpixel1, locationofpixel2) == 0)
3 个评论
Guillaume
2018-7-18
I have absolutely no idea what you are asking now. There's only one direction between two given pixels.
另请参阅
类别
在 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!