RAW vs JPG

I write code to process DNG files for fun, which it is.

This was for fun,


This was fun, some people can use it.


Some people do cross-word puzzles for fun. I write Fortran for fun. I also get paid to write it, has paid all the bills for the last 45 years. But I do not get paid to write code to process files from digital cameras anymore, not since the 1980s.

and since this thread is posted in my DIY forum, figured a good place to show DIY DNG processing.

Also for fun- but you can't do it by just typing.
 
Last edited:
Heh.

I shoot in raw. For my M 240 I'll convert using the Adobe DCP file & use the custom tone curve. ART 1.20 for processing. Then either color or monochrome jpg output as desired for my final output, compressed for the web or as big as possible if I'm going to print. Works for me.

As for fun? Well, I find moments like this fun: not realizing this would be the last portrait of an old friend who would suddenly pass away within two weeks of this image... requiescat in pace, dryad:

L1000620-2.jpg
Leica M 240, 1937 Sonnar 50/2 modified for Nikon RF in an Amedeo adapter at f4, 1/2000, ISO200. 😀
 
Last edited:
JPG codecs have improved incredibly over the last 20 years, but don't we all remember the early days when you had mosquitos around detail in high contrast areas or recognizable blocks in areas with subtle color and brightness gradations such as skies? Although JPG now allows different quality settings (compression ratios), the underlying algorithm still works on a block by block basis. Especially in deep sky photography, where you're trying to dig out that last photon, you run into JPG's limits when increasing brightness and that background difference between blocks shows up.
 
Some brands makes excellent Jpegs out of camera. Often better than one can achieve without spending hours by the computer - provided you can even visualize what you want.

If one is happy with what the camera produces and only do cropping/resizing, there is little point in maintaining the clutter the heavy RAW files creates during future file management.
Just think of JPGs as slide film - make sure to get it right in camera and bracket if needed.

I shoot RAW+JPG routinely. I mostly use the JPGs but keep the RAWs “just in case” — but when uploading my backup files to the Cloud or transfer my entire backup to a new NAS I damn all those RAW files that I know I’ll never use.
The number of files just grows and grows and I’ll never get back to remove the unnecessary RAWs - they are like a curse.
 
I don't have any cats.
It is amusing to see this "debate" once again.

One of the reasons I capture to raw data is that it simplifies the shooting workflow. With raw capture, I only need to be mindful of ISO, exposure setting, focus, DoF, and framing, and I can leave white balance, contrast, color tone, etc etc, for later. They're better handled in post capture rendering anyway.

What you like to spend your time doing when you're making photos is your choice. 🙂

G
 
I only use a digital camera for digitizing my film negatives, not for taking pictures. That said, I shoot RAW + JPG for the digitizing. I do a quick Affinity Photo batch edit of the JPG files and use them with ContactPage Pro to generate a contact page of each roll. Then I throw the JPGs away and file the RAWs. When I find a photo on the contact page that I want to print I develop and edit the RAW file with Affinity Photo and print it with Epson Print Layout. No JPGs in the film to print workflow.
 
I only use a digital camera for digitizing my film negatives, not for taking pictures. That said, I shoot RAW + JPG for the digitizing. I do a quick Affinity Photo batch edit of the JPG files and use them with ContactPage Pro to generate a contact page of each roll. Then I throw the JPGs away and file the RAWs. When I find a photo on the contact page that I want to print I develop and edit the RAW file with Affinity Photo and print it with Epson Print Layout. No JPGs in the film to print workflow.
Hmm. Easy enough to do that entirely with the raw image files in Lightroom using a custom template in the Print module. I've not seen ContactPage Pro ... perhaps it automates the input in a convenient way? And can't take raw files? I'll have to look it up. Thx!

G
 
Custom DNG processor the the Leica M8, shooting RAW mode and using M8RAW2DNG to produce 14-bit pixels.

Use a Red or Orange filter to eliminate Blue from the image. The Blue channel gets IR only, about 5%~10% efficiency.
Use Histogram Equalization to boost the Blue and Green channels to the same level as Red.
14-bit pixels allow this kind of boost, the crappy 8-bit DNG would look like a contour map.

Swap channels using Tags. Lightroom understands the Tag swap, but most raw processors do not.
I1015873.jpgI1015897.jpgI1015899.jpgI1015902.jpg

SUBROUTINE COLORMOSAIC( IMAGE, COLUMNS, ROWS)
IMPLICIT NONE
C IMAGE GENERATED USING EQUALIZATION.
C 1) COMPUTE HISTOGRAM FOR ALL THREE CHANNELS.
C 2) INTEGRATE ARE UNDER HISTOGRAM AND NORMALIZE.
C 3) EQUALIZE BLUE AND GREEN TO RED.
INTEGER* 4 COLUMNS, ROWS
INTEGER* 2 IMAGE( COLUMNS, ROWS)
INTEGER* 4 COLUMN, ROW
C+++ BEGIN DOS I/O FUNCTION CODES.
INTEGER* 4 MAXPIXEL
PARAMETER ( MAXPIXEL= Z'3FFF')
C HISTOGRAM. STRONGEST WILL BE SET THE THE CHANNEL THAT IS THE FIRST TO
C REACH A THRESHOLD
REAL* 8 INTEGRATION_CUTOFF
PARAMETER ( INTEGRATION_CUTOFF= 0.95D0)
INTEGER* 4 BLUECHANNEL, GREENCHANNEL, REDCHANNEL
PARAMETER ( BLUECHANNEL= 1, GREENCHANNEL= 2, REDCHANNEL= 3)
INTEGER* 4 HISTOGRAM( 0: MAXPIXEL, 3)
INTEGER* 4 BLUEHIST( 0: MAXPIXEL), GREENHIST( 0: MAXPIXEL)
INTEGER* 4 REDHIST( 0: MAXPIXEL), CUTOFF( 3), STRONGEST
EQUIVALENCE ( HISTOGRAM( 0, BLUECHANNEL), BLUEHIST)
EQUIVALENCE ( HISTOGRAM( 0, GREENCHANNEL), GREENHIST)
EQUIVALENCE ( HISTOGRAM( 0, REDCHANNEL), REDHIST)
C INTEGRATE THE CURVE.
REAL* 8 IMAGETOTAL( 0: MAXPIXEL, 3)
REAL* 8 BLUETOTAL( 0: MAXPIXEL), GREENTOTAL( 0: MAXPIXEL)
REAL* 8 REDTOTAL( 0: MAXPIXEL)
EQUIVALENCE( IMAGETOTAL( 0, BLUECHANNEL), BLUETOTAL)
EQUIVALENCE( IMAGETOTAL( 0, GREENCHANNEL), GREENTOTAL)
EQUIVALENCE( IMAGETOTAL( 0, REDCHANNEL), REDTOTAL)
C MAP BLUE TOTALS TO GREEN TOTALS, SHOULD EQUALIZE THE HISTOGRAM.
REAL* 8 GAINCURVE( 0: MAXPIXEL)
INTEGER* 2 BYTES, HANDLE, STATUS, LENGTH, EXCHANGE
REAL* 8 SUMGREEN, SUMBLUE, AVERAGE_GREEN, AVERAGE_BLUE, GAIN
INTEGER* 4 PIXELS, MINBLUE, MINGREEN, MAXBLUE, MAXGREEN
INTEGER* 4 MINRED, MAXRED
INTEGER* 4 I, J, K, L
C FORTRAN METHOD OF GETTING LOW-ORDER WORD FROM A 32-BIT VALUE.
INTEGER* 4 BIGVALUE
INTEGER* 2 VALUE( 2)
C EXTERNALS.
INTEGER* 2 MOD
REAL* 8 DFLOAT, DMIN1
EQUIVALENCE ( BIGVALUE, VALUE)
WRITE( *, *) ' COLUMNS= ', COLUMNS, ', ROWS= ', ROWS
C EQUALIZE BLUE AND GREEN CHANNELS TO RED. CAN CHANGE LATER TO USE
C THE STONGEST CHANNEL.
SUMBLUE= 0.0D0
SUMGREEN= 0.0D0
MINBLUE= 32768
MINGREEN= 32768
MINRED= 32768
MAXGREEN= 0
MAXBLUE= 0
MAXRED= 0
PIXELS= COLUMNS* ROWS
C INITIALIZE ARRAYS.
DO 1 I= 0, MAXPIXEL
BLUEHIST( I)= 0
GREENHIST( I)= 0
REDHIST( I)= 0
BLUETOTAL( I)= 0.0D0
GREENTOTAL( I)= 0.0D0
REDTOTAL( I)= 0.0D0
GAINCURVE( I)= 0.0D0
1 CONTINUE
C COMPUTE HISTOGRAMS AND FIND MAX/MIN OF EACH CHANNEL.
DO 2 J= 2, ROWS, 2
DO 2 I= 2, COLUMNS, 2
BLUEHIST( IMAGE( I, J))= BLUEHIST( IMAGE( I, J))+ 1
GREENHIST( IMAGE( I- 1, J))= GREENHIST( IMAGE( I- 1, J))+ 1
GREENHIST( IMAGE( I, J- 1))= GREENHIST( IMAGE( I, J- 1))+ 1
REDHIST( IMAGE( I- 1, J- 1))= REDHIST( IMAGE( I- 1, J- 1))+ 1
IF( IMAGE( I, J) .LT. MINBLUE) MINBLUE= IMAGE( I, J)
IF( IMAGE( I- 1, J- 1) .LT. MINRED) MINRED= IMAGE( I- 1, J- 1)
IF( IMAGE( I- 1, J) .LT. MINGREEN) MINGREEN= IMAGE( I- 1, J)
IF( IMAGE( I, J- 1) .LT. MINGREEN) MINGREEN= IMAGE( I, J- 1)
IF( IMAGE( I, J) .GT. MAXBLUE) MAXBLUE= IMAGE( I, J)
IF( IMAGE( I- 1, J) .GT. MAXGREEN) MAXGREEN= IMAGE( I- 1, J)
IF( IMAGE( I, J- 1) .GT. MAXGREEN) MAXGREEN= IMAGE( I, J- 1)
IF( IMAGE( I- 1, J- 1) .GT. MAXRED) MAXRED= IMAGE( I- 1, J- 1)
IF( IMAGE( I- 1, J- 1) .LT. MINRED) MINRED= IMAGE( I- 1, J- 1)
2 CONTINUE
C NOW INTEGRATE THE AREA UNDER THE HISTOGRAMS FOR EACH COLOR.
BLUETOTAL( 0)= DFLOAT( BLUEHIST( 0))
GREENTOTAL( 0)= DFLOAT( GREENHIST( 0))
REDTOTAL( 0)= DFLOAT( REDHIST( 0))
CUTOFF( REDCHANNEL)= -1
CUTOFF( BLUECHANNEL)= -1
CUTOFF( GREENCHANNEL)= -1
WRITE( *, *) ' BLUE= ', MAXBLUE, MINBLUE
WRITE( *, *) ' GREEN= ', MAXGREEN, MINGREEN
WRITE( *, *) ' RED= ', MAXRED, MINRED
DO 3 I= 1, MAXPIXEL
BLUETOTAL( I)= BLUETOTAL( I- 1)+ DFLOAT( BLUEHIST( I))
GREENTOTAL( I)= GREENTOTAL( I- 1)+ DFLOAT( GREENHIST( I))
REDTOTAL( I)= REDTOTAL( I- 1)+ DFLOAT( REDHIST( I))
3 CONTINUE
C NORMALIZE THE CURVES.
DO 4 I= 1, MAXPIXEL
BLUETOTAL( I)= BLUETOTAL( I)/ DFLOAT( COLUMNS* ROWS/ 4)
REDTOTAL( I)= REDTOTAL( I)/ DFLOAT( COLUMNS* ROWS/ 4)
GREENTOTAL( I)= GREENTOTAL( I)/ DFLOAT( COLUMNS* ROWS/ 2)
C LOOK FOR THE 95%.
IF( BLUETOTAL( I) .GT. INTEGRATION_CUTOFF .AND.
1 CUTOFF( BLUECHANNEL) .EQ. -1) THEN
WRITE( *, *) 'BLUETOTAL( ', I, ')= ', BLUETOTAL( I)
CUTOFF( BLUECHANNEL)= I
END IF
IF( GREENTOTAL( I) .GT. INTEGRATION_CUTOFF .AND.
1 CUTOFF( GREENCHANNEL) .EQ. -1) THEN
WRITE( *, *) 'GREENTOTAL( ', I, ')= ', GREENTOTAL( I)
CUTOFF( GREENCHANNEL)= I
END IF
IF( REDTOTAL( I) .GT. INTEGRATION_CUTOFF .AND.
1 CUTOFF( REDCHANNEL) .EQ. -1) THEN
WRITE( *, *) 'REDTOTAL( ', I, ')= ', REDTOTAL( I)
CUTOFF( REDCHANNEL)= I
END IF
4 CONTINUE
C ADJUST THE BLUE CURVE TO MATCH RED.
DO 20 J= 1, MAXPIXEL
C FOR EVERY BLUE INTEGRATED TOTAL, FIND THE RED VALUE THAT EXCEEDS IT.
IF( BLUEHIST( J) .GT. 0) THEN
I= 1
5 I= I+ 1
IF( I .LT. MAXPIXEL .AND.
1 BLUETOTAL( J) .GT. REDTOTAL( I)) GO TO 5
GAINCURVE( J)= DFLOAT( I)/ DFLOAT( J)
END IF
20 CONTINUE
C SCALE BLUE CHANNEL TO RED RESPONSE CURVE.
K= MIN0( MINRED, MINBLUE)
DO 35 J= 2, ROWS, 2
DO 35 I= 2, COLUMNS, 2
BIGVALUE= IMAGE( I, J)
BIGVALUE= INT( DFLOAT( BIGVALUE)* GAINCURVE( BIGVALUE))
IF( BIGVALUE .GT. Z'03FFF') BIGVALUE= Z'03FFF'
IMAGE( I, J)= VALUE( 1)
35 CONTINUE
C EQUALIZE GREEN TO RED.
DO 41 J= 1, MAXPIXEL
C FOR EVERY GREEN INTEGRATED TOTAL, FIND THE RED VALUE THAT EXCEEDS IT.
I= 1
42 I= I+ 1
IF( I .LT. MAXPIXEL .AND.
1 GREENTOTAL( J) .GT. REDTOTAL( I)) GO TO 42
GAINCURVE( J)= DFLOAT( I)/ DFLOAT( J)
C WRITE( *, *) ' GAIN( ', J, ')= ', GAINCURVE( J)
41 CONTINUE
K= MIN0( MINRED, MINGREEN)
DO 40 J= 1, ROWS- 1, 2
DO 40 I= 1, COLUMNS- 1, 2
C EXCHANGE BLUE AND RED IF NOT BEING DONE IN THE CFA FILTER PATTERN TAG.
C EXCHANGE= IMAGE( I, J)
C IMAGE( I, J)= IMAGE( I+ 1, J+ 1)
C IMAGE( I+ 1, J+ 1)= EXCHANGE
C GREEN PIXEL ON RG ROW
BIGVALUE= IMAGE( I+ 1, J)
BIGVALUE= INT( DFLOAT( BIGVALUE)* GAINCURVE( BIGVALUE))
IF( BIGVALUE .GT. Z'03FFF') BIGVALUE= Z'03FFF'
IMAGE( I+ 1, J)= VALUE( 1)
C GREEN VALUE OF THE GBGBGBGB ROW.
BIGVALUE= IMAGE( I, J+ 1)
BIGVALUE= INT( DFLOAT( BIGVALUE)* GAINCURVE( BIGVALUE))
IF( BIGVALUE .GT. Z'03FFF') BIGVALUE= Z'03FFF'
IMAGE( I, J+ 1)= VALUE( 1)
40 CONTINUE
WRITE( *, *) ' FINISHED COLORMOSAIC'
RETURN
END
 
