Boundary tracing in image

조회 수: 3 (최근 30일)
Anna Marshall
Anna Marshall 2020년 5월 3일
댓글: Anna Marshall 2020년 5월 3일
Hello folks,
I am trying to trace the boundaries of a binary edge detected image to the point that I can export the file as polylines into ArcGIS. So far, I have converted the image to a binary image and identified the edges. I've tried to use both bwtraceboundary and bwboundaries to identify the edge outlines and then export this file with polylines, but am not having any luck. The original image is attached as is the code to convert the image to a binary edge-detected image. Any help is much appreciated!
clear
RGB=imread('DJI_0022.jpg'); %inputs image
I=rgb2gray(RGB); %convers to grayscale
figure
imshow(I)
BW1 = edge(I,'Canny',0.6);
imshow(BW1)

채택된 답변

Image Analyst
Image Analyst 2020년 5월 3일
After Canny, those blobs are single pixel wide blobs, so it makes no sense to call bwboundaries() on them. That would just simply give you the same coordinates you already have, any maybe even doubled up as it goes to one end and back again. I think you want to use regionprops and ask for PixelList.
rgbImage = imread('DJI_0022.jpg'); %inputs image
hFig = figure;
subplot(2, 2, 1);
imshow(rgbImage)
axis('on', 'image');
impixelinfo;
title('Original RGB Image', 'FontSize', 20);
grayImage = rgb2gray(rgbImage); %convers to grayscale
subplot(2, 2, 2);
imshow(grayImage)
axis('on', 'image');
impixelinfo;
title('Gray Scale Image', 'FontSize', 20);
edgeImage = edge(grayImage, 'Canny', 0.6);
subplot(2, 2, 3);
imshow(edgeImage)
axis('on', 'image');
title('Canny Edge Image', 'FontSize', 20);
hFig.WindowState = 'maximized';
drawnow;
% Get coordinates.
props = regionprops(edgeImage, 'PixelList');
for k = 1 : length(props)
thisList = props(k).PixelList;
fprintf('\nFor blob #%d of %d:\n ', k, length(props))
for k2 = 1 : size(thisList, 1)
thisx = thisList(k2, 1);
thisy = thisList(k2, 2);
fprintf('(%d, %d), ', thisx, thisy);
end
end
  댓글 수: 2
Image Analyst
Image Analyst 2020년 5월 3일
Sorry, I don't know or use GIS. You'd have to check out the format required and use fprintf() or fwrite() to create the file in the required format.
Anna Marshall
Anna Marshall 2020년 5월 3일
Thanks again!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by