What is the effect of storing a larger value in a grayscale png image?

懵懂的女人 提交于 2019-12-11 02:53:53

问题


I am trying to perform the DCT on an image with block size 8X8 in java. After performing DCT on the first block, I get the very first value as "372". After performing the DCT on the entire image, I wrote the values into a PNG-grayscale image.Values inside the image automatically changed. The grayscale image will not store the value greater than 255. What will happen to the value which is greater than 255 (for eg., 372) ?


回答1:


you can not get to original image after loss of information so you need to:

  1. perform DCT or what ever
  2. find min,max values from whole image
  3. change range so any pixel(x,y)=(255*(pixel(x,y)-min))/(max-min)
    • +/-1 or some if to clamp to the right range

After this you lose absolute values but the relative changes stays there

  • for some purposes is this enough
  • if you need to restore the original image
  • then you need to encode min,max values to the png somewhere
  • so add a dummy scanline(s) and encode min,max into first few pixels ...

restoration is then easy:

  1. read png image
  2. decode min,max
  3. restore original dynamic range pixel(x,y)=min+(((max-min)*pixel(x,y))/255)
    • +/-1 or some if to clamp to the right range
  4. perform IDCT or what ever


来源:https://stackoverflow.com/questions/31230588/what-is-the-effect-of-storing-a-larger-value-in-a-grayscale-png-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!