straighten the jagged boundary and how to count lenght of boundary.

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 :

1 件のコメント

Ryan
Ryan 2012 年 6 月 17 日
You have had more than enough help and examples given to you by this point that you should be able to figure out this out. Just find the perimeter, locate the corners and then calculate the distance between the corners.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2012 年 6 月 17 日

0 投票

I'm not sure I understand why you don't have this yet. I gave you a snippet of code that uses imtransform() to warp an image to make it rectangular. All you had to do was to find the corners, and I think I gave you hints for that.
For that matter, I'm not even sure why you need to do this at all when the problem could be completely avoided by having your camera directly overhead from your tile and a jig to ensure precise positioning of tile samples in the field of view. Why go through all this bother when you don't have to?
As far as the jaggies go, don't worry about them. You don't need to "straighten them out" - you just don't. Why do you think you do?
You could use regionprops() on the transformed image and calculate the length of the perimeter that way, or use bwboundaries() and use the Pythagorean theorem. I think the outer perimeter length would only vary if the tile were chipped or broken.

10 件のコメント

KURNIAWAN
KURNIAWAN 2012 年 6 月 17 日
yeah,, thanks before image analyst, ur code about imtransform to warp an image,, but how to plot that code automaticly the corner of tile,,, because in my experiment will use interface later, so need automatic without tag the corner one by one, can u give code m-file how tag automaticallly the corner of tile and directly know the cordinate of edge corner..
i use this code ( to count the lenght of edge,, but the line of edge still jaggies , i think its not accurately in value of lenght edge with jagges line,,
_________________________________________
[B,L] = bwboundaries(bw,'holes');
% Display the label matrix and draw each boundary
imshow(label2rgb(L, @jet, [.1 .1 .1]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
end
%deklarasi variable
stats = regionprops(L,'Area','Perimeter', 'MajorAxisLength' )
jml_panjang = 0
panjang_terpanjang = 0
panjang_terpendek = 0
%Perhitungan
for k = 1:length(B)
boundary = B{k};
delta_sq = diff(boundary).^2;
perimeter =sum(sqrt(sum(delta_sq,2)));
area = stats(k).Area;
metric = 4*pi*area/perimeter^2;
if metric < 0.75 && area >300
panjang = stats(k).MajorAxisLength;
text(boundary(1,2)-35, boundary(1,1)+35, sprintf('%2.2f', panjang),'Color','y', 'Fontsize',12, 'FontWeight','bold');
jml_panjang = jml_panjang
if panjang_terpanjang < panjang
panjang_terpanjang = panjang
end
if panjang_terpendek <= 0
panjang_terpendek = panjang
end
if panjang_terpendek > panjang
panjang_terpendek = panjang
end
end
end
_________________________________________________
and the result picture still have jaggies on edge, i think count the lenght not acurrately,, my picture after bwboundaries become this : <http://tinypic.com/view.php?pic=15chlpk&s=6>
please help me,,
Image Analyst
Image Analyst 2012 年 6 月 17 日
That's why it's called DIGITAL image analysis. That happens everywhere in the computer world because that's what happens if you quantize/digitize data. If you don't want to sum the length of the pixels in the line, then just find the endpoint locations and use the Pythagorean theorem.
KURNIAWAN
KURNIAWAN 2012 年 6 月 18 日
yah ,, the point one that i dont know,, how to find coordinat pixel ofcorner tile automatically ,, can u help me in code m-file please
Walter Roberson
Walter Roberson 2012 年 6 月 18 日
http://www.mathworks.com/help/toolbox/vision/ref/cornerdetection.html
http://www.mathworks.com/matlabcentral/fileexchange/7652
KURNIAWAN
KURNIAWAN 2012 年 6 月 18 日
thanks walter roberson,, but im still confuse,, after we detect the corner and next how to know the location pixel of corner,, thats fileexchange that u gave before about detect the timing to detect corner,, but i need detect the corner and fine coordinate of corner,, can u help me
Walter Roberson
Walter Roberson 2012 年 6 月 18 日
The source code for #7652 is in a .rar file, so I cannot look at it. I see nothing in the documentation that would suggest that "timing" is being examined.
Image Analyst
Image Analyst 2012 年 6 月 18 日
Maybe you could try the corner() function in the Image Processing Toolbox.
Walter Roberson
Walter Roberson 2012 年 6 月 18 日
Ah, that function is newer than the release I normally run.
KURNIAWAN
KURNIAWAN 2012 年 6 月 19 日
hemm??? im confuse,, pls help
Walter Roberson
Walter Roberson 2012 年 6 月 19 日
At the MATLAB command prompt, command
help corner
If it gives you help information then you can use that corner-finding routine to find the corners in your image.

サインインしてコメントする。

質問済み:

2012 年 6 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by