I\'ve got a task to implement Sobel filter which is, as you know, an image processing filter for edge detection. But unfortunately, I\'ve got no experience in image processi
You can do this in R with the raster package (oriented towards geographic data)
library(raster)
sobel <- function(r) {
fy <- matrix(c(1,0,-1,2,0,-2,1,0,-1)/4, nrow=3)
fx <- matrix(c(-1,-2,-1,0,0,0,1,2,1)/4 , nrow=3)
rx <- focal(r, fx)
ry <- focal(r, fy)
sqrt(rx^2 + ry^2)
}
b <- brick("https://i.stack.imgur.com/Bnxa6.jpg")
plotRGB(b)
s <- stack(lapply(1:3, function(i) sobel(b[[i]])))
plotRGB(s)
# or
ss <- mean(s)
plot(ss, col=gray(1:10/10))
# or
bb <- mean(b)
sss <- sobel(bb)
plot(sss, col=gray(1:10/10))