Hmm. Easy enough to do that entirely with the raw image files in Lightroom using a custom template in the Print module. I've not seen ContactPage Pro ... perhaps it automates the input in a convenient way? And can't take raw files? I'll have to look it up. Thx!

G
I should have mentioned that I only work with black & white.

ContactPage Pro works with RAW files albeit more slowly than with JPGs. But a simple INVERT + AUTO LEVELS + AUTO CONTRAST + BLACK & WHITE in Affinity Photo produces better first cut images with my Fuji X-Trans JPGs than with RAWs.

ContactPage Pro produces a PDF output. Usually just a quick further tweaking of the black point and white point in Affinity Photo is all it needs for a good contact page to go into the ring binder.
 
One big thing that a lot of people don't realize is that shooting raw gives more fine detail resolution. The sharpening and noise reduction that cameras use when creating in-camera JPEGs are primitive and typically oversharpen and overdo the noise reduction, resulting is the destruction of a lot of fine detail in the image. This is especially true for shooting at high ISO speeds, but it is evident even at the camera's base ISO. I've used Nikon, Olympus, and Canon DSLRs and mirrorless cameras, and this was true for all of them, no matter what settings I used for the in-camera JPEGs. I use Lightroom for processing RAW files.
 
"JPG's? I don't got no JPG's. We don't got to show you no steenking JPG's!" With apologies to the great Alfonso Bedoya.

That said, as I am a SOOC guy I will continue to shoot both RAW and JPG but use the JPG's unless there is a case that an edit would really help. Images like the Iona are good enough for me:

B0000719 by West Phalia, on Flickr
And this snap shot from an M240 with the CV 40mm f/1.2 ASPH resolves well enough to suit me in JPG. Just a quick "what the hell" shot as I was about to leave the coffee shop with my buddy:

And this boatyard shot:

The first is the X2D + XCD55V. The other two the old M240 + CV 40mm f/1.2 ASPH Nokton. It could also be that I am easier to please. ;o)
 
Last edited:
DSC06401.JPG

🙂
All the best,
Mike
 
Last edited:
Back
Top Bottom