How to specify behavior of Java BufferedImage resize: need min for pixel rows instead of averaging

Posted by tucuxi on Stack Overflow See other posts from Stack Overflow or by tucuxi
Published on 2010-03-29T17:41:33Z Indexed on 2010/03/29 17:43 UTC
Read the original article Hit count: 573

I would like to resize a Java BufferedImage, making it smaller vertically but without using any type of averaging, so that if a pixel-row is "blank" (white) in the source image, there will be a white pixel-row in the corresponding position of the destination image: the "min" operation. The default algorithms (specified in getScaledInstance) do not allow me a fine-grained enough control. I would like to implement the following logic:

for each pixel row in the w-pixels wide destination image, d = pixel[w]
   find the corresponding j pixel rows of the source image, s[][] = pixel[j][w]
   write the new line of pixels, so that d[i] = min(s[j][i]) over all j, i

I have been reading on RescaleOp, but have not figured out how to implement this functionality -- it is admittedly a weird type of scaling. Can anyone provide me pointers on how to do this? In the worse case, I figure I can just reserve the destination ImageBuffer and copy the pixels following the pseudocode, but I was wondering if there is better way.

© Stack Overflow or respective owner

Related posts about java

Related posts about gui