morphological operations in matlab

I am having an image uploaded at: http://tinypic.com/view.php?pic=1h2n8g&s=6 After doing some processing on it I found the following results uploaded at: http://tinypic.com/view.php?pic=1jqffa&s=6 and http://tinypic.com/view.php?pic=2l6sk1&s=6
The code used for processing is:
img = imread('newroad1.jpg');
hsv = rgb2hsv(img);
I1 = hsv(:,:,3);
figure,imshow(I1)
se = strel('square',5);
mgrad = imdilate(I1, se) - imerode(I1, se);
figure,imshow(mgrad)
I=im2bw(mgrad,0.1);
What morphological operations should I use so that I can get the above mentioned results.

 採用された回答

Image Analyst
Image Analyst 2013 年 2 月 18 日

0 投票

Those would be the 'skel' and 'spur' options of bwmorph().

9 件のコメント

azan
azan 2013 年 2 月 18 日
編集済み: azan 2013 年 2 月 18 日
I have used these commands. By using the 'skel' command I get the result uploaded at: http://tinypic.com/view.php?pic=359iwes&s=6 and by using the 'spur' command I get the result uploaded at: http://tinypic.com/view.php?pic=359iwes&s=6 These are not the exact results which I require. I want the white lanes to be extracted at the end http://tinypic.com/view.php?pic=14dga2s&s=6 along with the correct results.
Image Analyst
Image Analyst 2013 年 2 月 18 日
That is not a skeleton. Evidently you did not use the "inf" option with the skel.
azan
azan 2013 年 2 月 18 日
By using this I got the result http://tinypic.com/view.php?pic=nq2pvc&s=6
Image Analyst
Image Analyst 2013 年 2 月 18 日
OK, you're getting there. You just need to zero out the edges of the top image and the bottom image because they are giving spurious edges.
skelImage(row1:row2, col1:col2) = 0;
azan
azan 2013 年 2 月 18 日
編集済み: azan 2013 年 2 月 18 日
I have done like this:
img = imread('road1.jpg');
hsv = rgb2hsv(img);
I1 = hsv(:,:,3);
se = strel('square',5);
mgrad = imdilate(I1, se) - imerode(I1, se);
I=im2bw(mgrad,0.1);
BW1=bwmorph(I,'skel',inf);
BW1(1:2,1:2) = 0;
figure,imshow(BW1)
BW2=bwmorph(BW1,'spur');
figure,imshow(BW2)
Same procedure is done for second image.But there is no significant change in result. Guide me
Image Analyst
Image Analyst 2013 年 2 月 18 日
What are you thinking when you do this:
BW1(1:2,1:2) = 0;
??? Are you thinking that erasing the upper left corner (a 2 by 2 patch) is going to erase the edges of the images - those lines that you do not want? Those lines exist way outside the 1:2,1:2 upper left box! After you use imshow(), call "axis on" to see what rows and columns you need to zero out. You need to zero out all of lines 150, 200, and 250 (or something like that) and all of column 800 (or something around there).
BW1(148:152,:) = false; % use the actual numbers.
BW1(:, 798:802) = false; % use the actual numbers.
azan
azan 2013 年 2 月 18 日
ok Sir now I got it..I am having images so I can fix the dimensions to erase edges. What if I am having a video. How to achieve the same result for the video.
Image Analyst
Image Analyst 2013 年 2 月 18 日
Just do it a frame at a time. Of course there are fancier ways involving time projection where you predict positions based on past frames but that's a lot more advanced. Just start with a frame at a time.
azan
azan 2013 年 2 月 18 日
ok sir I will try it and then will let you know if I will be having some problem.

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

その他の回答 (0 件)

製品

Community Treasure Hunt

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

Start Hunting!

Translated by