-
-
Notifications
You must be signed in to change notification settings - Fork 888
Not using quantization for Grey8 images when encoding 8Bit Bitmaps #909
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
Not using quantization for Grey8 images when encoding 8Bit Bitmaps #909
Conversation
Codecov Report
@@ Coverage Diff @@
## master #909 +/- ##
==========================================
+ Coverage 89.24% 89.25% +<.01%
==========================================
Files 1083 1083
Lines 47394 47442 +48
Branches 3293 3299 +6
==========================================
+ Hits 42299 42345 +46
Misses 4393 4393
- Partials 702 704 +2
Continue to review full report at Codecov.
|
|
I would like to add two additional test cases to test the quantization of a 32 bit color image to a 8 bit color image see:#10. This may require again comparing with a tolerance, because quantization could produce different results on .net462 vs netcoreapp2.1, but i think thats still better than not testing it. Or is it maybe enough that the quantization processors already are tested? |
|
@brianpopow I've merged those images for you 👍 |
|
@brianpopow |
|
@antonfirsov yes this time i can actually reproduce it locally. I will try to see if i can find out why this is happening. |
|
@antonfirsov it is, what you already said previously, the quantization produces slightly different results on net472 than on netcore. It looks to me as if the quantized colors are in many case (not all) identical in net472 and netcore, but they appear in a slightly different position in the palette. For example: Here is a zip file containing the quantized palette of net472 and netcore21. Also a comparison of which pixels differ.
|
… with net472 and netcore
|
There’s a lot of floating point calculation going on in Wu which will be causing the issue. If the output looks ok I’m good with dropping the tests. |
|
My tecnhique is to check |
|
@antonfirsov ok that makes sense, i will do that. |
| for (int y = image.Height - 1; y >= 0; y--) | ||
| { | ||
| Span<TPixel> inputPixelRow = image.GetPixelRowSpan(y); | ||
| PixelOperations<TPixel>.Instance.ToGray8Bytes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we replace this with inputPixelRow.AsBytes().CopyTo(outputPixelRow) here? Seems more explanatory about our intention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can not find AsBytes(), is that an extension method im missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, it's MemoryMarshal.AsBytes(spanOfThings) 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have changed that, please check it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good, thanks!
…antizeOnGray8 # Conflicts: # tests/ImageSharp.Tests/Drawing/DrawImageTests.cs
|
@antonfirsov i was unsure about DrawImageTests.cs while resolving the merge conflict: should this tests be removed or should we keep it? |
|
DrawImageTests should be kept in it's original form, strange you had a conflict here. Can you easily revert all changes on that class? Or just replace the code in your file with the code on current master? |
|
after i integrated the master branch the DrawImageTests.cs was named: DrawImageTest.cs (without an s), so the tests failed because the reference images could not be found. I just changed that to fix the failing tests. |
|
All good now! Thanks a lot for taking the time, and sorry for the conflicts! |
…izeOnGray8 Not using quantization for Grey8 images when encoding 8Bit Bitmaps
Prerequisites
Description
The title already says it: When its an Gray8 image, color quantization is actually not needed.