To download NI software, including the products shown below, visit ni.com/downloads.
This example demonstrates how to calculate the relative edge sharpness of an image to determine the best camera focus.
Description
It may be necessary in some applications to programmatically determine the quality of an image. "Quality" is a subjective term, but it is almost universally accepted that sharp focus is one characteristic of a high quality image. We can measure the sharpness of an image, at least relatively, by taking advantave of filters and convolution in NI Vision.
Basically, we are taking an image in, and then applying various convolution and filtering algorithms. These algorithms effectively differentiate the image, and highlight features in the image where there is a high change in pixel value in a small change of space. In other words, the derivative of a function which represents pixel values with respect to space will be the highest on sharp color (or intensity changes).
In our resulting image, the edges will show up as white, and everything else as black. We then take the mean value of the resulting image. If we pan through the various lens settings while on a constant field of view, we can surmise that the highest mean value of the set corresponds to the lens setting that provides the sharpest focus. It is important to remember that this is relative, but it can be helpful for many applications.
Requirements
Software
Hardware
Steps to Implement or Execute Code
Additional Information or References
This example requires IMAQdx. If you do not have a license for IMAQdx, you can still download this example and replace the IMAQdx VIs with IMAQ VIs.
**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
can you convert this to LV 8.6?
the filter vi's are just not working for me. gettin error -1074396080 all the time
I get the same error than TusDavid, did anyone solve it?