TwelveMonkeys
TwelveMonkeys copied to clipboard
Image position changes depending on the filter used with ResampleOp
The resulting image seems to move one pixel to right and down when resizing an image with ResampleOp's Lanczos filter. Because of this the right side and the bottom of the image look like that one row of pixels is cut off. The result does not look good with round images like I was using. Triangle filter does not result in the image moving like this. Example code and images below.
BufferedImage input = ImageIO.read(new File("original.png"));
BufferedImageOp resampler = new ResampleOp(50, 50, ResampleOp.FILTER_LANCZOS);
BufferedImage output = resampler.filter(input, null);
ImageIO.write(output, "png", new File("lanczos.png"));
Original:
Lanczos:
Triangle:
Hi vpmuli,
Thanks for reporting!
I'll try to look into it at some point. If you have time to dig a little bit more that would also be great. :-)
-- Harald K
I don't have the competence to check the algorithms themselves, but I made a test run using all the ResampleOp's filters. Point and quadratic filters behave like triangle and preserve the roundness of the image. All the other filters behave like Lanczos and result in an image that is less round. This makes sense as point, quadratic and triangle have special handling in the code. I don't know is this information at all useful, but it's all I'm able to do.
Thanks!
That will make the debugging a little easier at least! :-)
-- Harald K