color analysis script - page 2 - Script Writing - CHDK Forum  

color analysis script

  • 13 Replies
  • 5298 Views
Re: color analysis script
« Reply #10 on: 10 / October / 2013, 09:08:52 »
Advertisements
thanks a lot for the responses! the spot meter function is already close to what I would like to do.
however, I want to take a picture and then analyze it instead of having live information (i.e. I want to control exposure time, etc.). I don't think that you can easily apply the procedure from the motion detect buffer to the raw buffer you get from the taken image (?)
it looks to me like it should be possible to modify the build_shot_histogram() function in the source shot_histogram.c to only take the red, green, or blue pixels into account. you could then just have one shot_histogram variable per color and do a slight modification on the shot_histogram_get_range to calculate the values.
to do this I need to understand how the get_raw_pixel function in raw.c works. I get the basic principle how it assembles the bits corresponding to one pixel but I don't understand how you know which pixel is red, green, or blue, and where on the picture the pixels are.

basically I just need to know which pixels I need to access to only have red, green, or blue ones. more specific questions would be:
- in get_raw_pixel, the pixel is defined by x and y. Am I correct in assuming that these are just the normal coordinates of the pixels?
- In the wiki page on frame buffers it says that the most common format is red-green-green-blue. what does this mean exactly? do the pixels in one row have the sequence RGGBRGGB...? should I be able to take always the same color by always increasing x in steps of 4? what is then the sequence of a column?
- why does shot_histogram use a step size in both x and y of 31?
- could somebody maybe explain how the address of each pixel is found in raw.c (code: addr=(unsigned char*)rawadr+y*camera_sensor.raw_rowlen+(x/8)*10)
sorry if some of the questions are very naïve; as I said, I am completely new to this.

Re: color analysis script
« Reply #11 on: 10 / October / 2013, 09:55:48 »
- In the wiki page on frame buffers it says that the most common format is red-green-green-blue. what does this mean exactly? do the pixels in one row have the sequence RGGBRGGB...?

No.

Even rows are RGRGRGRG ..... and odd rows are  GBGBGBGB ........

Quote
- could somebody maybe explain how the address of each pixel is found in raw.c (code: addr=(unsigned char*)rawadr+y*camera_sensor.raw_rowlen+(x/8)*10)

that is for a camera that uses ten bits per pixel.
So, eight pixels are 80 bits or ten bytes.
Each row is camera_sensor.raw_rowlen bytes long.
The start address of row zero is rawadr.
start address of next row is rawadr + camera_sensor.raw_rowlen
start address of row 'y' is therefore rawadr+y*camera_sensor.raw_rowlen.

Address of first pixel in that row is the same.
In fact, it is the start address of eight pixels as used by the code that follows that.
The next group of eight pixels will be ten bytes further on.


Re: color analysis script
« Reply #12 on: 10 / October / 2013, 13:20:42 »
thanks a lot for your help! it seems to be working now.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: color analysis script
« Reply #13 on: 10 / October / 2013, 14:55:28 »
- In the wiki page on frame buffers it says that the most common format is red-green-green-blue. what does this mean exactly? do the pixels in one row have the sequence RGGBRGGB...?

No.

Even rows are RGRGRGRG ..... and odd rows are  GBGBGBGB ........

This depends on the cam_CFApattern value for the camera (platform_camera.h).

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


 

Related Topics