Canny Edge Detector-JuliaImages

I registered a new package ImageEdgeDetection.jl yesterday and it solves the issues you are encountering. That is, it works on OffsetArrays and it also handles the NaNs that arise as a by-product of your warp function correctly. I discovered a moment ago when trying your example that the current canny function in Images seems to have a bug with NaNs because it yields spurious artifacts in the NaN regions of the image.

With the ImageEdgeDetection package, the solution you are looking for looks likes this:

using CoordinateTransformations
using ImageCore
using ImageEdgeDetection
using ImageFiltering
using ImageTransformations
using ImageShow
using OffsetArrays
using Rotations

img_gray = zeros(Gray{Float64}, 200, 200)
img_gray[50:150, 50:150] .= 1
tfm = recenter(RotMatrix(pi/8), center(img_gray))
imgrot = warp(img_gray, tfm) 
imgg = imfilter(imgrot, Kernel.gaussian(3))
algo = Canny(spatial_scale = 1, 
             high = ImageEdgeDetection.Percentile(80), 
             low = ImageEdgeDetection.Percentile(20))
img_edges = detect_edges(imgg, algo)   
3 Likes