Merged
Conversation
ImagingReduce1x2, ImagingReduce1x3, ImagingReduce2x1, ImagingReduce3x1
homm
commented
Dec 5, 2019
|
|
||
| return self._new(self.im.resize(size, resample, box)) | ||
|
|
||
| def reduce(self, factor, box=None): |
Member
Author
There was a problem hiding this comment.
The name of the operation and argument could be discussed.
Member
Author
There was a problem hiding this comment.
@python-pillow/pillow-team any objections to naming?
Member
There was a problem hiding this comment.
Well, I can't think of a better name :)
There was a problem hiding this comment.
thumbs up for the current naming!
v-atamanenko
left a comment
There was a problem hiding this comment.
I suggested some small corrections. On the whole, everything is well written :)
|
|
||
| return self._new(self.im.resize(size, resample, box)) | ||
|
|
||
| def reduce(self, factor, box=None): |
There was a problem hiding this comment.
thumbs up for the current naming!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is it
A new operation that reduces an image size in
N×Minteger times. Each pixel gets an average value ofN×Mpixels of the source image. WithN == MandN == {2, 4, 8}this operation perfectly match JPEG DCT Scaling. When the image width is divisible byNand image height is divisible byM, this operation is perfectly match.resize((im.width / N, im.height / M), Image.BOX).Why is it
This will be used in the next Pull request in
.resize()operation (through new argument) and in.thumbnail()by default. In a nutshell, it allows speed up resizing in times in some cases.Why not use resize with BOX filter?
Two reasons:
Nor image height is not divisible byM. This increases the error in the next steps.Why so much code?
The good news is you don't have to review it all. There are:
ImagingReduce1x2,ImagingReduce1x3,ImagingReduce2x1,ImagingReduce3x1,ImagingReduce2x2,ImagingReduce3x3,ImagingReduce4x4andImagingReduce5x5for predefined scales.ImagingReduce1xNandImagingReduceNx1for xscale == 1 and yscale == 1.ImagingReduceNxNfor any other scales.ImagingReduceCornersfor the last row and last column if any, which is shared across all scales.INT32andFLOAT32data types:ImagingReduceNxN_32bpcandImagingReduceCorners_32bpcrespectively.All of them are:
ImagingReduceNxNandImagingReduce2x2with very little changes in logic (more/less columns/rows).TestImageReduce.compare_reduce_with_reference) and error threshold only 1 tier per channel.So basically, all you need is to carefully check the tests.
Performance
bench_reduce.py
Reduce in x•y times, time in ms.