MATLAB Answers

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 view (last 30 days)
Mohammad Bhat
Mohammad Bhat on 18 Jul 2018
Commented: Mohammad Bhat on 18 Jul 2018
I have to count black pixels between two white pixels in any direction???

Answers (1)

Guillaume on 18 Jul 2018
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)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!