比较2图像的焦点 [英] Comparing focus of 2 image
问题描述
我试图开发对象检测算法。我计划比较2图像与不同的焦距。正确对焦的图片和正确对焦背景的图片。
通过阅读有关;然后使用结果的凸包来组合片段作为抓取并插入彩色图像。如果您不熟悉抓取功能,请勾选我对此问题的回答。
但是也许一个更简单的方法也可以在这里工作。您可以尝试应用强大的模糊到你的渐变图像,而不是精确匹配,看看在这种情况下你的差异。下面的图片展示了我改变二进制掩码的区别的想法。
>
I'm trying to develop object detection algorithm. I plan to compare 2 image with different focus length. One image that correct focus on the object and one image that correct focus on background.
By reading about autofocus algorithm. I think it can done with contrast detection passive autofocus algorithm. It work on light intensity on the sensor.
But I don't sure that light intensity value from the image file has the same value as from the sensor. (it not a RAW image file. a jpeg image.) Is the light intensity value in jpeg image were the same as on the sensor? Can I use it to detect focus correctness with contrast detection? Is there a better way to detect which area of image were correct focus on the image?
I have tried to process the images a bit and I saw some progress. THis is what I did using opencv:
- converted images to gray using cvtColor(I, Mgrey, CV_RGB2GRAY);
- downsampled/decimated them a bit since they are huge (several Mb)
- Took the sum of absolute horizontal and vertical gradients using http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=sobel#cv.Sobel. The result is below. The foreground when in focus does look brighter than background and vice versa.
You can probably try to match and subtract these images using translation from matchTemplate() on the original gray images; and then assemble pieces using the convex hull of the results as initialization mask for grab cut and plugging in color images. In case you aren’t familiar with the grab cut, chceck out my answer to this question.
But may be a simpler method will work here as well. You can try to apply a strong blur to your gradient images instead of precise matching and see what the difference give you in this case. The images below demonstrate the idea when I turned the difference in the binary masks.
这篇关于比较2图像的焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!