How to save raw lenslet image?

83 views
Skip to first unread message

mohana

unread,
Feb 24, 2021, 2:06:22 PM2/24/21
to Light Field Vision
Hi all,

A lot of earlier works on light field use the 'raw' lenslet images, which have the characteristic honeycomb structure. For eg see image below from this CFP.
Screenshot 2021-02-25 at 12.23.23 AM.png 
I tried reading 'Jacaranda.lfp' in the toolbox using LFReadLFP and then using MATLAB's 'demosaic' function to apply debayering. I get a matrix of correct dimensions i.e. 5368x7728x3 uint16. However the max value in this uint16 matrix is way too small, only 1236. So when I try saving it as a png file, I only see a black image. Similar result for the .raw files in F01 folder. 

Am I missing a step? There's a LFWriteESLF, but ESLF is not really a raw image, and it has a slightly different structure, for eg below:
 zoom.png
Although it still seems to show the micro images, but it is aligned and there's the black portions. So how exactly are raw images saved to png?

Thanks!

Christopher Hahne

unread,
Feb 25, 2021, 12:58:34 PM2/25/21
to Light Field Vision
Hi Mohana,

I received your post as an email and thought PlenoptiCam may be a considerable alternative for you as it renders the raw image and saves it as a *.tiff file on your hard drive. Note that "raw" means the image will be in Bayer pattern representation. Hope this helps.

Best,
Christopher

mohana

unread,
Feb 25, 2021, 10:49:55 PM2/25/21
to Light Field Vision
Hi Christopher,

Thanks a lot for pointing to this! I will try it out. 

If it is in Bayer pattern it would mean it isn't exactly the lenslet image as in my post (which is obtained after demosaicing), none the less it would be interesting to see the actual raw image and try out other features of this software.

Regards,
Mohana

Donald Dansereau

unread,
Apr 25, 2021, 11:12:48 PM4/25/21
to Light Field Vision

Sorry for the long delay, I hope this is still useful:  If I've got the question right you'd like to read an LFP and write a PNG containing the debayered raw (not de-hexed) lenslet image.

Your approach was correct, the images are dim because the LFP is a 10-bit image for Illum, or 12-bit image for F01, and these are stored in 16-bit numbers so the display appears dim.  The easy fix is to scale the image.  Once this is done, if you want to save the raw lenslet image, imwrite works fine.  

The key steps are below, full example showing conversion to doubles and dealing with F01 images is at: 


LF = LFReadLFP('Images/Illum/Jacaranda.lfp');

% Scale it up to occupy all 16 bits:
RawImg = LF.RawImg .* 2^(16-10); 

% Now demosaic
LensletImage = demosaic(RawImg, LF.DemosaicOrder);

% And display
LFDisp(LensletImage);

% The 16-bit png is pretty big, 200 MBytes
% imwrite(LensletImage, 'Jacaranda16.png'); % commented out because this file is big

% You might consider manipulating the above to work in 8 bits instead:
RawImg = uint8( LF.RawImg .* 2^(8-10) );  % convert down to 8 bits
LensletImage = demosaic(RawImg, LF.DemosaicOrder);
imwrite(LensletImage, 'Jacaranda8.png');


see full example at link above.

Donald Dansereau

unread,
Apr 25, 2021, 11:15:02 PM4/25/21
to Light Field Vision

... just a note that the next thing you may want to do is devignette, i.e. divide by the white image to brigthen up the edges of the lenslet images.  Getting the data types right during the division is important, the first few lines of code in LFDecodeLensletImageDirect, up to and including the demosaic, might be helpful here.
Reply all
Reply to author
Forward
0 new messages