Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sobel on both X and Y #193

Merged
merged 1 commit into from
Oct 31, 2024
Merged

Conversation

Turtyo
Copy link
Contributor

@Turtyo Turtyo commented Oct 30, 2024

Description

This pull request implements a sobel filter using the magnitude of the X and Y components of the sobel filter to build the image. It calculates $\sqrt{X^2 + Y^2}$ for each pixel of the image, with X the horizontal sobel component, and Y the vertical sobel component.

Tests

It was discussed in the related issue ( closes #192 ) that tests were written in tests.rs, but calculating the expected result would just come to applying the algorithm by hand. As I noticed that none of the other convolution functions had a test, should I still write a test for it ?

Result

I modified src/bin/bin.rs quickly to test the result:

Original image:
image

Global sobel:
image

For comparison, here are both the horizontal and vertical sobel:

Horizontal Vertical
image image

Time

As a oneshot (so not very reliable but that gives an idea):

  • Global: 66.7 ms
  • Horizontal: 29.2ms
  • Vertical: 29.7ms

The results are quite logical, since the global needs to calculate both the X and Y components (which should take around 60ms on my computer); a bit surprising that it only takes 6ms then to calculate the magnitude for each pixel, but since it was a single time test, maybe not the best to calculate things on.

PS: Those times are with --release flag

@Turtyo
Copy link
Contributor Author

Turtyo commented Oct 30, 2024

Not sure if you want to be pinged for PR to see them from the notification tab @silvia-odwyer but just in case I will ping

@silvia-odwyer silvia-odwyer merged commit 3cdcd0e into silvia-odwyer:master Oct 31, 2024
4 of 5 checks passed
@silvia-odwyer
Copy link
Owner

@Turtyo Thanks very much for your excellent contribution, it's much appreciated! 🎉 I'm delighted that the library now has a global sobel function ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sobel on both X and Y
2 participants