Edge detection for color images

Hi, I am need to count the number of edges of the color image.
How i can do it??

Answers (1)

Image Analyst
Image Analyst on 17 Dec 2011
Assuming you have the edges already, bwlabel will count them for you. If you don't have the edges already then you need to do some research about how to find edges as there are lots of ways to do it with color images. For example, maybe you just want to convert to gray and use a regular grayscale edge detector.

7 Comments

Thank you.
Yes I have edges
, but when I implement the code shows me this error:
??? Error using ==> iptcheckinput
Function BWLABEL expected its first input, BW, to be two-dimensional.
Error in ==> bwlabel at 67
iptcheckinput(BW, {'logical' 'numeric'}, {'real', '2d', 'nonsparse'}, ...
Why is your input image BW not a 2D logical image? It should be. How did you get it?
This is my code:
image=imread('img.jpg');
image=rgb2gray(image);
BW=edge(image,'canny');
L = bwlabel(BW, 8);
There is no error now
Is the largest element in L is the number of edges ?
Yes, but you don't need to do max(L(:)) to get it, you can get it directly via:
[labeledImage numberOfEdges] = bwlabel(BW);
Great.
Thank you very much.
If I want to compare two images based on the number of edges
What is the criteria that must be relied upon to do so.
I don't understand. You gave the criteria: the number of edges. If that's what you want, you simply get the number of edges for each image. I don't know what "compare" means. Maybe you can just see which one has more so your final answer is simply "image A" or "image B". Maybe you just want to log the edge count of each image into a spreadsheet, or maybe have a bar chart to compare them graphically. Maybe the number of edges is a measure of texture an you're trying to find out which process gives a rougher texture. I have no idea what you're doing or how you want to compare images.
Well, the issue has become clear to me
Thank you again.

Sign in to comment.

Products

Tags

No tags entered yet.

Asked:

on 17 Dec 2011

Community Treasure Hunt

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

Start Hunting!