How can I stack images from multiple folders?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I got three images in three diffrent folders attached(1, Background. 2,Body 3, Expressions). I help stacking the images together from attached three diffrent folders. i would appreciate any help with the code.
imfuse will work to combine the imgaes from single folder. But, i need help pick the images from diffrent folders and stack it together as shwon here.
0 comentarios
Respuesta aceptada
DGM
el 11 de Mzo. de 2022
Editada: DGM
el 11 de Mzo. de 2022
As far as I know, nothing in MATLAB or IPT directly supports images with alpha, though you can certainly tote alpha around as a separate mask image. Even at that, imfuse() isn't a composition tool and has no means to utilize a mask.
% read images and alpha
[expr,~,expra] = imread('Expressions/standard.png');
[body,~,bodya] = imread('Body/maroon.png');
BG = imread('Background/blue.png');
% convert to floating point for simplicity
expr = im2double(expr);
expra = im2double(expra);
body = im2double(body);
bodya = im2double(bodya);
BG = im2double(BG);
% compose the image as weighted sums, working from the bottom up
outpict = body.*bodya + BG.*(1-bodya);
outpict = expr.*expra + outpict.*(1-expra);
% convert back to original class
outpict = im2uint8(outpict);
imshow(outpict)
MIMT has tools that can do this more succinctly, either using the alpha as a separate mask:
[expr,~,expra] = imread('Expressions/standard.png');
[body,~,bodya] = imread('Body/maroon.png');
BG = imread('Background/blue.png');
outpict = replacepixels(body,BG,bodya);
outpict = replacepixels(expr,outpict,expra);
imshow(outpict)
... or by using alpha combined with the image (RGBA)
[expr,~,expra] = imread('Expressions/standard.png');
[body,~,bodya] = imread('Body/maroon.png');
BG = imread('Background/blue.png');
% these are now RGBA images
expr = cat(3,expr,expra);
body = cat(3,body,bodya);
% imblend and imshow2 handle RGBA images just fine
outpict = imblend(body,BG,1,'normal');
outpict = imblend(expr,outpict,1,'normal');
imshow2(outpict)
... or the images can be combined as a layer stack and composed in a single pass:
[expr,~,expra] = imread('Expressions/standard.png');
[body,~,bodya] = imread('Body/maroon.png');
BG = imread('Background/blue.png');
% these are now RGBA images
expr = cat(3,expr,expra);
body = cat(3,body,bodya);
% pad and stack on dim4
stack = imstacker({expr,body,BG});
% compose the entire stack in one shot
outpict = mergedown(stack,1,'normal');
imshow2(outpict)
Though the latter two cases only makes sense if an RGBA workflow is convenient for other reasons. As I said, nothing in MATLAB or IPT knows what to do with an RGBA image, so you'd constantly have to work around that.
15 comentarios
DGM
el 14 de Mzo. de 2022
I'm not going to be much help with that, since the video encoding tools don't work in my environment. There are some examples in the documentation, and Image Analyst has posted a similar demo before:
The general workflow would be
Generate image sequence -> Convert image sequence to video
Más respuestas (1)
Benjamin Thompson
el 11 de Mzo. de 2022
montage or imtile should work for what you want.
1 comentario
DGM
el 11 de Mzo. de 2022
Neither imfuse(), montage(), nor imtile() support RGBA images or RGB images with a mask of any form.
Despite the wording of the documentation, I don't think it's reasonable to call these composition tools. The closest that any of these come to image composition is imfuse() with a 'blend' option, but that's only supported for I/RGB images, and it only supports 50% opacity with no mask. It's more of a crude comparison tool than anything.
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!