Author Topic: True Colors  (Read 24926 times)

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
True Colors
« on: 2010 February 14 13:03:00 »
Hello,

I am somewhat puzzled how to process images to preserve the maximum color information that they have. Lets consider this situation:

- I am shooting an object 1 that gives me (after calibration etc.) the RGB values (0.4, 0.2, 0.1). This is what you see in the center of the top left image in the attached screenshot.
- On the same picture, I have another object 2 that gives RGBs of (0.004, 0.002, 0.001). This is the color of the border of the top left image. It is quite dark in the unprocessed version.
- My idea is that both objects have the same color, only that object 2 is 100 times darker. Maybe it is not even darker in nature, it is just further away than object 1, so it appears darker.

Now process that image. Obviously, I need to boost the brightness of object 2 a bit to see it.
- Using Histogram Transform, I do a considerable boost by moving the midtones slider. The result is the middle top row picture, with RGBs of (0.986, 0.964, 0.923) and (0.303, 0.178, 0.098). Obviously, the bright part of the image became "whiter", and the dark part got a color that is by no means similar to the expected (4:2:1) ratio.
- Using Curves Transform, I can boost Luminance only. According to http://en.wikipedia.org/wiki/Lab_color_space, this would try to preserve the color impression. And indeed, to some extend it does. While the bright part keeps at least some color (RGB 1.0, 0.87, 0.74) , the dark part becomes gray (0.225, 0.224, 0.223) ... which is kind of logical since the original color impression was black.


So both approaches loose color. This is not an accademic problem as the lower row of pictures (a part of M42) shows: Histogram Transform gives the nice pink in the outer regions, but looses color in the central part. Curves Transform keeps most of the central color, but leaves the outer regions gray.

So what to do? This appears to be a no-win situation...

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline dhalliday

  • PixInsight Old Hand
  • ****
  • Posts: 307
    • on Flickr
