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

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 天前
计算机视觉(四):二值化
图像处理·人工智能·opencv·计算机视觉·二值化
XiaoMu_0012 天前
【全功能图片处理工具详解】基于Streamlit的现代化图像处理解决方案
图像处理·人工智能
unicrom_深圳市由你创科技2 天前
机器人视觉检测
图像处理·机器人·视觉检测
AndrewHZ2 天前
【3D算法技术入门】如何基于建筑图片重建三维数字资产?
图像处理·算法·3d·三维重建·colmap·点云处理·立体匹配
Js_cold3 天前
FPGA DDR 地址映射-黄金法则
图像处理·fpga开发·音视频·视频
智能物联实验室3 天前
屏随人动+视觉魔方+多样主题+智能留言,涂鸦Wukong AI 2.0助力打造爆款带屏云台相机
图像处理·人工智能·嵌入式硬件·数码相机·智能硬件
WSSWWWSSW3 天前
Python Imaging Library (PIL) 全面指南:Python Imaging Library (PIL)基础图像处理入门
开发语言·图像处理·python
WSSWWWSSW3 天前
Python OpenCV图像处理与深度学习:Python OpenCV入门-图像处理基础
图像处理·python·opencv
WSSWWWSSW4 天前
Python Imaging Library (PIL) 全面指南:PIL高级图像处理-分割与颜色空间转换
图像处理·python·计算机视觉·pillow
DogDaoDao5 天前
用PyTorch实现多类图像分类:从原理到实际操作
图像处理·人工智能·pytorch·python·深度学习·分类·图像分类