【发布时间】:2014-10-29 09:33:54
【问题描述】:
我试图根据颜色强度从地图中提取道路,但我无法清楚地划分道路,因为某些建筑物的强度与某些道路相同。现在我正试图移除那些建筑物。为此,我尝试在对象中使用“最大内接圆”的概念,因为建筑物中的内接圆将大于道路。但是,到目前为止,我的尝试无法做到这一点。这是我写的代码。
clc
clear all
x=imread('http://i.imgur.com/R80JmEH.jpg?1');
x1=rgb2gray(x);
imshow(x1)
x1(x1<240)=0;
T=graythresh(x1);
y=im2bw(x1,T);
figure;imshow(y)
y1= imfill(y,'holes');
figure; imshow(y1)
BW2 = bwareaopen(y1,10);
figure;imshow(BW2);
s = regionprops(BW2, x1, {'Centroid','WeightedCentroid'});
figure;imshow(BW2)
title('Weighted (red) and Unweighted (blue) Centroid Locations');
hold on
numObj = numel(s);
for k = 1 : numObj
plot(s(k).WeightedCentroid(1), s(k).WeightedCentroid(2), 'r*');
plot(s(k).Centroid(1), s(k).Centroid(2), 'bo');
end
hold off
原图:
应删除的红色圆圈区域:
【问题讨论】:
-
为什么要删除部分问题?您应该保留它原来的样子,以便人们将来可以参考它。