Re: True Colors
« Reply #1 on: 2010 February 14 17:37:39 »
George
Just off the top of my head I can say that I have noticed that adding "brightness" always reduces color...
In "curves" I can often improve this by INCREASING saturation,and reducing Luminance...
Your scenario is a bit "deep" for me...but it is an excellent topic !!
Just today,working on M1 data I noticed that doing a few more runs of DBE on the combined RGB data (already DBE'd individually) seemed to help,but I look forward to others comments.
Color is an issue I struggle with since switching to mono imaging... >:(

Dave
Dave Halliday
8" Newtonian/Vixen VC200L/ TV 101,etc etc
SSAG/EQ6
CGE Pro
SBIG ST2K,ST10XME

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: True Colors
« Reply #2 on: 2010 February 16 09:06:00 »
Hello,

I think I may have found a procedure for doing a "color preserving" histogram transform.

The basic idea is to use the HSV color space during the transformation. According to http://en.wikipedia.org/wiki/HSL_and_HSV, in particular http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSV, boosting the V values will preserve the relative RGB ratios. I gave it a try using the original example in the first post:

- Screenshot 1 shows from top left to bottom right:
-- the original synthetic picture with RGB values proportional to 4:2:1 in both the center and border region.
-- H, S, and V channels extracted using ChannelExtraction in the HSV space. Both center and border regions have identical hue and saturation, only the V value makes a difference.
-- A clone of the V channel, boosted using HistogramTransform. The border region is moved from almost black to gray.
-- A recombination of the boosted V channel and the original H and S channels using ChannelCombination. The RGB values are (0.986, 0.493, 0.2465) and (0.2979, 0.149, 0.0745), which mirrors perfectly the original RGB relationships of 4:2:1. The resulting image also is obviously more colorful that the result in my original post.

- Screenshot 2 shows the same methodology applied to the original M42 clip. While the color balance probably is not perfect, I seem to preserve much more of the original color information.

I wonder if this procedure is a valid one for processing RGB pictures to preserve as much color as possible. Any comments  ???

Georg
« Last Edit: 2010 February 17 01:32:05 by georg.viehoever »
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline dhalliday

  • PixInsight Old Hand
  • ****
  • Posts: 307
    • on Flickr
Re: True Colors
« Reply #3 on: 2010 February 16 09:12:56 »
George
Yikes !
That sounds too deep for me... >:D
Maybe Jack or Juan or other Jedii will weigh in here...

Dave
Dave Halliday
8" Newtonian/Vixen VC200L/ TV 101,etc etc
SSAG/EQ6
CGE Pro
SBIG ST2K,ST10XME

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: True Colors
« Reply #4 on: 2010 February 16 14:56:40 »
Hi Georg,

I played around with your problem the other night, and I also spent a fair amount of spare time trying to understand the various colour systems that are available to us in PI. There are basically six of them, including the standard RGB.

These are as follows:-

HSV (also known elsewhere as HSB) - based on Hue, Saturation and Value (or Brightness)
HSI (also known elsewhere as HSL - based on Hue, Saturation and Intensity (or Lightness)
XYZ - not a system I can easily visualise, so it is still the 'least understood' as far as I am concerned
Lab (more officially CIE L*a*b*) - this is apparently the colour space that most closely mimics the response of our eyes
Lch (more officially CIE L*c*h*) - further investigation needed before I can comment on this one

In the first two spaces, the Hue and Saturation elements are actually identical - they differ only in the third component

In the L*a*b* space, you can modify the 'Luminance' component of the image without affecting either of the two 'Chrominance' components - although there ARE limits. These limits come into play when you (have to) return from the L*ab colour model to the RGB colour model in order to display the image on your screen. The problem is that, as the RGB values tend toward the upper or lower limits, they are 'constrained' by the finite limits of the data variable space available to contain them.

Put another way - at 'pure white', you have equal RGB values [1,1,1] and at 'pure black' the same occurs again - [0,0,0]. Considering 'pure white' again, and then moving very slightly away from this point, you could end up with a 'colour' of (for example) [1,0.999,0.999] - but this colur, although 'red-dominant', will really be perceived as almost perfect white. You would have to move away quite a bit from the [1,1,1] point before you could really say that the colour was 'faint pink' (because of the dominance of Red).

And the same can be said down amongst the black levels.

Which is a problem as you start to stretch your data to enhance the dimmer regions. If the stretch is a simple 'linear stretch' - using an expression such as ($T * 1.5) in PixelMath to give you a straightforward '50%' increase in brightness across the whole image, then you could only get away with using the '1.5' multiplier if the existing maximum ADU value in your image was less than, or equal to, (1/1.5), or 2/3 (0.667). When you apply the 50% increase multiplication, the [0.667] value will 'max out' at [1.000], with everything else also increasing in perfect proportion, but with NO data loss at the top end.

However, this 'linear enhancement' can only be applied where the image is NOT already as bright as it can be in some areas - i.e. where the maximum ADU level anywhere in the image is less than [1.000]. I doubt whether ANY of our astroimages would EVER fall into that category, and - if they did - it wouldn't be for very long!!

So, we need to forget about linear enhancement - which is where the Histogram 'MTF' function comes into play (the 'Midtones' slider position), along with the far more flexible Curves process, where the shape of the transfer function curve is infinitely variable.

Sticking with the Histo MTF for a few moments, this gives you a quick and simple method of 'boosting' the 'intensity' of an image. The clever 'shape' of the curve ensures that 'most' of the 'boost' occurs down at the dimmer section of the Histogram. Which is exactly where we usually need it. And the MTF curve 'flattens' out as it gets up to the brighter section of the Histo, exatctly where we want/need its effect least. But the Histo MTF curve is very much a 'brute force' tool - sometimes useful for that very reason, but not when we need 'finesse'.

When we need 'finesse', we have to turn to the far more flexible 'Curves' process.

So, now we know WHICH function to use - Curves, not Histo or PixelMath. But how to implement it, or to what part of an image?

Going back to my (very brief) introduction to colour spaces (or models) above, and rembering that the CIE L*ab model most closely mirrors what we actually can 'see' - and noting that the 'L' component reflects the 'Luminance' and that the 'a' and 'b' components reflect the 'Chrominance' of the image, then it is fair to say that we only want to modify the L channel of the data, and that - if we don't touch the a or b channels, we shouldn't affect the colour at all.

So, we can then use the Channel Extract process to create that distinction for use - giving us three new images (L, a, and b) from our original RGB image. And these three images can then be Channel Combined again to recreate the original RGB image - identically in this case, because we didn't change the interim images in any way.

But, if we change the L channel, then we can modify the 'Luminance' (or 'brightness') of the image prior to recombination - with the effect of changing the 'Luminance' of the final image - exactly what we are after (and this argument is really ONLY valid for the L*ab and L*ch colour spaces - I know that you tried things in the HSV and HSI spaces, but you DO stand more a chance of 'modifying' the 'perceived' colours if you are not working with the L*ab or L*ch models (and I prefer the L*ab model, as I understand it the best - which is, still, not a lot ::))

However, you still have to 'be careful' in how 'much' you tweak the L-channel. Remember that, as you 'squeeze' the ADU values towards either [0.000] or [1.000] you WILL start to 'desaturate' the colours, because all three (Rd, Gn and Bu) values have 'nowhere to go' and so they start to 'come together' in value - and RGB values that are 'equal' represent a totally de-saturated 'shade of grey'. That is just a fundamental fact.

So, if we agree that you can preserve colour information by only processing the L-channel, and keeping the a and b channels untouched, and that the processing applied to the L-channel needs to have the finesse available in the Curves process (not the Histo or PixelMath processes), then how can you use Curves to achieve this?

Well, first of all, Curves actually allows you to process the L channel without all the hassle of splitting up and recombining the RGB data. You can define a transformation ONLY for the Luminance, and PI will extract the L-channel, process it and recombine it with the a and b channels without you ever needing to be involved - so that is one of the problems dealt with.

Then you need to understand how the modification of a 'curve' actually affects the data (for the L-channel here, but it is the same for the other curve options). The 'default curve' is simply a 'straight line' from the bottom left to the top right of the curve window. In other words every ADU value in the 'source' (along the x-axis, at the bottom) is 'mapped' via the curve line to an identical ADU value in the 'destination' (along the y-axis, up the left side). Typically, curve modification at its simplest involves 'grabbing' a point on this straight line and 'curving' it up or down.

For any source ADU value, if the mapping point on the curve (directly above its position on the x-axis) is now ABOVE the original corner-to-corner straight line, then the destination ADU value will be 'bigger' - and, for the L-channel, 'bigger' means 'brighter'. Conversely, if the new line is lower than the original diagonal at this particular point, the destination ADU will be lower, or dimmer.

So, now you can see that just a simple 'bowed curve' that you get by grabbing one point on the transfer curve, and dragging it upwards, is not really much better that the MTF curve in the Histo process. OK, you may get finer control, but the curve will be such that EVERY point is 'higher' that the diagonal corner-to-corner straight line was - and so every ADU value will be increased. And, for those values atthe brightest end of the histogram, you could still end up with 'data compression' - which will ALWAYS end up in de-saturation because, remember, values with similar ADU values are always shades of gray.

So, the trick then becomes one of creating a 'compound curve' - where only a small section of the curve is 'above the diagonal'. In fact, the standard enhancement curve is often the easily recognisable 's-curve' - one which often actually 'dips' at the bottom-left corner (which will serve to dim the faintest information, usually an advantage if this information is really just background noise anyway). Then the curve will rise above the line at the ADU level where the luminance enhancement is needed, before dropping back on to the original diagonal line for as long as possible - especially up at the upper right-hand end.

And, these curve adjustments need to be delicate. You don't want the 'dip' at the start to be so severe that you force your sky background all the way back to an un-natural 'glossy black'. You might not want a dip at all - you will have to judge that requirement on every image. Yo do want to be 'flat to the end' - and that means you need to get the curve back onto the path of the original diagonal as soon as you can - otherwise you will blow out the saturation of the brighter levels (which you could have done far more easily with a nice strong Histo MTF !!!). And you don't want 'sharp transitions' at the point where you do drag the curve off the diagonal.

Now, you can of course, apply the Luminance-Curve transformation through a Mask - which is how you will see it done in PS. That way your curve can be just that little bit more aggressive - because you will (hopefully) have eliminated all the brighter regions with the mask - meaning that they are now 'protected' anyway. Use a combination of ATWT and Histo to create a nice, feathered edge, mask - perhaps incorporating a star mask as well - so that only the areas of interest are exposed. And then see if you can enhance just that zone of levels that you are interested in.

You could even then invert the mask (exposing just the 'brightest' areas that were previously 'masked') and then use the Saturation-Curve to see if there is any extra detail available in those areas. (The PI 'behind the scenes' action is to split the image into HSV or HSI channels, and to then apply your Sat-Curve to the S-channel, before recombining back to RGB - again, saving YOU all the hassle of doing it yourself - which, of course, you can if you want to get a feel for the individual steps of the process).

Hopefully I have managed to get all of this right. This is certainly how I have understood the porcesses to work, given hours and hours playing with PI, and even greater amounts of time trying to understand all the theory of image processing from HAIP, through all of Ron Wodaski's excellent books, and an infinite number of times pressing <Ctrl-Z> ::)

Cheers,
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline dhalliday

  • PixInsight Old Hand
  • ****
  • Posts: 307
    • on Flickr
Re: True Colors
« Reply #5 on: 2010 February 17 04:01:45 »
Niall
How about a 150 word summary of what we can  do (in curves) to optimize color...?
I get the "S" curve part...but with what signal do we use it ?
Saturation ?
Lumunance ?
What about all the other choices on there..??
When I do a RGB combine of M! the data looks almost WHITE...what did I do wrong before I even got to curves..?

I am a "big picture" guy,myself.And you lost me... >:D
I will reread your post a few times,but seriously,(and respectfully  O:)) you need to keep in mind we are (some of us) just plain old folks..watching the Olympics,(go Canada !) and scratching our crotch occasionally.
We appreciate the Jedii...but we need to be able to understand the "Jedii" language...

Dave
« Last Edit: 2010 February 17 04:09:01 by dhalliday »
Dave Halliday
8" Newtonian/Vixen VC200L/ TV 101,etc etc
SSAG/EQ6
CGE Pro
SBIG ST2K,ST10XME

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: True Colors
« Reply #6 on: 2010 February 17 04:49:21 »
Hi Dave

If you want to boost the brightness of the image, and preserve color at the same time, what you need to do is perform both L and c adjustments with Curves. This saturation lost is unavoidable, becouse of the way that space colors are builded.
About V channel. I would avoid its use. Can't remember a good technical reason, but it is a very un-elegant channel. :D The V channel is buided by the maximum value of the RGB components. So, I would not trust that it works without artefacts at all, if you modify its contents (with curves, etc.). Anyway, if it seems to work to you, go ahead :)
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline dhalliday

  • PixInsight Old Hand
  • ****
  • Posts: 307
    • on Flickr
Re: True Colors
« Reply #7 on: 2010 February 17 05:12:48 »
Carlos
Thanks !!

Niall;now I am fretting that I sound like a mean Canadian redneck  >:D
Just another frustrated astroimager...

Dave
Dave Halliday
8" Newtonian/Vixen VC200L/ TV 101,etc etc
SSAG/EQ6
CGE Pro
SBIG ST2K,ST10XME

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: True Colors
« Reply #8 on: 2010 February 17 05:42:56 »
Fret ye not my little redneck friend  ;D

Just remember that - as often as not - I am actually LEARNING about the subject as I type. This is a natural benefit from trying to explain to others about a subject that I am 'slightly' familiar with.

The more I try to explain it, the more I have to understand it better myself  ???

So, please excuse my long diatribes - they are well meant - and I sometimes even hope that someone will correct me if I am wrong.

In reality, NONE of us are true Jedi - other than Lord Conejero of course - but his disadvantage is that he is all too often a 'busy' Jedi  :P

Cheers,
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: True Colors
« Reply #9 on: 2010 February 19 11:31:32 »
Hi Niall, Carlos

Hi Georg,

I played around with your problem the other night, and I also spent a fair amount of spare time trying to understand the various colour systems that are available to us in PI. There are basically six of them, including the standard RGB.
...

I agree with everything you you said about color spaces and about the use of curves transform. But...:

- The screenshot in my original post http://pixinsight.com/forum/index.php?action=dlattach;topic=1689.0;attach=403 shows the effect of using a curves transform on L in the upper right: The bright part keeps (most) of its color, the dark part just becomes gray. This is actually quite in line with the idea of Luminance in the CIE L*a*b* color space: When changing L, preserve the color impression as much as possible. And the original color impression of the dark image part was black, so it is only logical if pushing L will change it to grey.

- It is probably true that for most astronomical RGB data, the pushed L version would largely be a greyscale image. After all, most stars and nebula are so dark that our eyes (without telescope) perceive them as colorless. So preserving "natural" colors as seen with your eyes clearly is not a goal most astronomical image processing.

- Coming back to the argument in my original post http://pixinsight.com/forum/index.php?topic=1689.msg9757#msg9757: both regions in the top left image have the same relative RGB ratio of 4:2:1, only the outer region is much darker. In astronomy, both regions could actually come from objects that have the same color, only the outer object is further away. I therefore think they deserve (more or less) to have the same color in a processed image.

...About V channel. I would avoid its use. Can't remember a good technical reason, but it is a very un-elegant channel. :D The V channel is buided by the maximum value of the RGB components. So, I would not trust that it works without artefacts at all, if you modify its contents (with curves, etc.). Anyway, if it seems to work to you, go ahead :)

Carlos, the V channel is "un-elegant" in the sense that there is no real correspondence to the perceived luminance or color, it is more or less a mathematical measure that has some loose relationship to brightness. But using V from HSV does have the advantage to exhibit colors that otherwise go away in both HistogramTransform or L-processing with CurvesTransform. So to me there seems to be quite some merit to this "un-elegance".  ;)

I have the impression that using the V-push procedure outlined in http://pixinsight.com/forum/index.php?topic=1689.msg9779#msg9779 ís the best color preservation strategy I have found so far. But I am still uncertain why it is not a standard procedure that can be found in PI and other tools. Are there hidden problems? Your comments are welcome.


Cheers,

Georg

Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: True Colors
« Reply #10 on: 2010 February 19 12:19:58 »
Don't take me wrong. If I have to play with mud, I do :D The tuxido is for formalities only ;)
(just joking about "un-elegancies"...)

I guess that the way this channel is builded has so little to do with actual color or brightness, and there is so little one can "theorize" with it, most serious developers just avoid it. This may be a case where the practical use may prove to be enough to give it a more in deep try :P
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: True Colors
« Reply #11 on: 2010 February 21 08:54:27 »
Hello,

I have created a script that will do this HSV-based histogram transform for you. I call it V-Transform because it changes the V-component only. The script is no doubt buggy, since I just did a quick and dirty implementation of the idea. But it provides a preview functionality and all the sliders you need for some experiments. The script is attached below.

Also attached is a screenshot where I applied Histogram Transform (top) and the V-Transform script (bottom) to my M42 test data with the goal to get similar results. Clearly, the V-Transform image is much more colorful.

I would love to hear what you find when you apply the script on your data. Give it a try!  :)

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: True Colors
« Reply #12 on: 2010 February 21 09:01:17 »
Hi Georg,

