• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Image IO problem

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

The following code reads a jpg image into an int array and writes the same pixel array without any modification to a jpg file



here i was expecting the quality and size of the output image same as of input image
but the quality of image is poor and the size is also less than that of input image.why is it so,when im not modifing the pixels of input img?
secondly,if i am changing the output image format to bmp(#2),the output image retains the quality of original one but size of output image becomes very large.

is there any way by which i can read and write the same image without any modification and get the output image of same quality and size as that of input image??


Regards,
Ravi
[ April 16, 2008: Message edited by: Ravindra Harige ]
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ravindra Harige:
Sorry,i mis-edited my last post.please ignore the last(repeated) paragraph.

thanks,
Ravi



You can edit ( including delete ) the message using an icon at the top of the post that looks like a pencil and paper.

[ UD: removed parts that had nothing to do with the question, and which might be cause for confusion ]
[ April 16, 2008: Message edited by: Ulf Dittmer ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JPEG format contains an advanced compression technique, which can makes images comparatively smaller than other formats (like BMP).

JPEG also has built-in quality settings that allow you to trade off file size for image quality. My guess would be that the default quality is not set to 100% (which would preserve the image in full). This code example shows how to use the ImageIO JPEG quality settings.
 
Ravi Ramnath
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf for pointing to the sample code.It writes the jpg file with same quality as of the original one (given compressionquality=0.0f).
but the integer pixel array of input file and output file differed when compared.

Actually,i wanted to
- read a jpg image into integer pixel array,
- write it to a jpg file without modifying pixel array
(such that output jpg file preserves the quality of input image and the size of output image is almost same as input file)
- again read the output image into pixel array
such that pixelarray(input_image) = pixelarray(output_image)

I am stuck on the last point.please help me out.

thanks,
Ravindra
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if that's possible; I think it isn't. JPEG is not a good format to use if you need to preserve pixel values. PNG is a better choice.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic