Message Boards Message Boards

1
|
8230 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Recover highlight and shadow detail from RAW images?

Posted 7 years ago

I am processing RAW images (.nef) from a Nikon camera. If I process these images in Adobe Lightroom I can adjust the highlights and shadows to avoid clipping any data. Histogram looks like this. Histogram Lightroom

In Mathematica, doing an Import with default values the ImageHistogram looks like this: Histrogram Mathematica

Values appear to be clipped at both ends of the histogram. Applying ImageAdjust does not recover the data at the ends. It appears that importing a RAW file clips the data during the import process. The result is much like the defaults in Lightroom before adjusting the highlight and shadow sliders.

How can I import RAW images and get all the data without clipping?

POSTED BY: Jeff Burns
4 Replies
Posted 7 years ago

Test NEF files are a available at this link.

Using this code it is apparent that the image data is not clipped by Mathematica.

img = Import[“a.NEF”];

ImageHistogram[img, 1000, All, Appearance -> "Transparent", 
   Method -> #, ImageSize -> Large, 
   FrameTicks -> True] & /@ {"IncludeOutOfRange", "ExcludeOutOfRange"}
POSTED BY: Jeff Burns
Posted 7 years ago

So, what was the source of the problem? Was is too rough default binning by ImageHistogram (default is 128 bins)?

Apparently imported image contains no out-of range values:

ImageData[img] // MinMax
(* =>  {0., 1.} *)

But a naive attempt to obtain it directly from the "Data" element by applying Rescale to each color channel separately produces a slightly different image:

data = Import["DSC_2106.NEF", "Data"];
img = Import["DSC_2106.NEF"];

subimage = ImageTake[img, {-4500, -3000}, {1300, 2700}];
subimageFromData = 
 Image[Rescale /@ Transpose[N@data[[-4500 ;; -3000, 1300 ;; 2700]], {2, 3, 1}], 
  Interleaving -> False];

ImageData[subimageFromData] - ImageData[subimage] // MinMax

(* => {0., 0.0346075} *)
POSTED BY: Updating Name
Posted 7 years ago

If you provide your ".nef" file,you will receive more better solution maybe.And I have a related answer here,hope to help.

POSTED BY: Yode Japhe

Whenever you post here, post your code! it's part of the rules... thanks you :)

Did you use

Import["yourimage.nef"]

or

Import["yourimage.nef","Data"]

or

Import["yourimage.nef","RawData"]

?

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract