0

I have a code for drone image calibration and aligning from Micasense which works with 16bit images (Tiff). Alternatively the author of the code uses rawpy to read 12bit Tiff images(link: https://github.com/micasense/imageprocessing/issues/78). My images are all DNG 12bit but I cannot get rawpy to read it.

Screen shot of the code and error

However if i give it 16bit Tiff images it gives no error and the code runs.

I have tried reading about it but so far have not been able to find why rawpy cannot read my images. Am I missing something?

Alternatively, I thought of getting around the problem by converting my images into 16bit with gdal. Screen shot of code using gdal Which works fine, except that the metadata of the resulting 16bit Geotiff is less than original (using Exif to check this) and the image looks really dark. For my purposes I need the full metadata for calibrating the images later and also further processing on maps. So I need the whole metadata and a better scaling algorithm.

One idea is to copy the metadata of the original 12bit, then convert the image to 16bit (using scaling equation which gave good results) then find a way to greate a new GeoTiff using the ndarray and the metadata. I have not found an easy way to do this. Reading online Exif should be able to extract and save the metadata but then I need to find a way to combine 16bit scaled ndarray with metadata into geotiff. which I have not found yet. Is there a way to do this?

I would prefer using rawpy since its easier and also because I am trying to make a pipline with the code later. But if no solution then I would appreciate any hints on how to get the second idea working or any clever ways to get around the 12bit problem while keeping the metadata intact. Thank you.

here is an example of the 12bit image: https://tubcloud.tu-berlin.de/s/ba44SsEdNACgbM7

murph21
  • 1
  • 1
  • You said you are using 12-bit GeoTIFFs, yet appear to have shared a regular 8-bit JPEG? – Mark Setchell Nov 30 '22 at 12:21
  • @MarkSetchell, thank you for pointing that out. The tiff file was compressed while uploading. I added a link for cloud download. It should work now. – murph21 Dec 04 '22 at 12:42
  • rawpy is for reading RAW files, not TIFF files. Why are you surprised it doesn’t work? These are completely different file formats with different header structure and a different way of storing pixel data. – Cris Luengo Dec 04 '22 at 14:03
  • @Cris, you are right that rawpy is mostly used for NEF formats. Studying the source code of Micasense for image calibration, rawpy is also capable of reading DNG tiff 16bit images. I could also double check it directly giving a 16bit image to rawpy code above and it works. However according to Micasdense Codes Auther it should be able to read 12 bit (which are my images) and thats where rawpy is not working. – murph21 Dec 05 '22 at 13:44
  • rawpy does not read GeoTIFF files. You should probably try using [LibTIFF](https://github.com/pearu/pylibtiff) to read your files. – Cris Luengo Dec 06 '22 at 16:07
  • thanks for pointing that out. It led me to have a better look through the metadata and it turns out, images that rawpy could open were ".tiff" and not "Geotiff". At least now I am one step closer. :) – murph21 Dec 07 '22 at 11:33

0 Answers0