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

compare image data #1807

Merged
merged 5 commits into from
Aug 15, 2023
Merged

compare image data #1807

merged 5 commits into from
Aug 15, 2023

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Aug 15, 2023

Instead of comparing the encoded images, parse the image data and compare the pixel values; this way we can allow a small (imperceptible) amount of visual error across architectures.

@mbostock mbostock marked this pull request as ready for review August 15, 2023 18:32
@mbostock mbostock changed the title re-encode image data compare image data Aug 15, 2023
@mbostock mbostock requested a review from Fil August 15, 2023 18:55
Copy link
Contributor

@Fil Fil left a comment

Choose a reason for hiding this comment

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

Excellent! I feel that the thresholds are very generous — how much error did you notice in practice?

@mbostock
Copy link
Member Author

In the opacityLegendColor example, which has 256 pixels (1,024 RGBA values), I found:

  • 47 values with any error
  • 14 values with an error of at least 2
  • 6 values with an error of at least 3
  • 2 values with an error of at least 4
  • no values with an error of more than 4
  • a mean error of 0.0673828125
  • 95% of pixels had no error
  • 96% of pixels had 1 or less error
  • 99% of pixels had 2 or less error

We could probably reduce the max error threshold slightly, but that is the noisiest since it can be affected by a single value. I think the other ones are already tight.

@mbostock mbostock merged commit b16a2be into main Aug 15, 2023
1 check passed
@mbostock mbostock deleted the mbostock/normalize-image-date branch August 15, 2023 19:11
@tophtucker
Copy link
Contributor

😻

2023-08-15 - plot tests passing

Fil pushed a commit that referenced this pull request Aug 21, 2023
* re-encode image data

* adopt canvas.toDataURL

* compare image data

* parallelize getImageData

* statistical image comparison
chaichontat pushed a commit to chaichontat/plot that referenced this pull request Jan 14, 2024
* re-encode image data

* adopt canvas.toDataURL

* compare image data

* parallelize getImageData

* statistical image comparison
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