RAW data restructure for Infrared photograpy? - page 2 - RAW Shooting and Processing - CHDK Forum

RAW data restructure for Infrared photograpy?

  • 20 Replies
  • 11811 Views
Re: RAW data restructure for Infrared photograpy?
« Reply #10 on: 09 / August / 2013, 14:04:52 »
Advertisements

If you can compile your own version of CHDK then you might be able to simply change the setting that determines the Bayer sensor pattern in the DNG file.


Just getting back on this.  Thanks a LOT philmoz for building this for me.  It does work PERFECTLY and the output is as expected!  It took me a little while to make some new lightroom DNG color profiles to allow me to adjust the white balance the opposite way of the original, but now that I have that figured out, I am able to keep the file as a DNG and work on it!   This is the best solution for my IR converted canon S5is.   

The downside of using a custom build is that if you ever want to update, you need someone to make a new custom build for you. Or learn how to do it yourself.

I would like to learn how to do the build so I can keep up with future versions... could someone point me in the right direction on what I need to do this?    Philmoz, could you share the modified source code so I can see what you changed?  Since it works so well there's little point in me thrashing around in there trying to figure it out.  This is beyond my experience with CHDK.. I've written a few little scripts for it but thats about all.

Thanks reyalp for the explanation on the cfapattern tag and the suggestions on running in a batch file.  I'm going to try your hackcfa program next and see what I can do with my existing photos.

Re: RAW data restructure for Infrared photograpy?
« Reply #11 on: 09 / August / 2013, 14:27:43 »
The attached lua script can be used with chdkptp to change the cfa tag on existing DNG files.

Put the hackcfa.lua file in the directory with the other chdkptp lua files, and then enter the following in the chdkptp console
Code: [Select]
!require'hackcfa';hackcfa('input.dng','output.dng',0x01020001)
where input.dng is the name of the existing dng you want ot change, and output.dng is the name you want the modified file to be saved under. You could enter other numbers for the final parameter.

This may be more convenient than running special chdk build


I'm trying to get this to work, but I must be doing something wrong..   My input file is named "3.dng"  and I put it just in the same folder where chdkptp.exe is... I also tried putting it in the lua directory.. and I've also tried typing in the full path where it is.. here's what I get when I try to run it:


> !require'hackcfa';hackcfa('3.dng','3out.dng',0x01020001)
error: call failed:C:\temp\lua\hackcfa.lua:5: error 3.dng: No such file or directory loading input
stack traceback:
   [C]: in function 'error'
   C:\temp\lua\hackcfa.lua:5: in function 'hackcfa'
   [string "require'hackcfa';hackcfa('3.dng','3out.dng'..."]:1: in main chunk
   [C]: in function 'xpcall'
   C:\temp\lua\cli.lua:378: in function <C:\temp\lua\cli.lua:375>
   (tail call): ?
   (tail call): ?
   [C]: in function 'xpcall'
   C:\temp\lua\cli.lua:239: in function 'execute'
   C:\temp\lua\gui.lua:659: in function <C:\temp\lua\gui.lua:656>
   (tail call): ?
   [C]: in function 'MainLoop'
   C:\temp\lua\gui.lua:681: in function <C:\temp\lua\gui.lua:667>
   (tail call): ?
   C:\temp\lua\main.lua:227: in main chunk
   [C]: in function 'require'
   [string "require('main')"]:1: in main chunk



am I missing something here?   do I need my camera plugged in to get this to work?

Re: RAW data restructure for Infrared photograpy?
« Reply #12 on: 09 / August / 2013, 15:09:30 »
DNG files must have a CFAPattern tag, but it is in the DNG image IFD, not in the EXIF IFD. A tool like exiftool should show it to you. In fact, I expect exiftool would let you modify it was well.

I downloaded exiftool and sure enough it does show the CFAPattern tags..

for my canon S5 it is:
CFA Pattern: [Green,Blue][Red,Green]

for my Sony a65 it is:
CFA Pattern 2: 0 1 1 2

