3D Computer Vision Assignment 4
3D Computer Vision Assignment 4
is the warped
image, and xdata and ydata store the translation information, which will be used
when the mixing of images is calculated.
1.5 Mixing images
An easy way to mosaic the images is to take the reference image (the one
that wasnt warped) and copy the warped image over it, using the translation
information to position the warped image correctly. This approach has one big
problem: the superimposing of images is very easy to see, and this is seen as
artifacts in the resulting mosaic:
3
Available at: http://www.csse.uwa.edu.au/
~
pk/Research/MatlabFns/
2
To prevent this, a mask is applied to each image before it is added into the
mosaic. To create such mask, an initial mask is created for each image, in a way
that it has the greater value at the center, and decreases linearly to the borders.
The value of all masks is added into the mosaic mask, and then the nal mask
for each image is determined by dividing its initial mask by the mosaic mask.
Simple mosaic of images A and B. Mosaic mask.
Initial mask for A. Initial mask for B.
Final mask for A. Final mask for B.
Final mosaic.
The initial mask for each image is calculated by the implemented function
3
getMask(), which calculates the inverse distance of each pixel to the image center
in each axis (X and Y), measuring this inverse distance as 1 in the center and
0 close to the borders. The nal value for each pixel in the mask is its inverse
X distance times its inverse Y distance.
The functions immix2() and immix fast() were implemented to handle the
mixing of images. immix2() is just a wrapper around immix fast() that facil-
itates the passing of parameters. This functions do not apply any warping to
the images, they only mix two images at given coordinates using the procedure
described before.
A initial implementation of this method was done in the function immix().
Due to the authors inexperience with MATLAB, a lot of for cicles were used
to calculate the masks, and some values were calculated twice, in the hopes
that recalculating some simple values was faster than storing and retrieving
them from memory (as it happens with some algorithms implemented in C).
However, immix() was very inecient, and most of the time of the whole mo-
saicing process was spend only mixing the images. The function immix fast()
is a re implementation of immix(), using no loops and relying in MATLABs
vectorization.
Using MATLABs Proler to measure the eciency of immix() and im-
mix fast(), it was found that the speedup of the new function is very signicant.
Using 5 images to produce a mosaic took 13.039 seconds using immix(), of which
12.519 seconds are used by immix(). In contrast, using immix fast() to produce
the same mosaic took 0.591 seconds, of which only 0.088 seconds were spend in
immix fast(). This represents a speedup of 22, with immix fast() using about
15% of the total time, which is a big improvement over the 96% of the total
time used by immix().
1.6 Creation of the mosaic
To put all the previous steps together, the function imfuse() was implemented.
This function receives two images, say A and B, and calls ndHomography()
to estimate the homography H that match A into B. Then it warps A into
A