![]() |
如何在MATLAB中创建拼贴?
我想编写一个程序,可以从给定的图片文件夹中创建随机拼贴。
首先,我想用三个图像创建一个简单的拼贴。像这样: [IMG]https://i.imgur.com/I5AHe.png[/IMG] 我现在几乎没有代码 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中完成? 如何[B]拉伸[/B] , [B]旋转[/B]然后将单个图像放置在画布上,以便在创建拼贴画时可以完全自由?可能会发生图像放置,以致图像位于画布区域之外。 [IMG]https://i.imgur.com/JrrpZ.png[/IMG] 将图像拉伸成表格是拼贴的一种方法,但是我希望能够拉伸并放置它们 [B]回答:[/B] 假设您想将图像拉伸成一定形状,并且拥有图像处理工具箱,则可以使用[URL="http://www.mathworks.com/access/helpdesk/help/toolbox/images/imresize.html"]IMRESIZE[/URL]通过以下方式进行[URL="http://www.mathworks.com/access/helpdesk/help/toolbox/images/imresize.html"]拼贴[/URL] : 创建一个保存为.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) [url=https://stackoverflow.com/questions/3487412]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 01:03。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.