Reputation: 30107
Is it possible to copy (draw) one image into region of another in Matlab? I need not only copy a matrix part, but copy with interpolation, i.e. passing fraction coordinates.
Upvotes: 2
Views: 839
Reputation: 114846
You can "blend" images using alpha channel (or fractional mask).
Suppose you have master
the large image, region
the smaller image to be blended into master
and alpha
a fractional mask (the same size as region
), where alpha=0
indicates that the corresponding output pixel should be taken from master
, and alpha=1
indicates a pixel to be taken from region
(alpha
can be fractional to indicate a blend).
I assume master
, region
and alpha
has the same width and height, and are of type double
.
Then
>> blend = bsxfun( @times, master, 1-alpha) + bsxfun( @times, region, alpha )
Upvotes: 3