关于MATLAB插值算法的编程
目前我正在写一篇关于MATLAB插值算法的编程.程序编完后一直报错,Error: File: Untitled.m Line: 2 Column: 1Function definitions are not permitted at the prompt or in scripts.我把部分程序写在下面,有哪位高手能帮忙解答下吗?谢谢.
imcfa
function [dDiagPeak]=imcfa(imCover,iShowOn)
%% -------------------------------------------------------------------- %%
% Function: CFA插值,对角线处理,检测插值
% From: AC Gallagher, T Chen. Image authentication by detecting traces
% of demosaicing. IEEE Computer Society Conference on
% Computer Vision and Pattern Recognition Workshops, 2008:1-8.
% Argument: dDiagPeak: 检测结果 0.5频率处峰值
% imCover: 载体图像
% iShowOn: 显示结果: [1]-是,0-否
% Demo: imcfa(imread('lena.bmp'));
% Version: 1.02.20091112, 1.01.20090621
%% -------------------------------------------------------------------- %%
iptsetpref('ImshowBorder','tight');
dDiagPeak = 0;
% 参数预处理
if( ~exist('imCover') )
imCover = loadimg();
end
if isempty(imCover); return; end;
if( ~exist('iShowOn') )
iShowOn = 1;
end
% 图像预处理
imCover = double(imCover);
disp('Laplacian, Please wait...');
w = fspecial('laplacian',0);
imCover = imfilter(imCover,w,'replicate');
% imCover = abs(imCover); % 取绝对值还是不取绝对值,是个问题
[iH iW iL] = size(imCover); % iH=Height,iW=Width
iFFTMax = 2.^ceil(log2(iH+iW-1));
dDiagSum = zeros(iH+iW-1,iL);
dDiagNum = zeros(iH+iW-1,iL);
h = waitbar(0,'Diagonal, Please wait...');
for i = 1:iH
for j = 1:iW
iD = i+j-1; % 从1+1=2开始变为从1开始
for k = 1:iL
dDiagSum(iD,k) = dDiagSum(iD,k) + imCover(i,j,k);
dDiagNum(iD,k) = dDiagNum(iD,k) + 1;
end
end
waitbar(i/iH,h);
end
close(h);
dDiag = dDiagSum./dDiagNum;
dDiag = abs(fft(dDiag,iFFTMax));
dDiagSort = sort(dDiag(2:end,:)); % 排序
iPm = iFFTMax/2;
dDiagPeak = dDiag(iPm+1,:)./dDiagSort(iPm,:); % 0.5频率处
disp(['The peak magnitude (f=0.5) is: ',num2str(dDiagPeak)]);
% 显示结果
if iShowOn == 1
FigDiag(dDiag,iFFTMax,iL);
end