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

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博客

相关推荐
youcans_5 天前
【AI辅助编程】ROP 图像预处理
图像处理·人工智能·ai编程·辅助编程
sali-tec5 天前
C# 基于OpenCv的视觉工作流-章27-图像分割
图像处理·人工智能·opencv·算法·计算机视觉
unicrom_深圳市由你创科技5 天前
医疗设备专用图像处理板卡定制
图像处理·人工智能·fpga开发
guygg885 天前
图像匹配技术:相关匹配、Hausdorff距离匹配与基于距离变换的Hausdorff距离匹配
图像处理·opencv·计算机视觉
qq_526099135 天前
图像采集卡:机器视觉系统的“数据中枢”,解锁精准成像新可能
图像处理·数码相机·计算机视觉·自动化
sali-tec6 天前
C# 基于OpenCv的视觉工作流-章26-图像拼接
图像处理·人工智能·opencv·算法·计算机视觉
xinxiangwangzhi_6 天前
立体匹配--Cross-Scale Cost Aggregation for Stereo Matching
图像处理·计算机视觉
沃达德软件6 天前
模糊图像复原技术解析
图像处理·人工智能·深度学习·目标检测·机器学习·计算机视觉·目标跟踪
hans汉斯6 天前
《数据挖掘》期刊推介&征稿指南
图像处理·人工智能·算法·yolo·数据挖掘·超分辨率重建·汉斯出版社
码农三叔6 天前
(3-1-01)视觉感知:从像素到语义:图像处理基础
图像处理·人工智能·嵌入式硬件·机器人·人机交互·人形机器人