Monochrome images from camera with removed CFA - which EXIF tags to change?

Hello,

recently I got a Pentax K-5II with the CFA removed so it takes only monochrome images. But the firmware of the camera of course isn’t aware of the missing CFA. So the RAW files in DNG format still contain the EXIF data as it would be in colour images.

Now I’d like to prepare the DNG (RAW) files from the camera so that processing software such as darktable (4.0.0 at the moment) recognises them as monochrome images. I know that I can create a preset in the demosaicing module which applies the “passthrough (monochrome)” workflow automatically if eg. the camera model in the EXIF data matches. That’s fine so far - unless there is a second camera of the same model…

So I’d like to alter the relevant EXIF data prior to the import in darktable, eg. with exiftool.
Despite I searched the web including the darktable reference documentation, consulted the DNG standard: https://helpx.adobe.com/content/dam/help/en/photoshop/pdf/dng_spec_1_6_0_0.pdf, tried to reproduce what “Monochrome2DNG” (Monochrome2DNG: the Missing Application for Сolor Сameras Сonverted to Black and White | FastRawViewer) did to an DNG file - nothing helpful. After that I asked the question in the https://darktable.club forum and got the advice to ask here.

Finally I tried to find the relevant code in the source of darktable and found something in exif.cc:

 if((format == 1) && (bps == 16) && (spp == 1) && (phi == 34892)) is_monochrome = TRUE;

I am not a programmer, so I might be completely wrong there.

I tried to alter the EXIF tags accordingly:

$ exiftool -a -u -ee3 -api RequestAll=3 -SubIFD1:BitsperSample="16 16 16" -SubIFD1:PhotometricInterpretation="Linear Raw" -SubIFD1:SamplesPerPixel=1 mono.DNG -o mono1.DNG

After that I imported the resulting “mono1.DNG” into darktable, but the demosaicing module still applied the “RCD” demosaicing method.

Did I overlook something important, like a part of some documentation?

Any help appreciated and many thanks in advance!

E.

I’d recommend against changing metadata in your raw file. Your raw file is an artifact from your shoot and should be preserved as-is.

Instead I’d setup a preset for your camera that changes the demoasic method to “passthru” and whatever other module settings you’d like to modify.

2 Likes

Thank you for our quick answer.
If the images from the camera would be colour images, I’d agree. But in the case of converted cameras such as mine, some of the EXIF data like the value “Color Filter Array” for “Photometric Interpretation” is just wrong - there isn’t a CFA anymore. That’s why I don’t see a reason for keeping that false information.

That’s my current workaround. :smiley:

E.

Yes I also have a converted camera, an IR converted Fuji. I have a preset that works well. I keep the original metadata because changing it risks damaging the file, as both exiftool and exiv2 make exceedingly clear.

Also you don’t know how darktable or other application you may use in the future will react to the changed tag.

If I were you, I’d continue with your “workaround,” to me that is the proper way to handle such things.

Thank you for mentioning exiv2 - I didn’t perceived it until now as a tool to work with EXIF data. I’ll have a look at it.

exiftool can create a copy of the original file, just with the altered EXIF data. That’s the way I’d work. And yes, the price to pay is more space consumption.

Thankfully darktable is Open Source, so I can find it out, if I’m able to understand the source code.
Obviously I have to improve my ability to understand the code first.

E.

1 Like

If your camera firmware offers a monochrome mode (for the jpegs normally) you could use that. Dt can check for that right now while importing and you can define a demosaic preset for monochrome & raw.

2 Likes

Thank you for your answer which is an eye opener for me.

I think I’ve got it now:
EXIF tags are just information. There is no way via the EXIF tags to force a software to process an image in a predefined specific manner. The processing pipeline is defined completely within the software and only in the software. If eg. darktable interprets specific EXIF tags (as I found out: the tags of the embedded JPEG image in the SubIFD1 part), other software like digiKam or RawTherapee may use other tags to recognise whether an image is monochrome or not.

So now the converted Pentax K-5 II is set to monochrome style and I defined a preset in the demosaicing module in darktable, which applies the demosaicing method “passthrough (monochrome)” automatically if the camera model matches “K-5 II” and the image is monochrome. That worked fine. The countercheck with a chromatic Olympus E-M10II and an image in monochrome style showed the expected behaviour: embedded JPEG is displayed monochrome, the RAW data is correctly demosaiced and displayed in colour as it should be.

That investigation was very educational. :slight_smile:

E.

1 Like

BTW, who converted the camera? Would you recommend the service?

You could use that - I do it too - to define presets for filmic or others that better fit for monochromes.

1 Like

Disclaimer: I’m just a satisfied customer of Mr. Grybauskas and have no other relationship to him.

The camera was converted by Mr. Grybauskas in Vilnius, Lithuania. He works very professionally and he also sells converted cameras eg. in the international Pentax forum.
Despite the process of removing the CFA is risky - as he told me before I sent my camera to him - I can recommend his service. He has a good reputation and I can corroborate that this reputation is well earned.

E.

Correct!

For demosaicing raw images the software needs the CFA layout and the image dimensions from the metadata. Strictly speaking, the image dimensions are needed to display or work on any image. A bit pedantic, but only a bit… :laughing:

Edit: Oh, the PhotometricInterpretation tag is needed to distinguish raw mosaics from RGB. Very important with DNGs, which can contain either.

Edit1: PhotometricInterpretation=1 is what you’d need to properly code your monochrome images. Okay, I’m done now…

1 Like