The last descriptor available in Julia is the FREAK descriptor, which was developed in 2012. The algorithm introduces a new keypoint descriptor inspired by the human visual system and, more precisely, the retina, coined the Fast Retina Keypoint (FREAK).
FREAKs are in general quicker to calculate with lower computational requirements. It makes them a great alternative to the methods covered in the preceding section. FREAK is considered to be the fastest scale, rotation, and noise invariant algorithm.
The code examples stay very similar to those we have already seen. First, we load the packages and images by using the following code:
using Images, ImageFeatures, CoordinateTransformations, ImageDraw, ImageView
img1 = Gray.(load("cat-3417184_640.jpg"))
img2 = Gray.(load("cat-3417184_640_watermarked.jpg"))
We apply multiple transformations to the second image to complicate the example. We add rotation around the center and resize the image by using this code:
rot = recenter(RotMatrix(5pi/6), [size(img2)...] .÷ 2)
tform = rot ∘ Translation(-50, -40)
img2 = warp(img2, tform, indices(img2))
img2 = imresize(img2, Int.(trunc.(size(img2) .* 0.7)))
We execute the FAST algorithm to find the corners and use FREAK to match the keypoints by using this code:
keypoints_1 = Keypoints(fastcorners(img1, 12, 0.35));
keypoints_2 = Keypoints(fastcorners(img2, 12, 0.35));
freak_params = FREAK()
desc_1, ret_keypoints_1 = create_descriptor(img1, keypoints_1, freak_params);
desc_2, ret_keypoints_2 = create_descriptor(img2, keypoints_2, freak_params);
matches = match_keypoints(ret_keypoints_1, ret_keypoints_2, desc_1, desc_2, 0.2)
Similar to the preceding cases, we plot the results and generate a preview by using this code:
img3 = zeros(size(img1, 1), size(img2, 2))
img3[1:size(img2, 1), 1:size(img2, 2)] = img2
grid = Gray.(hcat(img1, img3))
offset = CartesianIndex(0, size(img1, 2))
map(m -> draw!(grid, LineSegment(m[1], m[2] + offset)), matches)
grid
As you can see from this image, the result is very nice:
The keypoints are matched very well. This seems very similar to BRISK.