1.matlab函数文件中的源码工程调度源码错误
2.如何用MATLAB实现一段视频中的车流量统计
3.Matlabä¸å¦ä½å®ç°ç°åº¦è¨èåç°åº¦è
èï¼
matlab函数文件中的错误
照这个用
function img = edu_imgpreprocess(I) %图像预处理
Igray = rgb2gray(I); %转化成灰色图像
Ibw = im2bw(Igray,graythresh(Igray));%转化成二值 graythresh返回图像的阈值和阈值的有效性
Iedge = edge(uint8(Ibw));
se = strel('square',3);
Iedge2 = imdilate(Iedge, se);
Ifill= imfill(Iedge2,'holes');
[Ilabel num] = bwlabel(Ifill);
Iprops = regionprops(Ilabel);
Ibox = [Iprops.BoundingBox];
Ibox = reshape(Ibox,[4 ]);
Ic = [Iprops.Centroid];
Ic = reshape(Ic,[2 ]);
Ic = Ic';
Ic(:,3) = (mean(Ic.^2,2)).^(1/2);
Ic(:,4) = 1:;
% Extra lines compare to example2 to extract all the components into an
% cell array
Ic2 = sortrows(Ic,2);
for cnt = 1:5
Ic2((cnt-1)*+1:cnt*,:) = sortrows(Ic2((cnt-1)*+1:cnt*,:),4);
end
Ic3 = Ic2(:,1:2);
ind = Ic2(:,4);
for cnt = 1:
img{ cnt} = imcrop(Ibw,Ibox(:,ind(cnt)));
end
如何用MATLAB实现一段视频中的车流量统计
mov1=mmreader('.mpg');
mov=read(mov1,[1, ]);
temp=size(mov);
fnum=temp(2);
for i=1:fnum
strtemp=strcat(int2str(i),'.','JPG');
imwrite(mov(i).cdata(:,:,:),strtemp);
end%% 从视频中提出每一帧图像
o=1;
e='.jpg';
for i=1:
u=o-1;v=o-2;
m=int2str(o);
n=int2str(u);h=int2str(v);
s=strcat(m,e);%%把字符串b与m连接后在连接e得到图像文件存储的位置
m=imread(s);%%从S处把图像读取出来
m=rgb2gray(m);%%将图像M灰度化
m=medfilt2(m,[3,3]);
if(o>=3)
s=strcat(n,e);
n=imread(s);
n=rgb2gray(n);
s=strcat(h,e);
h=imread(s);
h=rgb2gray(h);
n=medfilt2(n,[3,3]);
h=medfilt2(h,[3,3]);
q=im2double(m);%%将图像数组转换为double型
w=im2double(n); g=im2double(h);
c=q-w;j=w-g;
th=/;
k= abs(c)>=th;
c(k)=1;
k=find(abs(c)<th);
c(k)=0;
c=bwareaopen(c,);
se=strel ('line',3,);se0=strel ('line',3,0);
c=bwmorph(c,'close'); %对上述图像进行形态学闭运算
c=imdilate(c,[se,se0]);c=bwmorph(c,'close');
c=bwareaopen(c,);
k=find(abs(j)>=th);
j(k)=1;
k=find(abs(j)<th);
j(k)=0;
j=bwareaopen(j,);
j=bwmorph(j,'close'); %对上述图像进行形态学闭运算
j=imdilate(j,[se,se0]);j=bwmorph(j,'close');
c=bwareaopen(c,);
c=c&j;c=imerode(c,[se,se0]);
figure,imshow(c);
a=c;b=c; d=c;f=c;
[m,n]=size(c);
%%行扫描填充
for i=1:m
for j=1:n-1
if a(i,j)>0
a(i,j+1)=1;
end
end
end
for i=1:m
for j=n:-1:2
if b(i,j)>0
b(i,j-1)=1;
end
end
end
th=a&b;
%%列扫描填充
for i=1:n
for j=1:m-1
if d(j,i)>0
d(j+1,i)=1;
end
end
end
for i=1:n
for j=m:-1:2
if f(j,i)>0
f(j-1,i)=1;
end
end
end
td=d&f;
c=th&td;
end
o=o+1;
end
Matlabä¸å¦ä½å®ç°ç°åº¦è¨èåç°åº¦è èï¼
1ãéåå½æ°ä¸ºf(x)=-|x-6|+5å¨[1,]ä¸çå¾åï¼ç»åºå½æ°å¾åã2ã使ç¨strelæ建平å¦çç»æå ç´ ï¼å¦å¾ã
3ã使ç¨å¹³å¦çç»æå ç´ è¿è¡ç°åº¦è¨èï¼è®¾ç½®yè½´èå´ä¸º[0, 8]å¦å¾ã
4ãæ建é«åº¦ä¸º[1 1 1]çéå¹³å¦ç»æå ç´ ãæ¾ç¤ºçç»æåå¹³å¦å ç´ ç¸åï¼ä½å®é ç»æä¸åã
5ã使ç¨éå¹³å¦çç»æå ç´ è¿è¡ç°åº¦è¨èï¼å¹¶ç»å¾å³å¯ã
2024-11-28 09:00
2024-11-28 08:53
2024-11-28 08:08
2024-11-28 07:58
2024-11-28 07:47
2024-11-28 07:09