edge detection
hi, i am searching some articles/tutorials about edge detection on image files. do you recommend any article/tut/book?
Try running a convolution filter.
There are more advanced methods, too. But these should give you a good start.
Have fun,
Pat.
(Each filter is a simple 3x3 matrix)Find vertical edges:|-1 0 1||-1 0 1||-1 0 1|Find horizontal edges:|-1 -1 -1|| 0 0 0|| 1 1 1|Find both edges (yeah, it's not correct [wink]):| 1 0 -1|| 0 0 0||-1 0 1|Sobel operator:|-1 0 1||-2 0 2||-1 0 1||-1 -2 -1|| 0 0 0|| 1 2 1|
There are more advanced methods, too. But these should give you a good start.
Have fun,
Pat.
Just found an interesting article: clicky! [smile]
[edit]
BTW. the search terms "machine vision" and "edge detection" do wonders with google[wink].
[/edit]
[edit]
BTW. the search terms "machine vision" and "edge detection" do wonders with google[wink].
[/edit]
i always use google and others... before posting but i wanted to be sure about useful ones. [wink]
thanks for document but i did not understand anything about the matrices you wrote [headshake] are they usefull for non-convex shapes? what is "convolution filter"?
thanks for document but i did not understand anything about the matrices you wrote [headshake] are they usefull for non-convex shapes? what is "convolution filter"?
Images can be filtered using such matrices. Basically you loop over the pixel values and depeding on the size of the convolution kernel (such as the matrices I wrote) combine neighboring with it using the values stores in the filter.
Each value in the filter is a factor that the corresponding neighbouring pixel value is multiplied with. The values are all summed up and the result is written back to the original pixel position.
Sounds complicated, but it really isn't. If I had Tex support on this bord, I'd write down the formula (but I guess it would only confuse you).
Example:
Below are sample pixel values:
ABCDEF
GHIJKL
MNOPQR
STUVWX
The filter is [-1 0 1] (one dimensional for simplicity).
So to get the filtered value of pixel 'B', you apply the filter like so:
B* = A * (-1) + B * 0 + C * 1
So in essence if you have a n x m filter matrix, you apply the filter to each pixel (x,y):
As you might see filter kernels should have odd sizes (f.e. 3x3, 5x5, 7x7 but not 4x4). There are problems at the image boundaries, where the filter cannot be applied correctly (e.g. 'x - n/2' will not work for x == 0). In this case there are a few options:
Here's a more formal description (along with the formulas): Clicky.
Good luck!
Pat.
Each value in the filter is a factor that the corresponding neighbouring pixel value is multiplied with. The values are all summed up and the result is written back to the original pixel position.
Sounds complicated, but it really isn't. If I had Tex support on this bord, I'd write down the formula (but I guess it would only confuse you).
Example:
Below are sample pixel values:
ABCDEF
GHIJKL
MNOPQR
STUVWX
The filter is [-1 0 1] (one dimensional for simplicity).
So to get the filtered value of pixel 'B', you apply the filter like so:
B* = A * (-1) + B * 0 + C * 1
So in essence if you have a n x m filter matrix, you apply the filter to each pixel (x,y):
// pseudo code: do this for each pixel in the imagevoid FilterPixel(int x, int y) { int filteredPixel = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { filteredPixel += image[x - n/2 + i ,y - m/2 + j] * filterKernel[i, j]; } } // optionally you can clamp the final pixel value or use a threshold or take the absolute value of it. image[x,y] = filteredPixel;}
As you might see filter kernels should have odd sizes (f.e. 3x3, 5x5, 7x7 but not 4x4). There are problems at the image boundaries, where the filter cannot be applied correctly (e.g. 'x - n/2' will not work for x == 0). In this case there are a few options:
- Plug in a constant for the missing values (e.g. '0' for simplicity[wink])
- Extend the image periodially (i.e. repeat the last values)
- Mirror at the boundaries → mirror the available pixel values at the pixel center (in the above example filtering pixel 'A' by [-1 0 1] results in filtering 'BAB' o [-1 0 1])
- Repeat the last available data as often as necessary (in the above example this would result in 'AAB' o [-1 0 1])
Here's a more formal description (along with the formulas): Clicky.
Good luck!
Pat.
There are definitely some VERY good algorithms out there for edge detection. I can't remeber the name of the book, but I've seen an example in a digital imaging processing book that showed how both edge detection and line extension could be used to extract the license plate numbers off a blurry picture of a van (it also correctly extract the bounds of the windows, the seam on the split back door and the general shape of the vehicle and bumper =-)
Definitely some amazing algorithms out there
Definitely some amazing algorithms out there
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement