Engee documentation
Notebook

Viewing the difference of images

This demo shows a common example of comparing images by viewing differences through superposition.

Here, the imshowpair function is used to rotate the image.

In [ ]:
Pkg.add(["TestImages"])
In [ ]:
using Images
using TestImages
In [ ]:
# Загрузка тестового изображения
img = float.(testimage("cameraman"))
# поверните изображение на 4 градуса
img_r = imrotate(img, -pi/45, axes(img))
Out[0]:
No description has been provided for this image

The mosaicview function allows you to display multiple images. This method is especially useful when images have different sizes and colors.

In [ ]:
mosaicview(img, img_r; nrow=1, npad=20, fillvalue=colorant"white")
Out[0]:
No description has been provided for this image

In some cases, when the differences between two images are relatively minor, a simple visual comparison may not produce the desired result.

In this case, gray images can be filled with different RGB channels, an RGB representation can be created, and then converted to a grayscale image.

In [ ]:
RGB_diffview = colorview(RGB, channelview(img), channelview(img_r), fill(0., size(img)))
Gray_diffview = Gray.(RGB_diffview)
Out[0]:
No description has been provided for this image

Also, two images can be compared by calculating their difference.

In [ ]:
plain_diffview = @. img - img_r
Out[0]:
No description has been provided for this image
In [ ]:
mosaicview(plain_diffview, RGB_diffview;
           nrow=1, npad=20, fillvalue=colorant"white")
Out[0]:
No description has been provided for this image

Conclusion

We have studied several ways of visual comparison, both through algebraic operations and through visual comparison. The figure above shows what these comparisons look like in a single output image.