20060613-Spatial transformations: findbounds
2014-05-09 16:56
267 查看
原文:http://blogs.mathworks.com/steve/2006/06/13/spatial-transformations-findbounds/
To avoid these problems (and to avoid the tech support calls!), the function
imtransform uses the function
findbounds to determine automatically where to place the output grid and how big it should be.
findbounds first creates a grid of points. These points are located in input space at each corner of the image, as well as in between each corner and in the middle. It looks like this:
findbounds then calls
tformfwd to transform these points into output space. (For this example I'm going to construct an affine tform struct that combines scaling, rotation, shear, and a large translation.)
When you call imtransform, you can use optional output arguments to determine where the image is located in output space.
imshow to place the image in the right place on an axes that contains other X-Y data.
To avoid these problems (and to avoid the tech support calls!), the function
imtransform uses the function
findbounds to determine automatically where to place the output grid and how big it should be.
findbounds first creates a grid of points. These points are located in input space at each corner of the image, as well as in between each corner and in the middle. It looks like this:
I = imread('rice.png'); h = imshow(I); set(h,'AlphaData',0.3); axis on, grid on in_points = [ ... 0.5000 0.5000 0.5000 256.5000 256.5000 0.5000 256.5000 256.5000 0.5000 128.5000 128.5000 0.5000 128.5000 128.5000 128.5000 256.5000 256.5000 128.5000]; hold on plot(in_points(:,1), in_points(:,2), '.', 'MarkerSize', 18) hold off
findbounds then calls
tformfwd to transform these points into output space. (For this example I'm going to construct an affine tform struct that combines scaling, rotation, shear, and a large translation.)
tform = maketform('affine', ... [1.1067 -0.2341 0; 0.5872 1.1769 0; 1000 -300 1]); out_points = tformfwd(tform, in_points)
plot(out_points(:,1), out_points(:,2), '.', 'MarkerSize', 18) axis ij, axis image grid onThe bounding box of the points in output space tells us where to put the output space grid.
When you call imtransform, you can use optional output arguments to determine where the image is located in output space.
[J,XData,YData] = imtransform(I, tform); XDataYou can use this information together with
imshow to place the image in the right place on an axes that contains other X-Y data.
h = imshow(J,'XData',XData,'YData',YData); set(h,'AlphaData',0.3) hold on plot(out_points(:,1), out_points(:,2), '.', 'MarkerSize', 18) axis on grid on hold off axis ij, axis imageSo that's the method imtransform uses to determine where the output image should be in output space.
相关文章推荐
- ngui 输入事件处理
- SVN常用命令说明
- Android* 应用性能调试
- 参加广州PHP精英培训班 让你成为互联网精英
- 双向链表的实现
- C++习题 复数类--重载运算符+
- DispatcherServlet作用
- Android中Activity启动模式详解(1)
- 凌晨寝室断网后。
- hive与hbase整合
- Eclipse 常用快捷键
- Minor GC 过程
- velocity自定义标签实现给静态资源添加版本号
- CBitmap与HBITMAP的转换
- eclipse RCP配置问题
- ORA-00600 [4194]的解决
- 敏捷开发
- Nuane.SftpLite.dll 使用其可以反编译出sftp server
- 母亲节,写给我的妈妈
- 关于Class.getResource和ClassLoader.getResource的路径问题