我正在尝试从输入图像恢复反射和照明。 问题出在%%% find r部分(反射率)。 'pinv'的结果是NaN矩阵......为什么? 代码:
c = imread('cats.jpg');
c = im2double(c(:, :, 1));
im = log(c);
filters = {fspecial('laplacian', 0.1) fspecial('laplacian', 0.3,fspecial('laplacian', 0.5) fspecial('laplacian', 0.7) fspecial('laplacian', 0.9)};
%%% conv
o = cell(1, 5);
for i = 1:5
o{i} = conv2(im, filters{i}, 'same');
end
%%% median
imd = o{1};
for i = 2:5
imd = cat(3, imd, o{i});
end
r_n = median(imd, 3);
%%% find r
[X,Y]=size(r_n);
fftr=zeros(X,Y);
fft_filters = cell(1, 5);
for i = 1:5
requiredpaddingX = X-3;
requiredpaddingY=Y-3;
filters{i}=padarray(filters{i},[requiredpaddingY requiredpaddingX],'post');
fft_filters{i} = fft2(filters{i});
fft_filterspinv{i}=pinv(fft_filters{i}); %%% HERE
fftr=r+r_n .* fft_filterspinv{i};
end
答案 0 :(得分:0)
Pinv不适用于稀疏函数,laplacian是稀疏的