Filter löschen
Filter löschen

How do I combine two images of different sizes?

5 Ansichten (letzte 30 Tage)
Aliyu Abdu
Aliyu Abdu am 21 Apr. 2012
I have a small picture image that I want combine with a larger one,just like sticking them together. Re-sizing and adding them didn't work because the smaller one gets stretched too much when I re-sized it to size of the larger one,and the opposite when I tried re-sizing the larger one to the size of the smaller one. Can anyone help?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 21 Apr. 2012
You want the two images to be adjacent to each other in their different sizes? Or you want them to be adjacent but the same size as each other? Or you want to mix together the images like by transparency? Or you want to replace part of the first image by the second image?
If you want the two images to be adjacent to each other in their different sizes, then pad the edge of the first matrix with a band of as many zeros as matches the size of the second image, and then store the second image into the appropriate place in those zeros. Though you might have to use some value other than 0 (e.g., you might want the empty space to be white.)
  3 Kommentare
Walter Roberson
Walter Roberson am 21 Apr. 2012
sb = size(BiggerImage);
ss = size(SmallerImage);
BiggerImage(1,end+ss(2),1) = 0; %extend image
BiggerImage(1:ss(1), sb(2):sb(2)+ss(2)-1, :) = SmallerImage;
Aliyu Abdu
Aliyu Abdu am 21 Apr. 2012
Thanks so much!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by