MATLAB 程序错误;
error code:
--------------------------------------------------
clear
I = imread('cameraman.tif');
figure; imshow(I); title('Original Image');
PSF = fspecial('motion',13,45);
figure; imshow(PSF,[],'notruesize'); title('Original PSF');
Blurred = imfilter(I,PSF,'circ','conv');
figure; imshow(Blurred); title('Blurred Image');
INITPSF = ones(size(PSF));
[J P]= deconvblind(Blurred,INITPSF,30);
figure; imshow(J); title('Restored Image');
figure; imshow(P,[],'notruesize');
title('Restored PSF');
WEIGHT = edge(I,'sobel',.28);
se1 = strel('disk',1);
se2 = strel('line',13,45);
WEIGHT = ~imdilate(WEIGHT,[se1 se2]);
WEIGHT = padarray(WEIGHT(2:end-1,2:end-1),[2 2]);
figure; imshow(WEIGHT); title('Weight Array');
P1 = P;
P1(find(P1 < 0.01))=0;
[J2 P2] = deconvblind(Blurred,P1,50,[],WEIGHT);
figure; imshow(J2);
title('Newly Deblurred Image');
figure; imshow(P2,[],'notruesize');
title('Newly Reconstructed PSF');
------------------------------------------------
Instead its type was logical.
Error in ==> deconvblind>parse_inputs at 399
iptcheckinput(WEIGHT,{'double'},{'finite'},mfilename,'WEIGHT',5);
Error in ==> deconvblind at 122
[J,P,NUMIT,DAMPAR,READOUT,WEIGHT,sizeI,classI,sizePSF,FunFcn,FunArg] = ...
答案:WEIGHT = ~imdilate(WEIGHT,[se1 se2]);%%权重weight的尺寸在deconvblind函数中要求和Blurred图像尺寸一样,所以扩展的语句,也就是下面一行去掉
%WEIGHT = padarray(WEIGHT(2:end-1,2:end-1),[2 2]);
[J2 P2] = deconvblind(Blurred,P1,50,[],double(WEIGHT));%%weight为logical型,转化为double型即可!
其他:由报错信息可知,是deconvblind函数的调用出了问题。在我的Matlab中显示的是第五个参数格式错误,也就是WEIGHT。这好像是控制参数,如果不是很需要,就把它去掉,就可以无出错地运行。
改为:
[J2 P2] = deconvblind(Blurred,P1,50,[]);
上一个:matlab solve 函数 求解
下一个:我调用matlab的生成的dll,在MFC中输入3个数组,然后做出3张图,显示在一个对话框中。