6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7259
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: RAW output information

Wed Apr 12, 2017 2:59 pm

Bryan See wrote:Came by to see this thread, I'll comment around a bit. I tried the first example Python script of the Bayer capture, but I still cannot open the image file generated at the end of it, as the file is supposed to be readable in most packages (like GIMP and Photoshop). The question is: Could that be in DNG format? Or something else?

BTW, I've extracted the bayer data from the Jpeg stream or file, whether it's V1 or V2.
You've posted on viewtopic.php?f=43&t=146310&start=25#p1146735 and had responses.
Why the need to cross post the same question onto another thread?
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Bryan See
Posts: 11
Joined: Mon Apr 10, 2017 2:33 pm

Re: RAW output information

Fri Apr 14, 2017 5:50 am

From what I've found out on that section, the bayer pattern for the IMX219 is:

GR
BG

which means GRBG, I think. But how do the RAW output of the IMX219 image look like?
6by9 wrote:
Bryan See wrote:Came by to see this thread, I'll comment around a bit. I tried the first example Python script of the Bayer capture, but I still cannot open the image file generated at the end of it, as the file is supposed to be readable in most packages (like GIMP and Photoshop). The question is: Could that be in DNG format? Or something else?

BTW, I've extracted the bayer data from the Jpeg stream or file, whether it's V1 or V2.
You've posted on viewtopic.php?f=43&t=146310&start=25#p1146735 and had responses.
Why the need to cross post the same question onto another thread?
To add the knowledge of RAW image outputs here.

bmw318
Posts: 13
Joined: Tue Aug 16, 2016 8:23 am

Re: RAW output information

Thu May 11, 2017 3:43 pm

Hi,
using the RPi and the V2 camera, I want to acquire the RAW image from the image sensor directly without extracting it from the JPG file. Extracting takes a very long time. I think the sensor has to put into RAW mode by use of its serial commands, isn't it?
Is there somebody who knows how to do it?

Would love to heat from you.

Regards.

User avatar
jbeale
Posts: 3491
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: RAW output information

Thu May 11, 2017 3:56 pm

On the Raspberry Pi, the camera sensor is always used in RAW mode, so the raw image data is always transferred to the RPi. It is the ISP system onboard the RPi SoC (in the GPU) that does the image processing and creates the JPEG still or H.264 video data. The relative slowness of processing RAW data on the CPU has to do with processor speed and bus bandwidth on the ARM side of the hardware. The GPU is much faster, having more parallel hardware that was designed for that task.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7259
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: RAW output information

Thu May 11, 2017 4:02 pm

bmw318 wrote:Hi,
using the RPi and the V2 camera, I want to acquire the RAW image from the image sensor directly without extracting it from the JPG file. Extracting takes a very long time.

Code: Select all

tail -c -10270208 output.jpg > output.raw
The time taken will be totally dependent on the speed of the storage, but generally pretty minimal.
Or are you complaining that producing the file takes too long? There is a potential tweak for raspistill that would speed up the transfer from the GPU, but I couldn't say by how much.
bmw318 wrote:I think the sensor has to put into RAW mode by use of its serial commands, isn't it?
Is there somebody who knows how to do it?
The sensor is always producing Bayer as it has no processing block to convert from Bayer to YUV (that is normally done in the SoC).

If you really want to get down to just raw Bayer, then look at viewtopic.php?f=43&t=109137, or there will soon be a V4L2 driver that can receive the data. (There's an upstream driver for OV5647, but not for IMX219 as yet). Exposure and gain control is then totally down to you.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

bmw318
Posts: 13
Joined: Tue Aug 16, 2016 8:23 am

Re: RAW output information

Tue May 16, 2017 6:03 pm

Hi,
Thank you for your answer.
I was refering to Picamera because I want to acquire a RAW image from within Python. This takes a very long time. Doing measurements on many successive frames is undoable.
I noticed that there are many definitions regarding RAW images. What I define as RAW is the real contents of a pixel without any processing.

Regards.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7259
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: RAW output information

Wed May 17, 2017 8:40 am

bmw318 wrote:I was refering to Picamera because I want to acquire a RAW image from within Python. This takes a very long time. Doing measurements on many successive frames is undoable.
You hadn't stated how you were trying to access raw frames, and we have to share the crystal balls around when trying to mind read ;)
Can you provide a small snippet of code that you are trying to run? TBH The number crunching on the resultant images is likely to take a significant amount of time, particularly with the raw 10 packing used. The PiCamera docs around Bayer captures include various levels of processing. What of those are you using?
bmw318 wrote:I noticed that there are many definitions regarding RAW images. What I define as RAW is the real contents of a pixel without any processing.
Just to check, you are aware of Bayer patterns then? The sensor produces a Bayer image natively, not a full resolution RGB or YUV.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

cgoins
Posts: 1
Joined: Thu Jul 06, 2017 4:39 pm

Re: RAW output information

Thu Jul 06, 2017 4:51 pm

Do other people's demosaiced raw images look something like this? My demosaicing of jbeale's raw images are darker and greener that what I've seen others post. I'm using BGGR as the Bayer pattern and am pretty confident that is correct. I know I can adjust the image to look better but I want to know whether this is what the raw images look like for others.
Attachments
nn.png
nn.png (62.52 KiB) Viewed 4379 times
chart_nn.png
chart_nn.png (54.57 KiB) Viewed 4379 times

blindbloom
Posts: 20
Joined: Wed Jun 10, 2015 8:23 pm

Re: RAW output information

Mon Jul 10, 2017 4:48 pm

This is the typical result of performing demosaic only. The sensor values are linear with respect to scene radiance (aka scene-referred), which accounts for the dark appearance. A raw processing pipeline (e.g. David Coffin's dcraw) applies additional color processing to put the image into an output-referred form for normal viewing (e.g. sRGB/JPEG). This processing includes things like overall gain (exposure), channel-specific gains (white balance), 3x3 matrix, film curves, etc.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7259
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: RAW output information

Mon Jul 10, 2017 5:00 pm

blindbloom wrote:This is the typical result of performing demosaic only. The sensor values are linear with respect to scene radiance (aka scene-referred), which accounts for the dark appearance. A raw processing pipeline (e.g. David Coffin's dcraw) applies additional color processing to put the image into an output-referred form for normal viewing (e.g. sRGB/JPEG). This processing includes things like overall gain (exposure), channel-specific gains (white balance), 3x3 matrix, film curves, etc.
The updated version of dcraw at https://github.com/6by9/RPiTest/tree/master/dcraw also directly handles the JPEG+RAW format that the Pi produces, for both Pi camera modules and all of their modes. It doesn't have a colour calibration for the V2 sensor though.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Egg_man
Posts: 3
Joined: Tue Oct 02, 2018 1:42 pm

Re: RAW output information

Tue Oct 02, 2018 2:19 pm

Hi! I have a question: what's the quickest way to extract the RAW information from the jpeg image into a numpy array? I did acquire a set of pictures with raspistill -r because setting the exposure time in picamera gave me some problems, and now I'd like to process them with Python and OpenCV.

thatneat
Posts: 4
Joined: Tue Dec 04, 2018 5:52 pm

Re: RAW output information

Tue Dec 04, 2018 9:54 pm

what's the quickest way to extract the RAW information from the jpeg image into a numpy array?
My team just released a fork of picamera that is designed just for this. Check out https://github.com/OsmoSystems/picamraw/ and let us know how it goes!

Return to “Camera board”