图像变换——等距变换、相似变换、仿射变换、投影变换

Matlab 复制代码
%%图像变换
% I = imread('cameraman.tif');
I = imread('F:\stitching\imagess\or\baiyun2.jpg');
figure; imshow(I); title('原始图像');
[w,h]=size(I);
theta=pi/4;%旋转角
t=[200,80];%平移tx,ty
s=0.3;%缩放尺度
%% 等距变换=平移变换+旋转变换
H_e=projective2d([cos(theta) sin(theta) t(1);
              -sin(theta)  cos(theta) t(2);
                  0           0       1]');
I_e=imwarp(I,H_e);
figure; imshow(I_e); title('等距变换');
%% 相似变换=等距变换+均匀缩放
H_s=projective2d([s*cos(theta) -s*sin(theta) t(1);
                  s*sin(theta)  s*cos(theta) t(2);
                     0           0       1]');
I_s=imwarp(I,H_s);
figure; imshow(I_s); title('相似变换');
%% 仿射变换=平移变换+非均匀变换
H_a=projective2d([1 0.2 t(1);
                 0 1 t(2);
                 0 0  1]');
I_a=imwarp(I,H_a);
figure; imshow(I_a); title('仿射变换');
%% 投影变换
H_P=projective2d([0.765,-0.122,-0.0002;
                 -0.174,0.916,9.050e-05;
                  105.018,123.780,1]);
I_P=imwarp(I,H_P);
figure; imshow(I_P); title('投影变换');

% %% 黑色背景变白色
% linear_out = I_a;
% redChannel = linear_out(:, :, 1);
% greenChannel = linear_out(:, :, 2);
% blueChannel = linear_out(:, :, 3);
% thresholdValue = 0;
% mask = redChannel == thresholdValue & greenChannel == thresholdValue & blueChannel == thresholdValue;
% maskedRed = redChannel;
% maskedGreen = greenChannel;
% maskedBlue = blueChannel;
% % Do the masking - make white where it was black.
% maskedRed(mask) = 255;
% maskedGreen(mask) = 255;
% maskedBlue(mask) = 255;
% mosaic = cat(3, maskedRed, maskedGreen, maskedBlue);
% figure; imshow(mosaic);

实验结果:

等距变换:

相似变换

仿射变换

投影变换

参考文章图像变换------等距变换,相似变换,仿射变换,投影变换_投影扭曲 相似扭曲-CSDN博客

相关推荐
热热虎1 天前
医学图像分割最新进展
图像处理·人工智能·深度学习·计算机视觉
phoenix@Capricornus1 天前
卷积核、FIR滤波器与LTI系统——一回事
图像处理
蹦蹦跳跳真可爱5891 天前
Python----OpenCV(图像处理——图像的多种属性、RGB与BGR色彩空间、HSB、HSV与HSL、ROI区域)
图像处理·人工智能·opencv
一起搞IT吧2 天前
相机Camera日志实例分析之二:相机Camx【专业模式开启直方图拍照】单帧流程日志详解
android·图像处理·数码相机
HarrietLH2 天前
Matlab实现任意伪彩色图像可视化显示
图像处理·计算机视觉·matlab
大白爱琴2 天前
使用python进行图像处理—图像变换(6)
图像处理·人工智能·python
大白爱琴2 天前
使用python进行图像处理—像素级操作与图像算术(4)
开发语言·图像处理·python
时间之里3 天前
【图像处理3D】:焦距的像素单位标定
图像处理·数码相机·3d
老胖闲聊3 天前
Python Rio 【图像处理】库简介
开发语言·图像处理·python
时间之里3 天前
【图像处理3D】:世界坐标系
图像处理·数码相机·3d