I've been trying to figure out how I could use exiftool to just change these... but I'm having difficulty figuring out the correct command and syntax for that.  I see there is a -TAG operation to write a new value to a tag, but I can't seem to find an example on how to properly use this


*

Offline reyalp

  • ******
  • 14128
Re: RAW data restructure for Infrared photograpy?
« Reply #13 on: 09 / August / 2013, 16:01:22 »
I'm trying to get this to work, but I must be doing something wrong..   My input file is named "3.dng"  and I put it just in the same folder where chdkptp.exe is... I also tried putting it in the lua directory.. and I've also tried typing in the full path where it is.. here's what I get when I try to run it:
Code: [Select]
> !require'hackcfa';hackcfa('3.dng','3out.dng',0x01020001)
error: call failed:C:\temp\lua\hackcfa.lua:5: error 3.dng: No such file or directory loading input

am I missing something here?   do I need my camera plugged in to get this to work?
No, you do not need the camera plugged in.

The error means it could find the file. The you don't put a path on the file, it will expect to find it in the current directory. If you ran chdkptp from the command prompt, that will be what ever directory you were in when you ran it.

Specifying the full path should work, but \ is an escape character, so you should either use / instead, or double the backslashes.
Don't forget what the H stands for.

Re: RAW data restructure for Infrared photograpy?
« Reply #14 on: 09 / August / 2013, 16:06:32 »
I just noticed both cameras have both CFA Pattern and CFA Pattern 2

Canon S5
CFA Pattern: [Green,Blue][Red,Green]
CFA Pattern 2: 1 2 0 1

Sony A65
CFA Pattern: [Red,Green][Green,Blue]
CFA Pattern 2: 0 1 1 2

Do I need to change both of these?   I still can't figure out how in the world to use ExifTool to change these.. I think part of the problem is the tags have spaces, and when it hits the space it thinks I am giving an additonal parameter.  I've tried it with _  instead of space, but still just get errors... or it says it works, but then it doesn't make any changes

*

Offline reyalp

  • ******
  • 14128
Re: RAW data restructure for Infrared photograpy?
« Reply #15 on: 09 / August / 2013, 16:17:09 »
Do I need to change both of these?
I suspect these are just showing you the same information in human friendly and numeric formats. CHDK DNGs only have one CFA pattern tag.

The tag value itself is a sequence of 1 byte integers. The actual tag name is CFAPattern. I don't know off hand how you would set it using exiftool.
Don't forget what the H stands for.

Re: RAW data restructure for Infrared photograpy?
« Reply #16 on: 09 / August / 2013, 17:26:29 »
The error means it could find the file. The you don't put a path on the file, it will expect to find it in the current directory. If you ran chdkptp from the command prompt, that will be what ever directory you were in when you ran it.

Specifying the full path should work, but \ is an escape character, so you should either use / instead, or double the backslashes.

Ok, I got it to work with a DNG file created by CHDK, and I get

> !require'hackcfa';hackcfa('s5.dng','s5out.dng',0x01020001)
s5.dng old cfa=0x01000201
s5out.dng new cfa=0x01020001

Also, I'm happy to say this has the desired effect on the image as well!


but previously I was using an older version of chdk that only saved raw files, not DNGs so then I was using "dng4ps2" to convert them to dng,  these files give me the following when I try this:

>  !require'hackcfa';hackcfa('52.dng','52out.dng',0x01020001)
error: call failed:C:\temp\lua\dng.lua:228: ifd outside of data
stack traceback:
   [C]: in function 'error'
   C:\temp\lua\dng.lua:228: in function 'bind_ifds'
   C:\temp\lua\dng.lua:246: in function 'bind_ifds'
   C:\temp\lua\dng.lua:370: in function <C:\temp\lua\dng.lua:357>
   (tail call): ?
   C:\temp\lua\hackcfa.lua:3: in function 'hackcfa'
   [string "require'hackcfa';hackcfa('52.dng','52out.dn..."]:1: in main chunk
   [C]: in function 'xpcall'
   C:\temp\lua\cli.lua:378: in function <C:\temp\lua\cli.lua:375>
   (tail call): ?
   ...
   C:\temp\lua\cli.lua:239: in function 'execute'
   C:\temp\lua\gui.lua:659: in function 'action'
   C:\temp\lua\gui.lua:626: in function <C:\temp\lua\gui.lua:624>
   (tail call): ?
   [C]: in function 'MainLoop'
   C:\temp\lua\gui.lua:681: in function <C:\temp\lua\gui.lua:667>
   (tail call): ?
   C:\temp\lua\main.lua:227: in main chunk
   [C]: in function 'require'
   [string "require('main')"]:1: in main chunk


