|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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.
|
|
#2
|
|||||
|
|||||
|
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.
|
|
#3
|
|||
|
|||
|
Re: BinaryImage Pixel Access
GetNumberParticles only works after a particle filter is applied, we tried that. imaqGetPixel may do the trick. Thanks!
|
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
Re: BinaryImage Pixel Access
Appreciate the note on performance.
|
|
#6
|
||||
|
||||
|
Re: BinaryImage Pixel Access
If you're using opencv, look into image moments.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|