Engee documentation
Notebook

View image differences

This demonstration shows a common example of comparing images by viewing the differences due to overlapping.

Here, the imshowpair function is used to rotate the image to change 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 colours.

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 give the desired result.

Grey images in such a case can be filled with different RGB channels, create an RGB representation and then converted to a greyscale 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 explored several ways to visually compare both through algebraic operations and visual comparison. The figure above shows what these comparisons look like in a single output image.