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

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

相关推荐
Evand J4 小时前
【MATLAB例程,图像滤波5】 反谐波均值滑动窗口滤波(CHMF)图像降噪与质量评价,附代码下载链接
图像处理·算法·计算机视觉·matlab·均值算法·滑动窗口滤波·均值滑动
PhotonixBay11 小时前
3D共聚焦显微镜与探针式粗糙度仪:谁更适合亚表面损伤检测?
图像处理·人工智能·测试工具·3d
AndrewHZ13 小时前
图像处理入门026 | 分段线性变换:灰度窗与阶梯变换——CT 窗宽窗位的数学本质
图像处理·ct影像·分段线性变换·灰度窗·阶梯变换·密度分层·中间调拉伸
Ro Jace14 小时前
基于深度学习的图像处理方法
图像处理·人工智能·深度学习
AndrewHZ1 天前
图像处理入门025 | 非线性灰度变换:伽马校正与 Log 变换——暗图救星的两条曲线
图像处理·伽马校正·log变换·非线性点运算·自动伽马·lut加速·暗图增强
AndrewHZ1 天前
图像处理入门024 | 线性灰度变换:亮度与对比度调整
图像处理·性能基准·线性灰度变换·亮度 β·对比度 α·uint8溢出·hsv/lab
岁月蹉跎的一杯酒1 天前
格科微内置 ISP 图像效果调试(格科微 YUV Sensor)—GC2145
图像处理·isp·gc2145
FPGA开源工坊2 天前
ISP图像处理--Bayer Raw格式
图像处理·人工智能·verilog·fpga·isp
江畔柳前堤2 天前
具身智能全景深度指南(2026年9月版):从“会聊天的AI“到“能干活的机器“
大数据·javascript·图像处理·人工智能·分布式·智慧城市·原型模式
安河桥。2 天前
Android视频流处理模块硬件加速器数据流转技术说明
android·图像处理·isp