资源简介
基于Matlab的图像去模糊代码,基于Fergus 2006年的CVPR 论文
代码片段和文件信息
function [out_impatch_location]=automatic_patch_selector(impatch_sizeweightsat_mask)
% Author: Rob Fergus
% Version: 1.0 distribution code.
% Project: Removing Camera Shake from a Single Image SIGGRAPH 2006 paper
% Copyright 2006 Massachusetts Institute of Technology
SMOOTH_SIGMA = 3;
%% Assume input image is 0:255
%% patch_size is integer (odd)
%% sat_mask is binary & same size as im
%% weight is tuning parameter btw. variance and non-saturated pixels
%%% Get size of input im
[IIJJ] = size(im);
%%% Compute centre weighting mask
[xxyy] = meshgrid([1:JJ]-round(JJ/2)[1:II]-round(II/2));
centre_weight_mask = exp(-weight/(JJ^2)*(xx.^2+yy.^2));
II = II*2; JJ = JJ*2;
%% shift by patch_size
centre_weight_mask = real( ifft2( fft2(centre_weight_maskIIJJ) .* fft2(delta_kernel(patch_size)IIJJ) ) );
%%% Get patch mask
pmask = ones(patch_size)/patch_size.^2;
%%% Find patch with largest variance
ei2 = real( ifft2( fft2(im.^2IIJJ) .* fft2(pmaskIIJJ) ) );
mu2 = real( ifft2( fft2(imIIJJ) .* fft2(pmaskIIJJ) ) ).^2;
w = ei2 - mu2;
%%% Compute convolution with sautration mask
q = real( ifft2( fft2((sat_mask)IIJJ) .* fft2(pmaskIIJJ) ) );
%% q is small if more pixels are available for use
combined = (centre_weight_mask).*w./(q*mean(im(:)).^2+1); %% more variance less saturation
%% now find stable maximum (smooth resonse image)
f = fspecial(‘gaussian‘[8 8]SMOOTH_SIGMA);
combined = real( ifft2( fft2(combinedIIJJ) .* fft2(fIIJJ) ) );
%%% crop to avoid edge effects
combined = combined(patch_size:II/2patch_size:JJ/2);
%%% find max
[tmpmm] = max(combined(:));
[sysx] = ind2sub(size(combined)mm);
%%% get coords for axis
patch_location = [sx sy] -1;
%% chop out patch
out_im = im(sy-1:sy-2+patch_sizesx-1:sx-2+patch_size);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 30209 2007-02-22 21:50 README
目录 0 2007-02-22 21:48 code\
目录 0 2007-02-22 21:43 images\
目录 0 2007-02-22 21:43 priors\
目录 0 2007-02-22 21:43 results\
文件 5685 2007-02-22 21:41 code\GaussianMixtures1D.m
文件 28466 2007-02-22 21:41 code\deblur.m
文件 2870 2007-02-22 21:41 code\estimate_priors2.m
文件 1088 2007-02-22 21:41 code\greenspan.m
文件 5835 2007-02-22 21:41 code\initialize_parameters2.m
文件 545 2007-02-22 21:41 code\invDel2.m
文件 495 2007-02-22 21:41 code\mix_exponentials.m
文件 2641 2007-02-22 21:41 code\move_level.m
文件 3716 2007-02-22 21:41 code\plotgray.m
文件 656 2007-02-22 21:41 code\reconsEdge3.m
文件 2212 2007-02-22 21:41 code\rgb2gray_rob.m
文件 1879 2007-02-22 21:41 code\automatic_patch_selector.m
文件 556 2007-02-22 21:41 code\clip_image.m
文件 2527 2007-02-22 21:41 code\create_greenspan_settings.m
文件 358 2007-02-22 21:41 code\delta_kernel.m
文件 12443 2007-02-22 21:41 code\train_ensemble_evidence6.m
文件 1777 2007-02-22 21:41 code\train_ensemble_get.m
文件 1830 2007-02-22 21:41 code\train_ensemble_get_lambda.m
文件 13451 2007-02-22 21:41 code\train_ensemble_main6.m
文件 1816 2007-02-22 21:41 code\train_ensemble_put.m
文件 1868 2007-02-22 21:41 code\train_ensemble_put_lambda.m
文件 3570 2007-02-22 21:41 code\train_ensemble_rectified5.m
文件 4408 2007-02-22 21:41 code\train_blind_deconv.m
文件 571 2007-02-22 21:41 code\normMDpdf.m
文件 1559 2007-02-22 21:41 code\histmatch.m
文件 558 2007-02-22 21:41 code\prefZeros.m
............此处省略17个文件信息
评论
共有 条评论