Reputation: 12715
I'm looking for the algorithm (C#) or some info about how detect the edge of some object on the image (the target is the melanoma). I've found the AForge.NET
library but I need to detect an edge without losing the image color
. The examples below were prepared using the Paint.NET
Before:
after
I need only that blue edge (the color inside doesn't matter) or the that blue pixels coordinates
Matthew Chambers was right, converting the image to the grayscale improves the effectiveness of the algorithm. The first result image is based on the original coloured image, and the second one is based on the grayscaled image. The blue pixels corresponds to the HSV's Value < 30. You can see the differences by yourself. Thanks m8 !
Upvotes: 1
Views: 2387
Reputation: 20915
Considering the images and the question, it does not look like you need edge detection.
I would use an adaptive threshold technique instead, find the blob and finally extract the edge from it.
Here is a code in Matlab to illustrate what I mean:
function FindThresh()
i = imread('c:\b.png');
figure;imshow(i);
graythresh(i)
th = graythresh(i(:,:,2))*255;
figure;imshow(i(:,:,2)>th)
i1 = imclose(i(:,:,2)>th,strel('diamond',3));
figure;imshow(i1)
e = edge(i1);
indexes = find(e);
[r,c]=ind2sub(size(i1),indexes)
figure;imshow(e)
figure;imshow(i);hold on; scatter(c,r);
end
and the intermediate results images:
You can see that it is not perfect, but by improving it a little bit, you will get more powerful results than by using edge detection which is not a stable operation.
Upvotes: 1
Reputation: 818
You could convert to Lab color space, split channels, run edge detection code (like the one provided in other answer) on L channel only, then add back a and b channels.
Upvotes: 1
Reputation: 76
You need to consider a few points related to the problem you are trying to solve.
What is an edge in a picture? Generally it is when the colour changes at a high rate. I.e. from dark to light in a short space.
But this has an issue about what a high rate of change for a colour actually is. For example, the Red and Green values could stay the same, while the Blue value changes at a high rate. Would we count this as an edge? This could occur for any combination of the RGB values.
For this reason, images are typically converted to greyscale for edge detection - otherwise you could get different edge results for each RGB value.
For this reason, the simplest approach would be to use a typical edge detection algorithm that works on a greyscale image, and then overlay the result onto the original image.
Upvotes: 3
Reputation: 32468
How about using the Edges
class:
// create filter
Edges filter = new Edges();
// apply the filter
var newImage = filter.Apply(orignalImage);
Then do a threshold on newImages, finally overlay newImage
on top of originalImage
.
Upvotes: 1