登录论坛

查看完整版本 : [MATLAB图像处理] 在matlab7中可以运行的程序在2017和2012 中报错


Cdma
2018-05-14, 15:27
这是个指静脉图像处理的程序,在7中没有报错,在201

clc
clear
close
A=imread('E:\Matlab_12\workspace\IMAGE\Mycollection.bmp');
pic=rgb2gray(A);%转化为灰度图像
%一次裁剪
I=imcrop(pic,[65 270 1400 660]);
%中值滤波
b=medfilt2(I,[9,9]);
%均值滤波
%h=fspecial('average');
%b = filter2(h, I);
BW1=edge(b,'sobel');
%边缘检测
%BW1=edge(b,'sobel',0.05,'vertical');

%[BW1,thresh]=edge(b,'sobel');
%disp('Sobel算子自动选择阈值为:');
%disp(thresh)

se1 = strel('disk', 3);
%闭运算
BW2 = imdilate(BW1, se1);
se2 = strel('disk', 2);
BW2 = imerode(BW2, se2);
BW = bwmorph(BW2, 'thin',Inf);

figure(1)
subplot(121);
imshow(BW1);
title('边缘检测图像');
subplot(122);
imshow(BW);
title('边缘细化图像');

%ROI横向截取
[m,n] = size(BW);
r=0;
for i=1:floor(m/2)
for j=1:n
if BW(i,j)==1
r=i;
else
r=r;
end
end
end
t=0;
for i=floor(m/2):m-2
for j=1:n
if BW(i,j)==1
t=i;
break
else t=t;
end
end
if t==i
break
end
end
I1=imcrop(I,[0 r n t-r]);
%figure(8)
%imshow(I1);

%ROI垂直截取
[m,n] = size(I1);
L=zeros(1,n);
for j=1:n
L(j)=sum(I1(:,j));
end
figure(5)
plot(L);%画出图像数据
p1=0;
max1=L(floor(n/2));
for j=floor(n/2):n-1
%m(i)=(L(i)+L(i+15))/15;
%if m(i)>m(i-1)
%max=m(i+1);
% p1=(i+i+15)/2;
if L(j)>max1
max1=L(j);
p1=j;
else
max1=max1;
p1=p1;
end
end

p2=0;
for j=50:18:floor(n/2)
m(j)=(L(j)+L(j+18))/18;
if m(j)<m(j-18)
%min=m(i+1);
p2=(j+j+18)/2;
%if L(i)<L(i-1)&L(i)>L(i+1)
%min=L(i);
% p2=i;
break
else
%min=min;
p2=p2;
end
end

%在这个地方报错
I2=imcrop(I1,[p2 0 p1-p2 m]);

figure(2)
subplot(121);
imshow(I);
axis on
title('原图像');
subplot(122);
imshow(I2);
axis on
title('ROI图像');

%灰度归一化
originalMinValue = double(min(min(I2)));
originalMaxValue = double(max(max(I2)));
originalRange = originalMaxValue - originalMinValue;
desiredMin = 0;
desiredMax = 255;
desiredRange = desiredMax - desiredMin;
dblImageS255 = desiredRange * (double(I2) - originalMinValue) / originalRange + desiredMin;
I3=uint8(dblImageS255);
%figure(3)
%subplot(121);
%imshow(I3);
%subplot(122);
%imshow(I4);


%尺度归一化
[m n]=size(I3);
T = [double(150/n) 0 0;0 double(90/m) 0;0 0 1];
tform = maketform('affine',T);
I4 = imtransform(I3,tform,'bilinear');
%[m3 n3]=size(I4)
%直方图均衡化
%I5=histeq(I4);
%figure(8)
I5=I4;


figure(3)
subplot(221);
imshow(I2);
title('ROI区域');
subplot(222);
imshow(I3);
title('灰度归一化');
%axis on
subplot(223);
imshow(I4);
title('尺度归一化');
%axis on
subplot(224);
imshow(I5);
title('直方图均衡化');
%图像分割
%shuru=niblack(I5);
shuru = fangxiangfenge6(I5,18);
%shuru6 = Untitled(I5,10);
%[m1 n1]=size(shuru)
shuru1 = lvbo(shuru,20);
shuru1=medfilt2(shuru1,[5,5]);
shuru1 = tianchong(shuru1, 3);
shuru1 = lvbo(shuru1,200);

%细化
se3 = strel('disk', 3);
shuru2 = imdilate(shuru1, se3);
se4 = strel('disk', 2);
shuru2 = imerode(shuru2, se4);
shuru2 = bwmorph(shuru2, 'thin',Inf);
%[m2 n2]=size(shuru1)

figure(4)
subplot(221);
imshow(shuru);
title('分割图像');
%axis on
subplot(222);
imshow(shuru1);
title('处理后图像');
subplot(223);
imshow(shuru2);
title('处理后图像');


总是报错
错误使用 images.internal.imageDisplayParsePVPairs (line 125)
输入参数无效。

出错 images.internal.imageDisplayParseInputs (line 69)
[common_args,specific_args] = images.internal.imageDisplayParsePVPairs(varargin{:});

出错 imshow (line 241)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});

出错 imcrop>parseInputs (line 252)
imshow(a,cm);

出错 imcrop (line 93)
[x,y,a,cm,spatial_rect,h_image,placement_cancelled] = parseInputs(varargin{:});

出错 y (line 105)
I2=imcrop(I1,[p2 0 p1-p2 m]);

Cdma
2018-05-14, 15:30
请大神帮忙,,图片有点大是我用USB摄像头采集的,所以大神可以留下联系方式