Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   BinaryImage Pixel Access (http://www.chiefdelphi.com/forums/showthread.php?t=127697)

themagic8ball 10-03-2014 13:02

BinaryImage Pixel Access
 
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

Re: BinaryImage Pixel Access
 
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

Re: BinaryImage Pixel Access
 
GetNumberParticles only works after a particle filter is applied, we tried that. imaqGetPixel may do the trick. Thanks!

RyanCahoon 10-03-2014 15:26

Re: BinaryImage Pixel Access
 
(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 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

Re: BinaryImage Pixel Access
 
Appreciate the note on performance.

faust1706 11-03-2014 09:55

Re: BinaryImage Pixel Access
 
If you're using opencv, look into image moments.


All times are GMT -5. The time now is 12:12.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi