0

I am working on image interpolation for which I am using bi-cubic interpolation to double the resolution of image in java using AffinedTransformOp.I used BufferedImage of TYPE_4BYTE_ABGR while doing up-scaling. When I tried to save back my upscale image using ImageIO.write then I found that openjdk does not support jpeg encoding for TYPE_4BYTE_ABGR so I converted this up-scaled image from TYPE_4BYTE_ABGR to TYPE_3BYTE_BGR. When I saved it in folder then found that the memory taken by this upscale image is way less(about half time) than the memory taken by original image.

So I assume that the original(input) image is represented by four channels ARGB while upscale(output) image is taking 3 channels RGB and that's why getting less memory.

Now my question is that should I use this conversion?
Is there some information that is getting lost?
Does quality of image remains same?

P.S: I've read from the documentation of ImageIO that when we convert ARGB to RGB than the alpha value gets premultiplied to RGB values and I think it should not affect the quality of the image.

user_3pij
  • 1,334
  • 11
  • 22
  • Was the input image also in jpeg? Jpeg doesn't support an alpha channel. It's more likely that you use a (much) lower quality when you write the image than what was used in the original image. – Erwin Bolwidt Jun 27 '19 at 07:42
  • 1
    Yes the original image is in jpeg. And I wrote back the image in jpeg. – user_3pij Jun 27 '19 at 07:43
  • You'l probably want to check out this question to find out how to set the compression/image quality level when you write out the JPEG: https://stackoverflow.com/questions/17108234/setting-jpg-compression-level-with-imageio-in-java – Erwin Bolwidt Jun 27 '19 at 07:52

1 Answers1

0

I solved my problem and hope to share my answer. Actually the type of my original image was Grayscale and the color space of my original image was grey (meaning only one channel with 8 bits) with quality of 90.
Problem arised when I used TYPE_4BYTE_ABGR for the upscaling instead of using TYPE_BYTE_GRAY. Secondly when you try to save this image in a file in jpeg format ImageIO.write uses compression of 75 by default so the image size will get small. You should use the compression factor which suits you or you should save it in PNG format.
You can view information about your image by using identify -verbos image.jpg in linux and can see the color space, image type and quality etc
You can check this post to see how to set your compression quality manually in ImageIO.

user_3pij
  • 1,334
  • 11
  • 22