Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-12-10, 20:48   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 如何在MATLAB中创建拼贴?

我想编写一个程序,可以从给定的图片文件夹中创建随机拼贴。

首先,我想用三个图像创建一个简单的拼贴。像这样:



我现在几乎没有代码

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)

更多&回答...
poster 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 01:09


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.