[共享] 小圖拼大圖/蒙太奇(Matlab)

看板EZsoft作者 (阿信)時間18年前 (2006/08/15 12:17), 編輯推噓4(400)
留言4則, 4人參與, 最新討論串1/1
因為之後陸續有人寫信跟我要這個程式 加上本來存放此程式的空間已經不見(前陣子畢業了) 所以我直接把程式碼POST出來供大家參考 (前提還是要有Matlab程式,我用Matlab 7寫的) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all close all [fname path] = uigetfile({'*.jpg';'*.bmp';'*.tif'},'Base Image Selector'); base = imread([path fname]); dname = uigetdir('C:\','Select Directory of Images to Open'); tic cell_width = 100; cell_hight = 100; pixels = cell_width*cell_hight; cell_size = [30 40]; cell_pix = cell_size(1)*cell_size(2); output = cell([cell_hight cell_width]); base = imresize(base,[cell_hight cell_width],'bilinear'); baseR = base(:,:,1); baseG = base(:,:,2); baseB = base(:,:,3); fid = dir([dname '\*.jpg']); file_num = size(fid); resize_pic = cell(1,file_num(1)); for i = 1:file_num(1) I = imread([dname '\' fid(i).name],'jpg'); resize_pic{i} = imresize(I,cell_size); end rand_pic = randint(cell_hight,cell_width,[1 file_num(1)]); for i = 1:pixels I = resize_pic{rand_pic(i)}; I(:,:,1) = I(:,:,1) + (double(baseR(i)) - mean2(I(:,:,1))); I(:,:,2) = I(:,:,2) + (double(baseG(i)) - mean2(I(:,:,2))); I(:,:,3) = I(:,:,3) + (double(baseB(i)) - mean2(I(:,:,3))); output{i} = I; end output = cell2mat(output); toc imwrite(output,uiputfile('*.jpg')); figure, imshow(output) -- 妳可以因為我長得帥而喜歡我... 但我長得帥並不是為了讓妳喜歡... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.114.58.115

08/15 12:52, , 1F
推..
08/15 12:52, 1F

08/15 20:11, , 2F
push
08/15 20:11, 2F

08/16 02:15, , 3F
推 我有跟你要過 :)
08/16 02:15, 3F

08/16 12:04, , 4F
推學長
08/16 12:04, 4F
文章代碼(AID): #14uKh8ng (EZsoft)