Pages: [1]   Go Down

Author Topic: Simple "restoration" of a RAW file from a defective image sensor  (Read 408 times)

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Simple "restoration" of a RAW file from a defective image sensor
« 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

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Re: Simple "restoration" of a RAW file from a defective image sensor
« Reply #1 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

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Re: Simple "restoration" of a RAW file from a defective image sensor
« Reply #2 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:



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:


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

Regards
« Last Edit: February 28, 2022, 06:13:42 am by Guillermo Luijk »
Logged
Pages: [1]   Go Up