Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:

Global sobel:

For comparison, here are both the horizontal and vertical sobel:
Time
As a oneshot (so not very reliable but that gives an idea):
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