寻找下列MATLAB主程序中的报错点?
clear;= uigetfile({'*.jpg';'*.bmp';'*.tif';'*.gif'},'Please choose a color picture...');
= size(fname);
y = fname(v);
switch y
case 0
errordlg('You Should Load Image File First...','Warning...');
case{'g';'G';'p';'P';'f';'F'}
I = cat(2,pname,fname);
Ori_Face = imread(I);
subplot(2,3,1),imshow(Ori_Face);
otherwise
errordlg('You should load image file first...','Warining...');
end
p = rgb_RGB(Ori_Face);
subplot(2,3,2);imshow(p);
low_pass = 1/9*ones(3);
image_low = filter2(low_pass,p);
subplot(2,3,3);imshow(image_low);
%自适应阈值程序
=size(image_low);
previousSkin2 = zeros(i,j);
i= size(Ori_Face,1);
j= size(Ori_Face,2);
changelist = [];
for threshold = 0.55:-0.1:0.05
two_value = zeros(i,j);
two_value(find(image_low>threshold))= 1;
change = sum(sum(two_value-previousSkin2));
changelist = ;
previousSkin2 = two_value;
end
= min(changelist);
optimalThreshold = (7-I)*0.1;
two_value = zeros(i,j);
two_value(find(image_low>optimalThreshold))=1;
subplot(2,3,4);imshow(two_value);
frontalmodel = imread('C:\Users\Administrator\Desktop\templet.jpg');
FaceCoord = [];
imsourcegray = rgb2gray(Ori_Face);
= bwlabel(two_value,8);
for i = 1:N
= find(bwlabel(two_value)== i);
bwsegment = bwselect(two_value,y,x,8);
numholes = 1-bweuler(bwsegment,4);
if (numholes>=1)
RectCoord = -1;
= size(bwsegment);
=center(bwsegment);
bwnohole = bwfill(bwsegment,'holes');
justface = uint8(double(bwnohole) .* double(imsourcegray));
angle = orient(bwsegment,cx,cy);
bw = imrotate(bwsegment,angle,'bilinear');
bw = bwfill(bw,'holes');
= bianjie(bw);
wx = (r-1+1);
ly = (d-u+1);
wratio = ly/wx;
if((0.8<=wratio)&&(wratio<=2))
S = ly*wx;
A = bwarea(bwsegment);
if(A/S>0.35)
= mobanpipei(justface,frontalmodel,ly,wx,cx,cy,angle);
end
if (ccorr>=0.6)
mfitbw = (mfit>=1);
invbw = xor(mfitbw,ones(size(mfitbw)));
source_with_hole = unit8(double(invbw).*double(imsourcegray));
final_image = unit8(double(source_with_hole)+double(mfit));
subplot(2,3,5);imshow(final_image);
imsourcegray= final_image;
subplot(2,3,6);imshow(Ori_Face);
end
if (RectCoord~=-1)
FaceCoord = ;
end
end
end
end
= size(FaceCoord);
for i = 1:numfaces
hd = rectangle('Position',FaceCoord(i,:),'LineWidth',3);
set(hd,'edgecolor','y');
end
你的代码中有许多语法错误和未定义变量。以下是一些明显的错误:
1. **文件读取错误**:
= uigetfile({'*.jpg';'*.bmp';'*.tif';'*.gif'},'Please choose a color picture...');
第一个等号前缺少输出变量名,如:` = ...`
2. **使用未定义变量**:
y = fname(v);
变量`v`没有定义。
3. **不完整的语句**:
changelist = ;
`changelist`需要被初始化或赋值。
4. **缺少变量定义**:
= min(changelist);
optimalThreshold = (7-I)*0.1;
左边缺少变量名。此外,变量`I`已经用来表示图像,并非预期的数字。
5. **未定义变量**:
FaceCoord = ;
`FaceCoord`没有被正确分配初始值。
6. **不合法的运算符**:
if((0.8=0.6)
`=`应该为比较运算符`==`。
7. **其他未定义变量**如`N`, `x`, `y`, `cx`, `cy`, `r`, `d`, `u`, `mfit`, `bianjie`, 等都需要在使用之前进行定义。
8. **拼写错误**:
- `bwfill`应该是`imfill`。
- `unit8`应该为`uint8`。
9. **条件语句的完整性**:
请确保所有条件语句(如`if`,`for`,`switch`)都有对应的结束语句(如`end`)。
若要修复这些错误,建议在代码中逐行检查语法、定义所有变量,并确保函数调用的参数和函数名正确无误。
--- 光学专家Gpt
页:
[1]