Prev: freqz /freqs: Calling a bespoke filter function on them.
Next: What is the difference 2^-1024 and 1/(2^1024) in ieee- double precision format
From: tara woo on 26 Jan 2010 00:21 I have taken a picture of a laser line and three laser points. The laser line is folded, that is, it has two slopes. The background is quite noisy as there are some reflections of the laser lines and some short discrete laser lines that I don't want. I want to find out the value of the two slopes, but where the line folds is not my concern. Actually I want to know the angle between the two lines[that is, "how much" does the line folds]. I guess we have to find the slope of the two lines first? or is there any simplier methods? Moreover, I would like to locate the position of the laser points in the image. Thank you very much!! This is the photo I want to analyze [you can't see the laser points yet]: http://www.flickr.com/photos/14362116(a)N06/4305181607/in/photostream/ And I've added arrows pointing the two lines that I want to know and also the angle. http://www.flickr.com/photos/14362116(a)N06/4305192457/in/photostream/
From: kinor on 26 Jan 2010 03:29 "tara woo" <yamiaomiaohoo(a)yahoo.com.hk> wrote in message <hjlu3u$d5v$1(a)fred.mathworks.com>... > I have taken a picture of a laser line and three laser points. The laser line is folded, that is, it has two slopes. > > The background is quite noisy as there are some reflections of the laser lines and some short discrete laser lines that I don't want. I want to find out the value of the two slopes, but where the line folds is not my concern. Actually I want to know the angle between the two lines[that is, "how much" does the line folds]. I guess we have to find the slope of the two lines first? or is there any simplier methods? > > Moreover, I would like to locate the position of the laser points in the image. > > Thank you very much!! > > This is the photo I want to analyze [you can't see the laser points yet]: > http://www.flickr.com/photos/14362116(a)N06/4305181607/in/photostream/ > > And I've added arrows pointing the two lines that I want to know and also the angle. > http://www.flickr.com/photos/14362116(a)N06/4305192457/in/photostream/ Hi, have a look at help ->Demos ->Toolboxes -> image Processing -> Measuring Image Features -> Measuring Angle of Intersection hth kinor
From: Ashish Uthama on 26 Jan 2010 09:33 On Tue, 26 Jan 2010 00:21:03 -0500, tara woo <yamiaomiaohoo(a)yahoo.com.hk> wrote: > I have taken a picture of a laser line and three laser points. The laser > line is folded, that is, it has two slopes. > > The background is quite noisy as there are some reflections of the laser > lines and some short discrete laser lines that I don't want. I want to > find out the value of the two slopes, but where the line folds is not my > concern. Actually I want to know the angle between the two lines[that > is, "how much" does the line folds]. I guess we have to find the slope > of the two lines first? or is there any simplier methods? > > Moreover, I would like to locate the position of the laser points in the > image. > > Thank you very much!! > > This is the photo I want to analyze [you can't see the laser points yet]: > http://www.flickr.com/photos/14362116(a)N06/4305181607/in/photostream/ > > And I've added arrows pointing the two lines that I want to know and > also the angle. > http://www.flickr.com/photos/14362116(a)N06/4305192457/in/photostream/ You can segment out the laser 'lines' and detect 2D angles (see code below). However, I assume you are interested in the angle between the two planes of the bench rather than the laser lines themselves. I cant think of an easy way to do this. You could think of using, say the real world ratio of the width of the two planes of the bench and 3D geometry to deduce this. For the 2D case, look at the toy code below. Please read up the doc for the functions uses and adapt/generalize it to suit your needs. imdata=imread('laser.jpg'); %Use imtool to determine the required threshold to identify the laser. %mouse over the laser light, the red component is generally >150. %imtool(imdata); %threshold only the red layer to get a black/white image imdata=imdata(:,:,1)>150; figure;imshow(imdata); %'Skeletonize' the image. imdata=bwmorph(imdata,'skel', inf); figure;imshow(imdata); %help hough [H,T,R] = hough(imdata); %Given image has about 4 lines of interest P = houghpeaks(H,4,'Threshold',.3*max(H(:))); % Find the actual lines lines = houghlines(imdata,T,R,P,'FillGap',50,'MinLength',50); lines.theta %% display figure, imshow(imdata), hold on max_len = 0; for k = 1:length(lines) xy = [lines(k).point1; lines(k).point2]; plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green'); % Plot beginnings and ends of lines plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow'); plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red'); % Determine the endpoints of the longest line segment len = norm(lines(k).point1 - lines(k).point2); if ( len > max_len) max_len = len; xy_long = xy; end end % highlight the longest line segment plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','blue');
From: tara woo on 28 Jan 2010 07:35 Thank you very much!! Indeed, I am interested in the angle of the bench rather than the laser, but actually, the bench is an imitation of a hill slope. Could you tell me more about the method you mentioned? I am really interested!! Moreover, can anybody help me on finding the location of the red laser dots? Many thanks!!! and sorry for asking stupid questions, I'm quite new to matlab... Here's a photo with red dots: http://www.flickr.com/photos/14362116(a)N06/4310758165/ "Ashish Uthama" <first.last(a)mathworks.com> wrote in message <op.u649euhua5ziv5(a)uthamaa.dhcp.mathworks.com>... > On Tue, 26 Jan 2010 00:21:03 -0500, tara woo <yamiaomiaohoo(a)yahoo.com.hk> > wrote: > > > I have taken a picture of a laser line and three laser points. The laser > > line is folded, that is, it has two slopes. > > > > The background is quite noisy as there are some reflections of the laser > > lines and some short discrete laser lines that I don't want. I want to > > find out the value of the two slopes, but where the line folds is not my > > concern. Actually I want to know the angle between the two lines[that > > is, "how much" does the line folds]. I guess we have to find the slope > > of the two lines first? or is there any simplier methods? > > > > Moreover, I would like to locate the position of the laser points in the > > image. > > > > Thank you very much!! > > > > This is the photo I want to analyze [you can't see the laser points yet]: > > http://www.flickr.com/photos/14362116(a)N06/4305181607/in/photostream/ > > > > And I've added arrows pointing the two lines that I want to know and > > also the angle. > > http://www.flickr.com/photos/14362116(a)N06/4305192457/in/photostream/ > > > You can segment out the laser 'lines' and detect 2D angles (see code > below). > However, I assume you are interested in the angle between the two planes > of the bench rather than the laser lines themselves. I cant think of an > easy way to do this. You could think of using, say the real world ratio of > the width of the two planes of the bench and 3D geometry to deduce this. > > > For the 2D case, look at the toy code below. > Please read up the doc for the functions uses and adapt/generalize it to > suit your needs. > > > imdata=imread('laser.jpg'); > > %Use imtool to determine the required threshold to identify the laser. > %mouse over the laser light, the red component is generally >150. > %imtool(imdata); > > %threshold only the red layer to get a black/white image > imdata=imdata(:,:,1)>150; > figure;imshow(imdata); > > %'Skeletonize' the image. > imdata=bwmorph(imdata,'skel', inf); > figure;imshow(imdata); > > %help hough > [H,T,R] = hough(imdata); > %Given image has about 4 lines of interest > P = houghpeaks(H,4,'Threshold',.3*max(H(:))); > % Find the actual lines > lines = houghlines(imdata,T,R,P,'FillGap',50,'MinLength',50); > lines.theta > > %% display > figure, imshow(imdata), hold on > max_len = 0; > for k = 1:length(lines) > xy = [lines(k).point1; lines(k).point2]; > plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green'); > > % Plot beginnings and ends of lines > plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow'); > plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red'); > > % Determine the endpoints of the longest line segment > len = norm(lines(k).point1 - lines(k).point2); > if ( len > max_len) > max_len = len; > xy_long = xy; > end > end > > % highlight the longest line segment > plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','blue');
From: ImageAnalyst on 28 Jan 2010 08:11
Finding the red dots is very easy. Just adapt this demo where I find red objects in an image: http://www.mathworks.com/matlabcentral/fileexchange/26420-simplecolordetection Once you've found the red objects, you'll have to examine their properties (for example area or perimeter) to keep just those that are the dots and throw away those that are the red lines. Post your code back here if you have problems. |