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

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

相关推荐
Yan-英杰17 分钟前
百度搜索和文心智能体接入DeepSeek满血版——AI搜索的新纪元
图像处理·人工智能·python·深度学习·deepseek
MYT_flyflyfly6 小时前
计算机视觉-OpenCV图像处理
图像处理·opencv·计算机视觉
Zoe Din9 小时前
【图像加密解密】空间混沌序列的图像加密解密算法复现(含相关性检验)【Matlab完整源码 2期】
图像处理·密码学
沐风_ZTL14 小时前
在RK3568上C++编程,使用ISP进行图像处理
c++·图像处理·mpp·rk3568·isp·v4l2·rga
高力士等十万人17 小时前
有哪些滤波,原理是什么,分别在什么时候用
图像处理·python·opencv·计算机视觉
傻啦嘿哟19 小时前
Python图像处理中的内存泄漏问题:原因、检测与解决方案
开发语言·图像处理·python
gloomyfish2 天前
OpenCV4.8 开发实战系列专栏之 32 - 图像梯度-更多梯度算子
图像处理·opencv·计算机视觉
Ronin-Lotus2 天前
图像处理篇---基本OpenMV图像处理
图像处理·人工智能·python·机器学习·计算机视觉·openmv
mm_exploration3 天前
halcon激光三角测量(十七)calibrate_sheet_of_light_3d_calib_object
图像处理·3d·halcon·点云处理
old_power3 天前
图像缩放的双线性插值实现方式
图像处理·opencv·numpy