and my sony files give me this:
>  !require'hackcfa';hackcfa('sony.dng','sony_out.dng',0x01020001)
error: call failed:C:\temp\lua\dng.lua:246: attempt to perform arithmetic on field 'elsize' (a nil value)
stack traceback:
   C:\temp\lua\dng.lua:246: in function 'bind_ifds'
   C:\temp\lua\dng.lua:246: in function 'bind_ifds'
   C:\temp\lua\dng.lua:370: in function <C:\temp\lua\dng.lua:357>
   (tail call): ?
   C:\temp\lua\hackcfa.lua:3: in function 'hackcfa'
   [string "require'hackcfa';hackcfa('sony.dng','sony_o..."]:1: in main chunk
   [C]: in function 'xpcall'
   C:\temp\lua\cli.lua:378: in function <C:\temp\lua\cli.lua:375>
   (tail call): ?
   (tail call): ?
   [C]: in function 'xpcall'
   C:\temp\lua\cli.lua:239: in function 'execute'
   C:\temp\lua\gui.lua:659: in function <C:\temp\lua\gui.lua:656>
   (tail call): ?
   [C]: in function 'MainLoop'
   C:\temp\lua\gui.lua:681: in function <C:\temp\lua\gui.lua:667>
   (tail call): ?
   C:\temp\lua\main.lua:227: in main chunk
   [C]: in function 'require'
   [string "require('main')"]:1: in main chunk

I tried looking at hackcfa.lua to see how it worked, but it went completely over my head!  Any ideas whats going on with these other DNG files?

*

Offline reyalp

  • ******
  • 14128
Re: RAW data restructure for Infrared photograpy?
« Reply #17 on: 09 / August / 2013, 17:37:07 »
but previously I was using an older version of chdk that only saved raw files, not DNGs so then I was using "dng4ps2" to convert them to dng,  these files give me the following when I try this:
...
I tried looking at hackcfa.lua to see how it worked, but it went completely over my head!  Any ideas whats going on with these other DNG files?
The DNG code currently in chdkptp is really only intended to be used with CHDK DNGs, and is quite unfinished. So I'm not surprised it fails on other DNGs. If you can post examples of those files I'd be interested to see what exactly goes wrong, but I don't promise to fix it.

The actual dng code is in dng.lua if you want to look at it.
Don't forget what the H stands for.

Re: RAW data restructure for Infrared photograpy?
« Reply #18 on: 09 / August / 2013, 18:25:50 »

The DNG code currently in chdkptp is really only intended to be used with CHDK DNGs, and is quite unfinished. So I'm not surprised it fails on other DNGs. If you can post examples of those files I'd be interested to see what exactly goes wrong, but I don't promise to fix it.

That makes sense, I tried to attach one here, but they are just too large.  The Sony DNG's are the ones I would like to get to work but they are 30MB

Re: RAW data restructure for Infrared photograpy?
« Reply #19 on: 09 / August / 2013, 19:30:00 »
Update:  I managed to get this working!  if I use the following command with Exiftool:

exiftool -exif:cfapattern2="2 1 1 0" file.dng   

it replaces the original tag of 0 1 1 2 with the new one 2 1 1 0 and when I got back into lightroom and tell it to discard the preview, the photo comes up with red and blue reversed,  just what I wanted to do!  I did not really think it would be as easy as changing one tag in the file.. I was thinking I would have to read in all the data and write it back out in the other order,  so Thank you to everyone for helping me with this!!  The modified CHDK file is the best solution for my canon S5is, as I don't even have to do anything, and the exiftool for other DNGs will work great.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal