Re:Pillow-SIMD – Fast, production-ready image resize for x86
by mark-r on Friday July 07, 2017 @12:17AM
(#14716002)
Generating the factors dynamically isn't that hard. I implemented this algorithm back in the late 80's, and it had acceptable performance on a 25 MHz processor. Not only that but it had to do some distortion correction at the same time, so it was applying a different resize factor to every single line of the image. All with integer math.
Re:Pillow-SIMD – Fast, production-ready image resize for x86
by dahart on Friday July 07, 2017 @12:33AM
(#14716080)
Oh absolutely, I believe it, and I looked at @pedrocr's code. Very simple. But, a static box filter is even simpler.
Did you call it pixel mixing in the 80s? I've been doing image resizing for decades and never heard the term before tonight. I have implemented a couple of very similar algorithms to pixel mixing for CG films, once in a shader and once for antialiasing in a particle renderer.
Re:Pillow-SIMD – Fast, production-ready image resize for x86
by pedrocr on Friday July 07, 2017 @02:43PM
(#14720935)
>Did you call it pixel mixing in the 80s? I've been doing image resizing for decades and never heard the term before tonight.
I hadn't either. I just searched for a name for the algorithm I also came up with independently. The imagemagick docs had a particularly comprehensive discussion on resizing options and linked this page with this naming for the algorithm.
Re:Pillow-SIMD – Fast, production-ready image resize for x86
by mark-r on Friday July 07, 2017 @12:53AM
(#14716169)
I didn't have a name for it back then. I developed it independently so there was no existing reference for the name.
I worked on a major application years later that was calling it bilinear, until someone pointed out that bilinear had a completely different definition. I think we renamed it Weighted Average.
Faster depends on implementation details, but from the looks of it, to implement pixel mixing, you either have to generate your convolution kernel dynamically, or chop some source pixels into potentially 4 separate pieces? I would guess that it's easier to optimize a static kernel than to make a dynamic kernel faster than a static one. But I'm not entirely sure how fast pixel mixing could be made.
> It can be confused with a box filter or with linear interpolation, but it is not the same as either of them... [pixel mixing] Treats pixels as if they were little squares, which gets on some experts’ nerves.
This is a funny way of putting it. Pixel mixing is definitely using a box filter, just slightly differently than what people normally call box filter resizing. The author even says that later: "Another way to think of pixel mixing is as the integral of a nearest-neighbor function." Pixel mixing as described here is clipping the source image under the box filter rather than using a static kernel. The reason that a box filter isn't ideal is well understood. It's because the filter itself has high frequencies in it. This is the reason that the quality of pixel mixing resizes is low.
One of the benefits of a box filter is that applied multiple times, it becomes a better filter, and approximates a Gaussian after several times. I'm not sure but I would bet that clipping to the exact filter boundary actually prevents you from being able to do that with pixel mixing.