我目前正在与MATLAB合作,从空中/卫星图像中检测道路/公路。我已经为这一概念编写了代码,我的概念是基于道路及其周围环境的强度差异。但效率并不是很高,因为它也是检测非道路实体。除此之外,我还将在这些道路上检测车辆,然后尝试计算道路的宽度。你能帮我改进我目前的方法吗?或者建议一个新的方法?
谢谢!)
我已经附上了我的MATLAB代码,以供审查。
clc
clear all
close all
a=rgb2gray(imread('freeway24.tif'));
a2=mean(a);
t=min(a2);
b=lt(a,t);
[row_b, column_b]=size(b);
for i=1:row_b
for j=1:column_b
if b(i,j)~=1
b(i,j)=0;
else
b(i,j)=255;
end
end
end
bw0=bwareaopen(b,50);
bw1=bwmorph(bw0,'clean');
bw2=bwmorph(bw1,'majority');
bw3=bwmorph(bw2,'fill');
bw4=imfill(bw3,'holes');
[row_final,column_final]=size(bw4);
bw_final=zeros();
for i=1:row_final
for j=1:column_final
if bw4(i,j)==1
bw_final(i,j)=a(i,j);
else
bw_final(i,j)=0;
end
end
end
subplot(1,2,1);
imshow(a);
title('Original Image');
subplot(1,2,2);
imshow(bw_final);
title('After detection');注:由于我没有10个声誉点,我无法张贴输入图像。我已经上传了链接到这里的图片。https://drive.google.com/open?id=0B0MIQKh4Irk8MVlXYnhIcmpxTG8
发布于 2016-05-12 15:08:09
我建议你更多地研究计算机视觉,特别是这些matlab函数:不紧密、不腐蚀、不膨胀和开式。下面是帮助您的代码。您只需在最后一次演示之前添加它。
% Calculate disk of radius 2 pixels, 4 pixels diameter
se = strel('disk', 2);
% Connect the white pixels that are less than 4 pixels apart
bw_final = imclose(bw_final, se);
% Connect the black pixels that are less than 4 pixels apart
bw_final = ~imclose(~bw_final, se);
% Calculate 2% of the image pixels
num2Percent = round(numel(bw_final)/50);
% Remove white area smaller than 2%
bw_final = bwareaopen(bw_final, num2Percent);
% Remove black area smaller than 2%
bw_final = ~bwareaopen(~bw_final, num2Percent);https://stackoverflow.com/questions/37190317
复制相似问题