2021-11-15

Matlab图像拆分技巧

将窄图裁剪成宽图

function img = image_reshape_inv(inImage,row,col)
% image_reshape(rand(2,9),6,3)   %将窄图裁剪成宽图 512x512 -> 4096x64 -> 512x512
[m,n] = size(inImage);
a = reshape(inImage',n,row,[]);
b = permute(a,[2,1,3]);
c = reshape(b,row,col);
img = c;
function img = image_reshape(inImage,row,col)
% image_reshape(rand(2,9),6,3)   %将宽图裁成短图,512x512 -> 4096x64
[m,n] = size(inImage);
a = reshape(inImage,m,col,[]);
b = permute(a,[2,1,3]);
c = reshape(b,col,row)';
img = c;

将四张图片拼成一张图

%图像转换成h*w*4的三维矩阵
figure;
subplot(2,2,1);imshow(src(:,:,1),[]);
subplot(2,2,2);imshow(src(:,:,2),[]);
subplot(2,2,3);imshow(src(:,:,3),[]);
subplot(2,2,4);imshow(src(:,:,4),[]);

figure(2);
%将图像转换成h*(w*4)的二维矩阵
b = permute(src,[2,3,1]); 
d =reshape(b,2720*4,[]);
imshow(d',[]);%实现图像转换成h*(w*4)的二维矩阵
%将图像转换成h*2w*2的二维矩阵
e =reshape(d',2704,2720*2,[]);
f = permute(e,[1,3,2]);
%将图像转换成2h*2w的图像
g = reshape(f,2704*2,[]);
imshow(g,[])%输出结果
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值