LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create fast intenstiy histogram without Vision toolkit

Solved!
Go to solution

I am trying to create an intensity histogram from an 8bit gray scale image that is being acquired from a USB camera.  Using the drivers that camera that came with the camera I am able to get a 2D array of image data (1021 x 764).  What I am doing is concatenate all the columns in the array to create a 1d array.  I then use the general histogram function that is set to a max of 256, min of 0 and 100 bins.  This approach takes approx. 5 secs. to complete. Attached is my approach.

 

Is there a better approach that would process much faster? 

 

If I use the Vision functions to convert the image data to an IMAQ image and then using the IMAQ histograph function, it processes almost immediately.  However I do not wish to use the Vision functions because I do not wish to pay for a Vision runtime license for each installation of my application.

 

Thanks

Terry.

0 Kudos
Message 1 of 5
(3,210 Views)

It looks like you are trying to do the same thing as Reshape Array.  If you used that function, how fast does it run?

0 Kudos
Message 2 of 5
(3,209 Views)
Solution
Accepted by topic author Terry_S

This is the simplest way to obtain a histogram.  Is it fast enough?

 

Histogram.png

 

That will give a 256-bin histogram, but I iust noticed that you want 100 bins for some reason.  The easiest way to do that is to scale your image from 0-255 to 0-99 (multiply by 99/255) and do the same thing, something like this:

Histogram2.png

Message 3 of 5
(3,190 Views)

Thanks for the suggestion GregS.  However the array function that you have in the inner for loop, where did you find this?  This is something I have not discovered yet in labview

0 Kudos
Message 4 of 5
(3,179 Views)

That's the In Place Element Structure, which ensures that the array is not copied when it is used.  You can find it in the Structures palette since LabVIEW 2009 I think.  Or you can effectively replace it with the pair of functions Array Index and Array Replace - the IPES is just a little cleaner!

0 Kudos
Message 5 of 5
(3,176 Views)