To expand on Terry's post about dcrawps, the following is a little primer on dcrawps.
Here is how I split a pixel-shifted DNG. This would be for those who would like to layer images and paint over pixels themselves:
$ dcrawps -s all -T -4 -w K1A_2688.DNG (-s all = split all constituent layers into separate images; -T = write out in tiff format; -4 = write out in linear 16-bit, i.e. no gamma curve, no brightness changes; -w = use camera WB).
And I get K1A_2688_0.tiff (bayer filtered), K1A_2688_1.tiff (R data), K1A_2688_2.tiff (G data), K1A_2688_3.tiff (B data)
Here is an example of how dcrawps is used for motion correction of a pixel shifted image. It has two abilities: motion detection and motion correction.
Motion detection -
dcrawps -X -G 1 -T -4 -w K1A_2685.DNG
The -X option highlights motion-detected pixels in magenta.
The -G option sets the threshold (in percent) for detecting differences between the two green channel pixels (a lower threshold will have more pixels highlighted).
The -T option produces a tiff file.
The -4 option produces a linear 16-bit tiff (no gamma curve applied, no brightening done).
The -w option uses the white balance settings from the camera.
Here is an image resulting from the above command. Prepare to be shocked. A 1% difference can be exceeded just by the effects of air motion:
This was taken in the morning when the mountain breezes were just getting started with slight swaying of the lupines and rustling of the aspen leaves.
Here is the command setting a 20% green channel threshold to be exceeded:
dcrawps -X -G 20 -T -4 -w K1A_2685.DNG
And the resulting image:
That is more like it. Only the vegetation is showing some movement. So replacing the marked pixels should result in a motion corrected image.
Motion repair -
dcrawps motion correction works by comparing the bayer filtered green channel to the 3rd G data image. If any pixel differences in the G channel exceed the threshold you gave in the command, those pixels are replaced by the ones from the bayer filtered image. However, the syntax is different than what one would intuitively think. You need to think about what percentage of the pixels you do not want replaced for the repair command. So to keep 80% of the image pixels (i.e., replace 20% of the pixels), the command would be:
dcrawps -G 80 -T -4 -w K1A_2685.DNG
And you get this:
You will notice that there is still a tiny amount of movement visible in the lupines. Setting the repair threshold to 70 takes care of that.
dcrawps -G 70 -T -4 -w K1A_2685.DNG
There is always some "slop" with the motion correction using dcrawps and trial and error is the best way to get the best results. Note that since I asked for a linear tiff, the image will be flat as a board and will need some tender loving care in post to bring it back to life.
I am nowhere saying that this method is superior to the motion correction achieved by DCU or any of the other programs out there that are able to decipher Pentax's pixel shifted images. It is just one more tool in the arsenal. Personally, I think the motion detection is worth the price of admission (free).
- Jack