0

I am trying to compress and reconstruct an image but facing problems with the data type of the compressed image pixel values which are of float64 and therefore, when I am trying to retrieve the pixel values from the compressed image , reconstruction is poor because on reading the pixel values corresponding to compressed image, the pixel value array elements are converted to uint8 type, thus leading to loss in the pixel data on automatic conversion from float to uint8. I want to take dwt of the image, store the dwt coefficients as an image (as images are of the lesser size as compared to pixel values stored in a file), and then retrieve the pixel values from the coefficient images, and thus reconstructing the image on taking inverse wavelet of the coefficients arrray obtained on reading the coefficient array. I am implementing the complete system in OpenCV python.

Marcus Müller
  • 30,525
  • 4
  • 34
  • 58
  • Do you mean that the float64 data type has different range than the usual uint8 triplet you would expect, or something else (?) – A_A Jun 22 '18 at 16:18
  • yes, I am writing a separate code for decomposition of the compressed image, there when I am reading the compressed image for retrieving the pixel values, the pixel values are transformed to uint8, for instance, if the compressed image had pixel values like 2.335465 then I am not getting a correct corresponding uint8 value instead most of the values are transformed to 255, which I think are not correct. – Arpit Jadon Jun 23 '18 at 07:45
  • Can you please edit the question with a little bit more information on how you handle the conversion between the data types and their different ranges? – A_A Jun 23 '18 at 08:00
  • I have updated the question – Arpit Jadon Jun 23 '18 at 11:10
  • Thank you. I am sorry but I still don't understand how you handle the conversion currently. float64 has an enormous range, uint8's range is 0-255. The possible reason why you don't "see" something that resembles an image is because you are not handling the conversion properly. The rest of the description of why an image might be smaller (?) is also unclear. Are you following specific publications outlining what you are trying to implement? – A_A Jun 23 '18 at 21:08
  • Yes, I also think that I am not handling the conversion right. The image that I saved was having float64 pixel values but when whenever we read an image, pixel values are automatically converted to uint8. But I want my float64 pixel values back. On using np.float64() function, I think I am not getting the replica of the float64 pixel values which I had earlier in the array before saving it as an image. So, that's the problem I want those float64 pixel values back on reading the image. – Arpit Jadon Jun 24 '18 at 04:23
  • Just to help others who are looking for an answer to this or a similar problem...Normalizing the pixel values to 0-255 after compression will solve the problem. – Arpit Jadon Jul 28 '18 at 17:21

0 Answers0