Visualizing circles around feature points

As a quick aside, let's implement a function to draw circles around a feature point, rather than just a single point. The idea would that for every True value in the mask, I look in a neighborhood around that mask, and for every point that is equal to the radius of the circle I want to draw,

To do this I had to learn about StaticArrays and CartesianRange types.

Basically, a


In [ ]:
using StaticArrays;

In [ ]:
# radius in pixels
function draw_circles(image::AbstractArray, mask::AbstractArray{Bool}; c::Colorant=RGB(1, 0, 0))
    new_mask = falses(mask);
    new_image = copy(image);
    R = CartesianRange(size(mask));
    f, l = first(R), last(R);
    for I in R
        if mask[I]
            for J in CartesianRange(I - 1, I + 1)
                dist = sqrt(sum((SVector(I.I) - SVector(J.I)) .^ 2));
                if dist == 1
                    new_mask[min(max(f, J), l)] = true
                end
            end
        end
    end
    
    new_image[new_mask] = c;
    return new_image;
end

In [ ]:
draw_circles(img1, features_1)