20060221-Tracing George
来源:互联网 发布:手机棋牌麻将软件 编辑:程序博客网 时间:2024/06/14 07:48
原文:http://blogs.mathworks.com/steve/2006/02/21/tracing-george/
url = 'http://blogs.mathworks.com/images/steve/36/george.jpg';I = imread(url);imshow(I)The first step is to threshold the image. The Image Processing Toolbox functiongraythresh computes binarization thresholds automatically. It works well for a variety of images.
threshold = graythresh(I);bw = im2bw(I, threshold);imshow(bw)Toolbox function bwmorph has a thinning option, but it works on white (foreground) pixels instead of black pixels. So complement the image:
bw2 = ~bw;and then thin it. Specify the number of iterations to be Inf so thatbwmorph will keep thinning until the lines are a single pixel wide.
bw3 = bwmorph(bw2, 'thin', inf);imshow(bw3)Now trace the line using toolbox function bwboundaries.
boundaries = bwboundaries(bw3);boundaries is a cell array containing one P-by-2 matrix for each object boundary. This image contains only one object, soboundaries contains only one P-by-2 matrix. The matrix has twice as many rows as we need, becausebwboundaries traces all the way around the object.
b = boundaries{1};b = b(1:floor(end/2), :);Finally we are ready to plot the curve.
x = b(:,2);y = b(:,1);plot(x,y)axis ij % Place the origin at upper left, with y values increasing from % top to bottom.axis equal % Set the aspect ratio so that the data units are the same in % every direction.title('George P. Burdell')
0 0
- 20060221-Tracing George
- George Gissing
- Code Tracing
- SQL Tracing
- Enabling Tracing
- Oops-tracing
- Ray Tracing
- Ray Tracing
- George Winston《 December》
- API joyGetPos George hadd1
- API GetCurrentTime George wasd1
- API AddFontResource George, id1
- API EnumPrinters George! Gd1
- API DragQueryFile George verd1
- API mmioStringToFOURCC George, whd1
- George and Sleep
- George and Round
- . George and Sleep
- 面试题:把数组中的数分为两组,使得两组和相差最小 timus 1005. Stone Pile
- cmd 下命令
- Linux查看版本及内核
- Internet Explorer里的条件注释
- github在官网创建仓库
- 20060221-Tracing George
- 华为OJ Home+work
- POJ 1474 多边形的核(半平面交)
- C17_OC07-Category分类:增强模式
- tomcat设置nio模式
- 晚了
- WPF获取选中单元格的内容-技术&分享
- pvs算法
- 淮南投诉转载的博客hntszz