how solve this problem - Edge detection, straighten the line detection, and counting the line of edge image

6 visualizzazioni (ultimi 30 giorni)
I want to find the edge of a line image, but If i detect with canny and sobel, thats not suitable, not straight but the problem is the line still irregular lines,,, I NEED M-FILE CODING : How to straighten out the jagged lines on the edges and calculate the length of the edge :

Risposte (2)

Walter Roberson
Walter Roberson il 14 Giu 2012
  • Start by doing corner detection
  • Calculate the difference in slopes between the top and bottom edges (by using the coordinates of the corners), and also calculate the difference in slopes between the right and left edges. Choose the line pair with the least difference in slope and use that line pair as your reference pair.
  • You could rotate the image so that one of the two lines of the reference pair is along the y-axis, with the other of the reference pair forming the top and ideally the top would then be parallel to the bottom. You do not actually need to do the rotation though, as you can proceed analytically just based upon coordinates
  • Once you have a logical bottom line and top line, by looking at the difference in projected x coordinates of the "top" corners vs the "bottom" corners, you can easily calculate the length of the small side of the triangles. By looking at the difference in projected y coordinates of the "top" line vs the bottom line, you can easily calculate the length of the larger side of the triangles.
  • Now do some trivial geometry to calculate the length of the two hypotenuse.
  • None of this requires that you do any light equalization or any image rotation or any cropping: all it requires is that you can do corner detection and a small amount of geometry, and requires that the sides be a sufficiently close approximation of straight for simple geometry to be accurate enough.
  • The above also assumes that there is no "preferred" direction for the tile; if there is the equivalent of a "grain" that must be detected and is preferred to run either top to bottom or side to side, then you would need additional work to do that detection.

KURNIAWAN
KURNIAWAN il 14 Giu 2012
rgbImage = imread('IMG2cp.jpg');
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);
% Extract the individual red, green, and blue color channels.
% redChannel = rgbImage(:, :, 1);
% greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
imshow(blueChannel, []);
% Threshold blue channel
binaryImage = blueChannel < 193;
% Get rid of small blobs.
binaryImage = bwareaopen(binaryImage, 10000);
% Fill in any holes in the tile.
binaryImage = imfill(binaryImage, 'holes');
% Display it.
figure, imshow(binaryImage, []);
what next ?? im confuse

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by