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

Add (P)SNR, RMSE, and MAE #536

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add (P)SNR, RMSE, and MAE #536

wants to merge 4 commits into from

Conversation

stelfrich
Copy link
Member

Adds implementations for (peak) signal-to-noise ratio, root mean square error, and mean absolute error of two images (a reference and a test image).

Closes #521.

@stelfrich stelfrich requested a review from imagejan March 8, 2018 09:12
Copy link
Member

@imagejan imagejan left a comment

Choose a reason for hiding this comment

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

I tested this (on Windows) and it works as advertised, although I currently don't have enough understanding of the underlying concept to verify the exact numbers (so I trust the unit tests).

Some minor comments (that don't have to be part of this PR):

  • Would it make sense to make the out parameter optional, or to add Function signatures in addition to these Computer ones? Or is it wrong to provide a default output type like e.g. DoubleType?
  • From the op signature (e.g. in the Op Finder) it wasn't clear to me which of in1 and in2 is the reference and which the test image. Maybe we can rename them to reference and test?
  • Currently, these ops live in the image namespace together with such diverse things as ascii, distancetransform, and histogram. I think this was discussed already, but would it make sense to create nested namespaces inside image, or to split them into other namespaces instead?

Before merging, I suggest we squash all three commits and rebase onto current master.

@stelfrich
Copy link
Member Author

Thanks for taking some time to look at his @imagejan!

Would it make sense to make the out parameter optional, or to add Function signatures in addition to these Computer ones? Or is it wrong to provide a default output type like e.g. DoubleType?

Totally makes sense, especially since the type parameter for the output is obsolete anyway (that was a relic from when I was trying to do all computations directly on the RealType objects).

From the op signature (e.g. in the Op Finder) it wasn't clear to me which of in1 and in2 is the reference and which the test image. Maybe we can rename them to reference and test?

This would be amazing, though I fear that the information used in the Op Finder is extracted from the inherited instance variables in1 and in2. I did at least change the names in the namespace methods.

Currently, these ops live in the image namespace together with such diverse things as ascii, distancetransform, and histogram. I think this was discussed already, but would it make sense to create nested namespaces inside image, or to split them into other namespaces instead?

Good point as well, but definitely something we can discuss afterward.

@stelfrich stelfrich force-pushed the snr branch 2 times, most recently from 61119d0 to c888b0a Compare March 29, 2018 08:55
@stelfrich
Copy link
Member Author

This would be amazing, though I fear that the information used in the Op Finder is extracted from the inherited instance variables in1 and in2. I did at least change the names in the namespace methods.

I had a quick chat with @ctrueden about this and scijava-ops will allow for class-based @Parameter annotations for in1 and in2. See ParameterTest.java#L197-L198 for an example of how it could look like.

stelfrich and others added 2 commits June 5, 2018 14:55
Adds various metrics for comparing reference images with (noisy) test
images.
Maven will only execute unit tests whose class name begins or ends with
"Test".
final IterableInterval<T> reference, final IterableInterval<T> test)
{
final DoubleType result = (DoubleType) ops().run(
net.imagej.ops.image.quality.DefaultMAE.class, out, reference, test);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be ops().run(Ops.Image.MAE.class, out, reference, test);. That way if someone creates a more specific/specialized MAE op, it could be matched. Otherwise, DefaultMAE would always be used.

final IterableInterval<T> reference, final IterableInterval<T> test)
{
final DoubleType result = (DoubleType) ops().run(
net.imagej.ops.image.quality.DefaultMAE.class, reference, test);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

final IterableInterval<T> reference, final IterableInterval<T> test)
{
final DoubleType result = (DoubleType) ops().run(
net.imagej.ops.image.quality.DefaultPSNR.class, out, reference, test);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be ops().run(Ops.Image.PSNR.class, out, reference, test), and same idea for the remaining namespace methods you added. They should be run(...) with an interface not a concrete implementation.

@Test
public void testPSNR() {
final DoubleType psnr = new DoubleType();
ops.image().psnr(psnr, reference, test);
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than using the namespace methods in tests, you should use ops.run(net.imagej.ops.image.quality.DefaultPSNR.class, psnr, reference, test);. This will ensure that this unit test always tests the DefaultPSNR and not some other PSNR op.

Same idea for your other tests.

@awalter17
Copy link
Contributor

@stelfrich Thanks for your work on this! I modified the name of your unit tests, so maven runs them now. And have suggested a few minor edits.

I had a quick chat with @ctrueden about this and scijava-ops will allow for class-based @Parameter annotations for in1 and in2. See ParameterTest.java#L197-L198 for an example of how it could look like.

I don't know if we want to wait until this is resolved before merging this, or if we're OK with merging this without? Basically it is to rename/annotate in1 and in2 right? I think for now renaming them in the namespace methods is sufficient. Thoughts? @ctrueden? @imagejan?

I think after the minor edits I suggested, this should be good to merge. But if you object please let me know. 😺

@ctrueden
Copy link
Member

ctrueden commented Jun 6, 2018

I don't know if we want to wait until this is resolved before merging this, or if we're OK with merging this without?

If we wait, we will be waiting for at least a few months. I'd say we should merge before that. Normally, I like the namespace method variable names to match the parameter fields, but in the case of in/in1/in2/out I am OK with naming them differently, with the idea that when Ops migrates to the new SJC framework, the names from the namespace methods will serve as a hint for what to name the new @Parameter declarations.

@stelfrich
Copy link
Member Author

Thanks for your comments, @awalter17! They have been addressed in two separate commits.

I think after the minor edits I suggested, this should be good to merge.

I'd say we should merge before that.

Feel free to merge! 👍

@ctrueden ctrueden added the to do label Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants