Skip to content

Add reference tests for image operations - #2877

Open
RunDevelopment wants to merge 9 commits into
image-rs:mainfrom
RunDevelopment:imageops-test
Open

RunDevelopment wants to merge 9 commits into
image-rs:mainfrom
RunDevelopment:imageops-test

Conversation

@RunDevelopment

Copy link
Copy Markdown
Member

I added reference tests for image operations. For now, I tested blur, fast_blur, invert, filter3x3, and huerotate.

Reference images currently capture the bugs of these functions as is:

@RunDevelopment

Copy link
Copy Markdown
Member Author

I forgot to mention: The cat image is CC0. I got it from here. The other two images I created myself.

@197g 197g left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the code nits, I'm not entirely sure. Should we bit-for-bit test these methods yet? In particular with fast_blur still having some outstanding discussion. Then again such tests should be in place before we add diverging implementation paths for arch-specific vectorization. Maybe you can lean in to either side of the argument?

Comment thread tests/imageops_reference.rs Resolved
Comment thread tests/imageops_reference.rs Resolved
@RunDevelopment

Copy link
Copy Markdown
Member Author

Should we bit-for-bit test these methods yet?

I would like to answer it like this: The right time to add such tests for these functions was years ago when they were added. The second best time is right now.

Suppose we change fast_blur. Having existing tests doesn't get in the way of that. If anything, they would show that the function did change and how. So I don't see what future changes should get in the way of testing.

Comment thread tests/imageops_reference.rs Resolved
for image in [bw_edge, noise] {
for sigma in [0.1, 0.5, 1.0, 1.5, 2.0, 5.0, 10.0, 50.0] {
trials.add(
format!("blur/{} blur sigma={sigma:.1}", image.name),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having filenames with spaces in them does make command line analysis of the files somewhat more awkward in general. (You cannot as easily do tricks like ls -l tests/imageops/blur/* | cut -w -f 5,9 | sort -n, which is a bit silly of an example.) But this is only a weak preference of mine.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If your tools can't handle valid file paths, you need better tools!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

@mstoeckl mstoeckl left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type of test is indeed very useful to have, and the test files are small. (Oxipng could only shave off 10 KiB in total, were you to run it.)

Pedantic testing philosophy note: these are technically snapshot/expect tests, not reference tests, because the test files aren't certainly fixed and correct, and the snapshot of behavior that we expect from them will change in the future. (edit: OK, I'm slightly wrong with this note :-)

This does need rebasing to fix a (trivial) merge conflict.

@RunDevelopment

Copy link
Copy Markdown
Member Author

Thanks for the review! I implemented your png suggestion.

Oxipng could only shave off 10 KiB in total, were you to run it.

Sorry, but that's not worth the effort now.

This branch has not been deployed

No deployments
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.

3 participants