Luminous Landscape Forum

Raw & Post Processing, Printing => Digital Image Processing => Topic started by: Guillermo Luijk on February 26, 2022, 04:02:24 pm

Title: Simple "restoration" of a RAW file from a defective image sensor
Post by: Guillermo Luijk on February 26, 2022, 04:02:24 pm
Something is wrong in the sensor readout of a Canon 7D user. All the RAW files have very low levels (nearly black) in 1 out of each 8 columns (corresponding to G-B photosites):

http://guillermoluijk.com/misc/rayas.png


I have done a quick fix by averaging the left and right columns and replacing the defective RAW data with them. The result eliminates the vertical lines after RAW development:

http://guillermoluijk.com/misc/antesdespues.jpg


Overall image:

http://guillermoluijk.com/misc/rayasrestaurado.jpg
 

The unsophisticated method produces artifacts in areas with high horizontal gradients:

http://guillermoluijk.com/misc/rayasrestauradocrop.jpg


Compact R code to do the averaging:
i=which(!col(img)%%8)  # affected pixels (1 out of each 8 columns)
NROW=nrow(img)
img[i]=(img[i-2*NROW]+img[i+2*NROW])/2  # replace averaging both sides


The restored RAW file can be downloaded from:
http://guillermoluijk.com/download/rayasrestaurado.dng

Regards
Title: Re: Simple "restoration" of a RAW file from a defective image sensor
Post by: Guillermo Luijk on February 26, 2022, 05:37:31 pm
Another approach: now I interpolate the G values from its closest 4 neighbours. B remains to be taken from the average of the columns offset 2 photosites left and right:

http://guillermoluijk.com/misc/rayasrestauradocrop2.jpg

Regards
Title: Re: Simple "restoration" of a RAW file from a defective image sensor
Post by: Guillermo Luijk on February 27, 2022, 06:33:35 am
This is what the last approach does: to restore the G values we average the four surrounding G photosites, and for the B values we just average the two closes neighbours, located 2 columns away left and right:

(https://blogger.googleusercontent.com/img/a/AVvXsEiW4xkh2aSriJDZ_Kg4qrmr1CdHyVjM20UvMFfdIxdHYpOW-zqWF-ywUIIu2XxIIIEA_enHrU_4TxkcJ3WoKZsMGFWz1ULe7MeAxwnpjbjHKvogCdJZIALAEhJzhfMunbZ1pmfnsxIfZMgHT-2xcRnG7eUgSmceGz3EDDR23OEd5Gg44iunbCW8uJiZIA=s16000)

The compact R code:

# METHOD 2

# B photosites
i=which(!col(img)%%8 & !row(img)%%2)
img[i]=(img[i-2*NROW]+img[i+2*NROW])/2

# G photosites
i=which(!col(img)%%8 & row(img)%%2)
img[i]=(img[i-NROW-1]+img[i-NROW+1]+img[i+NROW-1]+img[i+NROW+1])/4

About the defective columns, they still hold some information but impossible to recover due to severe underexposure and blooming:
(https://blogger.googleusercontent.com/img/a/AVvXsEjtcIxD3xWtMAsUu7y98B73N5FvWg3xYBEfIEJJhnf9MstX3QOh2KCOsF3JGN0BrT37gL1Brb1X7LPa9K-gfo47rVfu3Dvz8WDTwx7fIUzPZv5-2q1JVrV2ZCp7czRzi6vVxozFARMKZ0zU869K7h2whQysvy1x_l2HL9gLG-tjAJRO8x7dJkKnSIIOdA=s1300)

It looks like as if the Canon 7D would have 8 separate circuits to perform the sensor readout, and one of them failed.

Regards