Question to rawop.set_pixels_rgbg() - Script Writing - CHDK Forum

Question to rawop.set_pixels_rgbg()

  • 5 Replies
  • 1250 Views
Question to rawop.set_pixels_rgbg()
« on: 08 / June / 2023, 10:18:53 »
Advertisements
Hi everyone,

I tried to set the pixel color in my script,
but when I try to set for example

Code: [Select]
grayscale = 150
            rawop.set_pixels_rgbg(x, y, grayscale, grayscale, grayscale, grayscale)

it comes out pink rather than gray.

What's my problem?

I couldn't find any solution on the website or in this forum.

Thanks,
Michael

*

Offline reyalp

  • ******
  • 14079
Re: Question to rawop.set_pixels_rgbg()
« Reply #1 on: 08 / June / 2023, 16:42:24 »
Code: [Select]
grayscale = 150
            rawop.set_pixels_rgbg(x, y, grayscale, grayscale, grayscale, grayscale)

it comes out pink rather than gray.
The raw values are raw counts from the sensor, so they reflect the characteristics of the individual R, G, B filters in the bayer array. To convert them to some standard colors space, you need transform them based on some calibration. In DNG, this is done using the color matrix(es), and additionally modified by white balance values. You can find some references in the DNG specs.

The color matrix isn't currently exposed in rawop, it was on my list to add some day, but no one has asked for it yet. You can get the values from the platform_camera.h file in the source for your cameras port, or from a CHDK DNG shot with that camera.

Alternatively, if you just want something kinda close, you could shoot a grey card, and use read pixels to get the values and either hard code them or base a fudge factor on them.
Don't forget what the H stands for.

Re: Question to rawop.set_pixels_rgbg()
« Reply #2 on: 08 / June / 2023, 16:49:08 »
Cool, thanks.

Where can I find the source code for my camera(s)?

(I use IXUS 50 and IXUS 60)

Thanks,
Michael

*

Offline reyalp

  • ******
  • 14079
Re: Question to rawop.set_pixels_rgbg()
« Reply #3 on: 08 / June / 2023, 17:01:38 »
Cool, thanks.

Where can I find the source code for my camera(s)?

(I use IXUS 50 and IXUS 60)
You can find the source at https://app.assembla.com/spaces/chdk/subversion/source/HEAD/trunk

Code for individual ports is in the platform directory.

If you want to check out the whole source with svn, use guest / guest as the login.
Don't forget what the H stands for.


Re: Question to rawop.set_pixels_rgbg()
« Reply #4 on: 08 / June / 2023, 17:08:46 »
Thanks, found it.

No I have to dive into the magic of color matrix  :D

Re: Question to rawop.set_pixels_rgbg()
« Reply #5 on: 08 / June / 2023, 17:32:32 »
Quote
The raw values are raw counts from the sensor, so they reflect the characteristics of the individual R, G, B filters in the bayer array. To convert them to some standard colors space, you need transform them based on some calibration. In DNG, this is done using the color matrix(es), and additionally modified by white balance values. You can find some references in the DNG specs.

The color matrix isn't currently exposed in rawop, it was on my list to add some day, but no one has asked for it yet. You can get the values from the platform_camera.h file in the source for your cameras port, or from a CHDK DNG shot with that camera.



Okay,, I guess this expands my ability in programming for now.

I guess I will stop my idea in manipulating images directly in the camera (I thought about random things doing on the shot).

Thanks for your help, but it's too heavy for me (at the moment).

 

Related Topics