Closed Turtyo closed 3 weeks ago
@Turtyo That's an excellent point, it would be great to have a global sobel function. If you would like to make a PR for it with your implementation, that would be fantastic! 🎉
I'll make the PR this week then. I notice all functions have a wasm
binding, generated automatically ? I'll look at other functions to be sure. Any test to run / performance test ?
@Turtyo That's great, thanks very much! If you would like a WebAssembly version to be created, you will need to add the wasm binding also.
We add tests to the tests.rs
module. The test consists of creating a PhotonImage from a vector of pixels and then running the function (in your case, the sobel function) on the image. It then checks if the resulting vector of pixels matches the correct vector after the function has been applied.
Description
Since there is both
sobel_vertical
andsobel_horizontal
, I was wondering why there is nosobel
alone. Usually calculated as the magnitude of the X and Y component from what I know, ie $\text{Sobel} = \sqrt{\text{Sobel}_X^2 + \text{Sobel}_Y^2}$Is the reason that there is no single way to define a global sobel ? I think it would be nice to have at least one implementation because a lot of image editors allow for a Sobel edge detection and they are not either on X or Y, so they have some kind of global sobel like that
Implementation
I implemented it on my side by getting both the
X
andY
components and iterating over each pixel to calculate $\sqrt{X^2 + Y^2}$; if it's ok, I can make a PR with the code for it.There is maybe a more efficient way by a direct convolution, but calculating a magnitude is not linear, so i'm not sure it can be done purely with convolutions.