
how i can superpose (overlay) two images ?
63 views (last 30 days)
Show older comments
Hello
how i can superpose (overlay) two images with different size and find the différence?
Thanks
0 Comments
Answers (1)
DGM
on 7 Mar 2022
Edited: DGM
on 7 Mar 2022
You can use tools like imoverlay() or imfuse(), or you can combine the images by opacity blending.
There are other ways "overlay" can be interpreted, so you might want to clarify what kind of images you're dealing with and what you expect the result to be. Tools like imoverlay() might not work if neither image is binarized. Imfuse() may not be helpful if you want opacity blending for any alpha value other than 0.5.
This is basic opacity blending
FG = imread('cameraman.tif');
BG = imread('cmantifBG.png');
montage({FG BG})
a = 0.6; % foreground opacity
C = a*FG + (1-a)*BG;
imshow(C)
In image manipulation applications, 'overlay' might mean something entirely different:
C = imblend(FG,BG,1,'overlay'); % THIS IS A MIMT-ONLY TOOL (see file exchange)

Furthermore, it's conceivable that you want to combine two non-binarized images with the aid of a mask. Depending on what you want, this may be a logical or linear combination.
In all cases, it's expected that the images have the same geometry. If they don't, you'll have to figure out how you want to colocate them and then continue as before. Here's another example:
TL;DR: It depends.
5 Comments
DGM
on 7 Mar 2022
In the given example, I manually aligned them by cropping. As given, this attempts to align the square in the center region.
A generalized and automatic registration process would require a better understanding of the expectations regarding what might be presented and what's important to align. Registration accuracy would likely be hindered by the noise produced by compression.
See Also
Categories
Find more on Geometric Transformation and Image Registration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

