matlab 图像的几何变换
2016-08-17 13:06
781 查看
图像如果向前映射有效率低,不完成等缺点,所以一般我们使用向后映射。
(1)平移:
I = imread('apostles.jpg'); I = double(I); B = zeros(size(I)); H = size(I); move_x = 100; move_y = 150; B(move_y + 1:H(1), move_x+1:H(2), 1:H(3))=... I(1:H(1)-move_y, 1:H(2) - move_x, 1:H(3)); subplot(1,2,1),subimage(uint8(I)) title('原图像') subplot(1,2,2),subimage(uint8(B)) title('平移变换');
I = imread('apostles.jpg'); se=translate(strel(1),[150 100]); B = imdilate(I,se); figure; subplot(1,2,1),subimage(I); title('原图像'); subplot(1,2,2),subimage(B); title('平移变换');
(2)镜像:
I = imread('apostles.jpg'); [height, width, dim]=size(I); %水平镜像变换 tform = maketform('affine',[-1 0 0;0 1 0; width 0 1]); B=imtransform(I, tform, 'nearest'); %垂直镜像变换 tform2 = maketform('affine', [1 0 0; 0 -1 0; 0 height 1]); C=imtransform(I, tform2, 'nearest'); subplot(1,3,1),imshow(I); title('原图像'); subplot(1,3,2),imshow(B); title('水平图像'); subplot(1,3,3),imshow(C); title('垂直图像');
A = imread('apostles.jpg'); A = double(A); figure(1), imshow(uint8(A)); H = size(A); figure(2),B(1:H(1),1:H(2),1:H(3))=A(H(1):-1:1,1:H(2),1:H(3));%垂直镜像 imshow(uint8(B)); figure(3),C(1:H(1),1:H(2),1:H(3))=A(1:H(1),H(2):-1:1,1:H(3));%水平镜像 imshow(uint8(C));
(3)转置:
I = imread('apostles.jpg'); tform = maketform('affine',[0 1 0; 1 0 0; 0 0 1]);%定义转置矩阵 B = imtransform(I, tform, 'nearest'); subplot(1,2,1),imshow(I) title('原图像'); subplot(1,2,2),imshow(B) title('转置图像');
(4)缩放:
I = imread('C:\apostles.jpg'); A = imresize(I, 1.5, 'nearest');%最近插值法 B = imresize(I, 1.5, 'bilinear');%双线性插值法 C = imresize(I, 1.5, 'bicubic');%二次立方插值法 subplot(2,2,1), imshow(I), title('original'); subplot(2,2,2), imshow(A), title('nearest'); subplot(2,2,3), imshow(B), title('bilinear'); subplot(2,2,4), imshow(C), title('bicubic'); A = imresize(I, [a b], 'nearest');%不同方向比例差值
(5)旋转:
I = imread('apostles.jpg'); A = imrotate(I, 30, 'nearest');%旋转30度,最邻近插值 figure(1),imshow(A) B = imrotate(I, 45, 'bilinear','loose');%旋转45度,二次线性插值 figure(2),imshow(B)
相关文章推荐
- matlab 图像几何变换 平移、旋转、缩放
- Matlab图像的几何变换之图像缩放
- Matlab图像几何变换之图像旋转
- Matlab图像的几何变换之图像平移
- Matlab图像的几何变换之图像平移
- matlab之原始处理图像几何变换
- Matlab学习20101207(图像读写和几何变换)
- matlab 图像几何变换 平移、旋转、缩放
- matlab之原始处理图像几何变换
- Matlab图像的几何变换之图像镜像
- Matlab图像的几何变换之图像镜像
- matlab 图像的几何变换
- Matlab图像的几何变换之图像转置
- Matlab图像的几何变换之图像转置
- 在Matlab中实现图像的几何变换
- 【图像处理】MATLAB:几何变换与图像配准
- matlab之原始处理图像几何变换
- Matlab图像的几何变换之图像缩放
- Matlab图像几何变换之图像旋转
- OpenCV-图像几何变换:旋转,缩放,斜切