Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
edge detection with coordinates of edge points

Subject: edge detection with coordinates of edge points

From: Toan Cao

Date: 16 Oct, 2010 02:54:04

Message: 1 of 5

hi, everybody!
I have a gray image with the horizontal and vertical lines, i would like to detect the edge of these lines. Moreover, i also want to know the coordinate of each point on each edge after edge detection process complete!
Is there any function or method to accomplish my purpose ?
Looking forward to your reply .
Thank you very much !

Subject: edge detection with coordinates of edge points

From: balanmurugan thurmalingam

Date: 22 Oct, 2010 17:18:04

Message: 2 of 5

i also searching for same question..if u got any code reply me...tq...u cn try this code i got from matlab tutor...
% Demo macro to find books
% NOT FINISHED.....
% by ImageAnalyst
clc;
clear;
close all;
workspace;
fontSize = 20;

% Change the current folder to the folder of this m-file.
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
% Read in books image.
folder = 'C:\Documents and Settings\user\My Documents\downloads';
baseFileName = 'books.jpg';
fullFileName = fullfile(folder, baseFileName);
rgbImage = imread(fullFileName);
% Display the original color image.
subplot(2, 2, 1);
imshow(rgbImage);
title('Original Color Image', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full
screen.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
grayImage = rgb2gray(rgbImage);

% Do a Canny edge detection on the image.
BW = edge(grayImage,'canny');
subplot(2, 2, 2);
imshow(BW, []);
title('Edge Image', 'FontSize', fontSize);

[H,T,R] = hough(BW);
subplot(2, 2, 3);
imshow(H,[],'XData',T,'YData',R,...
            'InitialMagnification','fit');
title('Hough Image', 'FontSize', fontSize);
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
P = houghpeaks(H,10,'threshold',ceil(0.3*max(H(:))));
x = T(P(:,2));
y = R(P(:,1));
plot(x,y,'s','color','white');

% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',25,'MinLength',7);
% Put code in here to toss out horizontal lines.

% Display original image with lines over it.
subplot(2, 2, 4);
imshow(rgbImage);
title('Original Color Image with Lines', 'FontSize', fontSize);
hold on;
max_len = 0;
for k = 1:length(lines)
   xy = [lines(k).point1; lines(k).point2];
   plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');

   % Plot beginnings and ends of lines
   plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
   plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');

   % Determine the endpoints of the longest line segment
   len = norm(lines(k).point1 - lines(k).point2);
   if ( len > max_len)
      max_len = len;
      xy_long = xy;
   end
end

Subject: edge detection with coordinates of edge points

From: Sean

Date: 22 Oct, 2010 17:32:06

Message: 3 of 5

"Toan Cao" <toancv3010@gmail.com> wrote in message <i9b44c$b3j$1@fred.mathworks.com>...
> hi, everybody!
> I have a gray image with the horizontal and vertical lines, i would like to detect the edge of these lines. Moreover, i also want to know the coordinate of each point on each edge after edge detection process complete!
> Is there any function or method to accomplish my purpose ?
> Looking forward to your reply .
> Thank you very much !

help edge
help bwperim %if you can convert to binary

Subject: edge detection with coordinates of edge points

From: Pauline Addis

Date: 1 Nov, 2010 15:13:04

Message: 4 of 5

"Toan Cao" <toancv3010@gmail.com> wrote in message <i9b44c$b3j$1@fred.mathworks.com>...
> hi, everybody!
> I have a gray image with the horizontal and vertical lines, i would like to detect the edge of these lines. Moreover, i also want to know the coordinate of each point on each edge after edge detection process complete!
> Is there any function or method to accomplish my purpose ?
> Looking forward to your reply .
> Thank you very much !

Hi,

I have just managed fairly good results by first of all using the Canny edge detection method, then using bwboundaries to report back the location of the co-ordinates. search Matlab help for bwboundaries. Hope that helps.

Subject: edge detection with coordinates of edge points

From: nguyen phuong

Date: 19 Dec, 2011 04:12:08

Message: 5 of 5

hi

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us