Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

how to check contrast ratio

Hi,
i have a camera to take "live" pictures and i will need to check for the contrast ratio, or the so call focus level to know if the picture is out of focus anot.. i tried this programme but have completely no idea how it works or wad it does. Plz help me with this problem thx
 
~vic
 
-----
0 Kudos
Message 1 of 5
(4,241 Views)
Sorry, lemme rephrase my qns.. how do i calculate the intensity of a jpg file?
0 Kudos
Message 2 of 5
(4,238 Views)
Hi Vic,

Thank you for posting on the National Instruments discussion forums.

I've taken a look at these two examples, and if you're trying to determine whether part of your picture is in focus or not, it looks like Autofocus Frequency.VI should do what you're looking for.  This VI takes a picture, extracts a rectuangular portion of the image, then performs an FFT to determine whether this part of the image is in focus.  It is doing this continuously and charting the Focus Quality until the VI is stopped.

If this is what you are looking for in your application, I would be glad to help you implement this.  It would help, though, if you could explain exactly what you are looking to do.  Thanks.


Rishee B.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 5
(4,219 Views)
>> I've taken a look at these two examples, and if you're trying to determine whether part of your picture is in focus or not, it looks like Autofocus Frequency.VI should do what you're looking for. 
 
Is there a VB example of this? If not, can you give me the pseudo-code for replicating what the VI does?
 
Thanks!
0 Kudos
Message 4 of 5
(3,923 Views)
Here's my favorite focus measurement in pseudocode:
 
Apply Prewitt filter to detect edges in image.
 
Use Quantify Image to get statistics for entire image.  I have found that the Std. Dev. of the pixel intensities is a great focus indicator.  The mean intensity also works pretty well.
 
To speed things up, I frequently reduce the image resolution.  Extracting every other pixel in both directions gives you an image that is half the size and processes four times faster than the original image.  Unless you have really, really fine details, this usually works just as well as the original image.
 
Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 5 of 5
(3,905 Views)