确定用于在MATLAB中对运动模糊图像进行模糊处理的正确参数 [英] Determine the right parameters for deblurring motion blurred images in MATLAB

查看:114
本文介绍了确定用于在MATLAB中对运动模糊图像进行模糊处理的正确参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在程序上,我需要在图片上自动执行运动模糊处理.目前,我为 LEN THETA 做一个 for 循环,从 LEN 0:50 THETA (来自 1:180 ).通过这种方式可以产生大量运动不模糊的图像-有些是正确的,有些是错误的.现在这是我的问题:我如何确定哪一组参数产生最接近原始照片的一组参数?

我正在考虑使用像素比较.有什么想法吗?

这是我生成的图像的示例:


这样,要在您的代码中使用此代码,您的 for 循环应如下所示:

  psnr_max = -realmax;对于LEN = 0:50对于THETA = 1:180%//取消模糊图像%//...%//...%//计算PSNRmse =平均值(平均值((im2double(I)-im2double(K)).^ 2,1),2);psnr = 10 * log10(1 ./mean(mse,3));if(psnr> psnr_max)%//获得最大的PSNR并获得LEN_final = LEN;%//使它如此的参数THETA_final = THETA;psnr_max = psnr;结尾结尾结尾 


此循环将遍历每对 LEN THETA ,而 LEN_final THETA_final 将是这些参数可以为您提供最佳的图像重建效果(不模糊).

I'm currently working on program and I need to automatic perform motion un-blurring on a picture. Currently, I make a for loop for LEN and THETA, guessing from LEN 0:50 and THETA from 1:180. There are plenty of motion un-blurred pictures produce in this way - some correct and some are wrong. Now here is my problem: How do I actually determine which set of parameters yields the one most closest to original photo?

I'm thinking of using pixel comparison. Any idea on this?

Here's a pictorial example of what I generated:

http://dl.dropboxusercontent.com/u/81112742/Capture.JPG

解决方案

If you have access to the original clean image, I would compute the Peak Signal to Noise Ratio (PSNR) for all of the images you have generated, then choose the one with the highest PSNR. Amro posted a very nice post on how to compute this for images and can be found here: https://stackoverflow.com/a/16265510/3250829

However, for self-containment, I'll post the code to do it here. Supposing that your original image is stored in the variable I, and supposing your reconstructed (un-blurred) image is stored in the variable K. Therefore, to calculate the PSNR, you would need to calculate the Mean Squared Error first, then use it to calculate the PSNR. In other words:

mse = mean(mean((im2double(I) - im2double(K)).^2, 1), 2);
psnr = 10 * log10(1 ./ mean(mse,3));

The equations for MSE and PSNR are:

Source: Wikipedia


As such, to use this in your code, your for loops should look something like this:

psnr_max = -realmax;
for LEN = 0 : 50
    for THETA = 1 : 180
        %// Unblur the image
        %//...
        %//...
        %// Compute PSNR
        mse = mean(mean((im2double(I) - im2double(K)).^2, 1), 2);
        psnr = 10 * log10(1 ./ mean(mse,3));
        if (psnr > psnr_max) %// Get largest PSNR and get the
            LEN_final = LEN; %// parameters that made this so
            THETA_final = THETA;
            psnr_max = psnr;
        end
    end
end


This loop will go through each pair of LEN and THETA, and LEN_final, THETA_final will be those parameters that gave you the best reconstruction (un-blurring) of the image.

这篇关于确定用于在MATLAB中对运动模糊图像进行模糊处理的正确参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