Image 如何在MATLAB中创建拼贴?
我想写一个程序,可以创建随机拼贴从一个给定的文件夹的图片 首先,我想从三幅图像中创建一个简单的拼贴。大概是这样的: 我现在几乎没有代码Image 如何在MATLAB中创建拼贴?,image,matlab,image-processing,Image,Matlab,Image Processing,我想写一个程序,可以创建随机拼贴从一个给定的文件夹的图片 首先,我想从三幅图像中创建一个简单的拼贴。大概是这样的: 我现在几乎没有代码 clc; clear all; close all; a = imread('a.png'); b = imread('b.png'); c = imread('c.png'); % create a new image of size X x Y % for a simple collage % place a in the top half % p
clc;
clear all;
close all;
a = imread('a.png');
b = imread('b.png');
c = imread('c.png');
% create a new image of size X x Y
% for a simple collage
% place a in the top half
% place b in the bottom left
% place c in the bottom right
如何在MATLAB中实现这一点
如何拉伸,旋转,然后将各个图像放置在画布上,以便在创建拼贴时拥有完全的自由?图像放置可能会使图像位于画布区域之外
拉伸图像以形成拼贴是一种方法,但我希望能够拉伸并放置它们假设您希望将图像拉伸成形状,并且您有图像处理工具箱,您可以使用以下方法进行拼贴: 创建一个保存为.m文件的函数。这比调用“全部清除/全部关闭”安全得多
function collImg = collage
%#COLLIMG creates a collage of three images called 'a.png' 'b.png' and 'c.png'
%#
%# OUTPUT collImg : collage image, with individual images arranged as [a;b,c]
%#
a = imread('a.png');
b = imread('b.png');
c = imread('c.png');
newImageSize = [512,512]; %# or anything else that is even
%# get the new sizes - this approach requires even image size
newSizeA = newImageSize./[2,1];
newSizeB = newImageSize./[2,2];
newSizeC = newImageSize./[2,2];
%# resize the images and stick together
%# place a in the top half
%# place b in the bottom left
%# place c in the bottom right
collImg = [imresize(a,newSizeA);imresize(b,newSizeB),imresize(c,newSizeC)];
%# display the image
figure,imshow(collImg)
单个图像的大小是多少?如果所有的图像都是正方形呢?你有图像处理工具箱吗?谢谢!是的,我可以用工具箱。我希望能够将图像放置在画布的任何部分。最好的方法是什么?首先定义每个图像的中心点和新大小。然后(在循环中)调整图像大小,使用
imrotate
旋转图像,最后将图像放置在拼贴上,使其中心位于您希望的位置。