1

I am working on a telescope project and we are testing the CCD. Whenever we take pictures things are slightly pink-tinted and we need true color to correctly image galactic objects. I am planning on writing a small program in python or java to change the color weights but how can I access the weight of the color in a raw data file (it is rgb.bin)?

We are using a bayer matrix algorithm to convert monochromatic files to color files and I would imagine the problem is coming from there but I would like to fix it with a small color correcting program.

Thanks!

clifgray
  • 4,313
  • 11
  • 67
  • 116
  • 2
    You really need to know if the inaccuracy is caused by by the sensor and its color filters or by the software. If it's the software, any corrections you apply could just make it worse. Point the telescope at an unfocused white wall and look at the raw pixel values directly. – Mark Ransom May 29 '12 at 21:34

4 Answers4

3

Typical white-balance issues are caused by differing proportions of red, green, and blue in the makeup of the light illuminating a scene, or differences in the sensitivities of the sensors to those colors. These errors are generally linear, so you correct for them by multiplying by the inverse of the error.

Suppose you measure a point you expect to be perfectly white, and its RGB values are (248,237,236) i.e. pink. If you multiply each pixel in the image by (248/248,248/237,248/236) you will end up with the correct balance.

You should definitely ensure that your Bayer filter is producing the proper results first, or the base assumption of linear errors will be incorrect.

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622
1

There are some useful things for image processing in Java, try to use the BufferedImage class, here I leave you a link to the Javadoc you can open images in the common formats and use BufferedImage to access the color or the gray levels of each pixel.

BufferedImage

I don't know python.

Hope this helps!

1

You might want to check out the Python Imaging Library (PIL). I will let you load images in various formats and get access to its color values.

I am not familiar with the rgb.bin image format, but if "weight" means simply adjusting the various RGB type values, then the PIL may be worth looking into (PIL documentation pdf)

Note that the PIL is officially supported for up to Python v2.7 (the welcome page says v2.6, but it's really v2.7 - see the download page), however there is a non-official version of the PIL for Python v3.x available from the Unofficial Windows Binaries for Python Extension Packages site.

Levon
  • 138,105
  • 33
  • 200
  • 191
1

If your image is coming out with a color-cast (the pink tint), the photographer's approach to fixing it would be to adjust the white balance of the image.

There is a good discussion of implementing an automatic white balance correction algorithm here: White balance algorithm

As you have already generated a file containing your binary RGB values I'm assuming you are able to re-parse this into a data structure for further processing. Once you have your RGB pixels in a buffer you will want to convert them into their HSB (hue, saturation, brightness) equivalents as altering the color tint of an image is essentially a global operation on the hue of each pixel. The Java Color class contains methods for performing HSB<->RGB conversion.

Community
  • 1
  • 1
Malcolm Smith
  • 3,540
  • 25
  • 29