View Full Version : BinaryImage Pixel Access
themagic8ball
10-03-2014, 13:02
Does anyone know an easy way to get direct pixel access in a BinaryImage? Basically I just want a count of the 1 pixels vs the 0 pixels.
connor.worley
10-03-2014, 13:18
GetNumberParticles looks like it will do what you want (return the number of 1s, total bits can be calculated based on image size). GetImaqImage will return an Image* that can be passed to imaqGetPixel.
themagic8ball
10-03-2014, 13:59
GetNumberParticles only works after a particle filter is applied, we tried that. imaqGetPixel may do the trick. Thanks!
RyanCahoon
10-03-2014, 15:26
(Info largely based off of Google searches)
Calling imaqGetPixel repeatedly will probably give you very bad performance. If you're using C++, try imaqGetImageInfo instead to get direct access to the pixel data. See here (https://github.com/patfair/frc-camera-test/blob/master/BitmapImage.cpp) for an example of how to use it.
If you're using LabVIEW, there's a imaqImageToArray function, but this creates a copy of the image data, and so will be slower than the imaqGetImageInfo method.
You could also call imaqQuantify which returns summary statistics about the image, include the mean pixel value. You can multiply the mean by the pixel size of the image (width*height) to get the number of 1 pixels.
themagic8ball
10-03-2014, 15:31
Appreciate the note on performance.
faust1706
11-03-2014, 09:55
If you're using opencv, look into image moments.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.