Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
我想编写一个程序,可以从给定的图片文件夹中创建随机拼贴。
首先,我想用三个图像创建一个简单的拼贴。像这样: ![]() 我现在几乎没有代码 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中完成? 如何拉伸 , 旋转然后将单个图像放置在画布上,以便在创建拼贴画时可以完全自由?可能会发生图像放置,以致图像位于画布区域之外。 ![]() 将图像拉伸成表格是拼贴的一种方法,但是我希望能够拉伸并放置它们 回答: 假设您想将图像拉伸成一定形状,并且拥有图像处理工具箱,则可以使用IMRESIZE通过以下方式进行拼贴 : 创建一个保存为.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) 更多&回答... |
![]() |
![]() |