You couldn't email me your original M42 FITS?

I would like to have a look at the V-transform and see why, or if, it performs better than the equivalent L-transform (either by colour separation, or just via the Curves process).

Cheers,
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: True Colors
« Reply #13 on: 2010 February 21 09:26:28 »
Hi Niall,

You couldn't email me your original M42 FITS?

Sure, you can have it. A crop of the relevant region is on http://cid-c56e60845cfa6790.skydrive.live.com/self.aspx/Pixinsight/m42_30_800.cal_small.fts (5 MBytes fts file).

Enjoy!

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: True Colors
« Reply #14 on: 2010 February 23 10:46:16 »
Hello all,


here is another try of the V-Transform, this time on a part of the Cirrus Nebula. Left is the V-Transform result, right is the traditional HistogramTransform. In the HistorgramTransform version, Cirrus is slightly more colorful, but I lost almost all color in the stars. The V-Transform version shows the color of the stars, while color in Cirrus is somewhat reduced.

I think this nicely shows the strength of this procedure especially for bright objects (like the center of M42 or the star field). Those loose a lot of color when treated with the HistogramTransform.

I imagine that the V-Transform should work very nicely on star clusters, showing the different star colors. I dont have any raw material for these, maybe someone else will give it a try.

Cheers,

Georg
« Last Edit: 2010 February 23 11:12:10 by georg.viehoever »
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)