当我从命令=
中取出img中的图像时imread('C:\Users\Administrator\Desktop\Detect\F04U2MPIXQG15WQS.LARGE.jpg');
figure,imshow(img)
它工作正常,但是当我使用
时[filename, pathname] = ...
uigetfile({'*.jpg';'*.jpeg';'*.png';'*.*'},'Select Image File');
img=strcat(pathname,filename);
错误显示为skinDetect2Func中的错误(第8行)
yuv(:,:,y)=(img(:,:,r)+ 2. * img(:,:,g)+ img(:,:,b))/ 4;错误 bwFingers1(第39行)
出= skinDetect2Func(IMG);
任何人都可以帮助我,我只是被困在这里。 :(
以下是完整的代码:
function out=skinDetect2func(img)
imshow(img);
sz=size(img); r=1;g=2;b=3;y=1;u=2;v=3;
yuv=img;
region=yuv;
yuv(:,:,y) = (img(:,:,r)+2.*img(:,:,g)+img(:,:,b))/4;
yuv(:,:,u) = img(:,:,r)-img(:,:,g);
yuv(:,:,v)=img(:,:,b)-img(:,:,g);
region = (yuv(:,:,u)>20 & yuv(:,:,v)<74) .* 255;
toc;
out=region;
%filtering
out=im2bw(out); out=bwareaopen(out,100);
out=imdilate(out,strel('diamond',4));
%retain largest only
res=out;
cc=bwconncomp(res);
arr=(cellfun('length',cc.PixelIdxList));
newLabel=res;
if ~isempty(round(arr))
msz=0;
for i=1:length(arr)
if msz<arr(i:i)
msz=arr(i:i);
index=i;
end
end
labels=labelmatrix(cc);
newLabel=(labels==index);
out=newLabel;
end
out=imfill(out,'holes');
end***
答案 0 :(得分:0)
EHM,
这是一个字符串:
img=strcat(pathname,filename); % STRing conCATenation
您仍然需要imread
...
正确的代码是
imgpath=strcat(pathname,filename);
img=imread(imgpath);