I am doing image processing in a scientific context. Whenever I need to save an image to the hard drive, I want to be able to reopen it at a later time and get exactly the data that I had before saving it. I exclusively use the PNG format, having always been under the impression that it is a lossless format. Is this always correct, provided I am not using the wrong bit-depth? Should encoder and decoder play no role at all? Specifically, the images I save
- are present as 2D numpy arrays
- have integer values from 0 to 255
- are encoded with the OpenCV
imwrite()
function, e.g.cv2.imwrite("image.png", array)
PGM
for greyscale orPPM
for colour - especially as OpenCV can read/write that without any library dependencies. Plus they also support 16-bit if higher colour resolution becomes necessary later... en.wikipedia.org/wiki/Netpbm_format – Flurriednumpy.save()
without having to rely on any additional image reader/writer :) – Waxwork