PixInsight Forum (historical)
PixInsight => Tutorials and Processing Examples => Topic started by: troypiggo on 2014 August 05 05:43:37
-
Update to the below:
There are some images and colour combinations that did show odd results. Check out my post further down this thread (http://pixinsight.com/forum/index.php?topic=7377.msg49571#msg49571).
Now I'm using the following formulae, just boosting G to the min of R and B. See the link above for effects on a colour wheel showing how it much better targets just the magenta.
R: $T[0]
G: iif(min($T[0],$T[2])>$T[1],min($T[0],$T[2]),$T[1])
B: $T[2]
The attached zip file has been updated to use this formula.
---------------------------------------------
Original post:
Not sure if this has been done before, but I had this idea recently on how to get rid of the magenta stars in SHO narrowband images due to the red SII and blue OIII channels needing to be stretched so much to balance strong G Ha. A common Photoshop method I've seen is to do a selection based on colour (magenta), and desaturate it.
It occurred to me that with PixelMath we may be able to achieve something like this. We could detect if a pixel is magenta by checking if it's R and B channels were of similar value (within some acceptable range), and if they both were significantly brighter than the G channel.
With this in mind, I came up with the following formulae. I found some stars needed a luminance rule in there too.
R: $T[0]
G: iif((CIEL($T)>MIN_BRIGHTNESS)||((min($T[0],$T[2])/(max($T[0],$T[2])>MAGENTA_DEFN))&&(mean($T[0],$T[2])>$T[1])),mean($T[0],$T[2]),$T[1])
B: $T[2]
Symbols: MAGENTA_DEFN = 0.9, MIN_BRIGHTNESS = 0.9
Attached are some sample before and after images (not my images, but have sought the approval of the image owners where possible. Some were from a Google image search). Seems to work ok to me. Thoughts? Any improvements or suggestions on the above?
I'm just hoping it is a quick and simple solution to what seems to be a common issue with narrowband images. Just drag and drop the attached process icon on your final narrowband image with magenta stars and they're gone.
-
I am just beginning to collect narrowband data and I will add this to my list of threads. Nice work.
-
Troy,
Nicely done! Will try this out on some of my old NB images at let you know how it works.
Best,
Jim
-
Troy!
Very nice idea and PixelMath Expression!
Gerald
-
really nice work! i think this was the last piece of the puzzle for my for PI NB processing.
rob
-
Replacing G with Mean(R, B) will boost the pixel's luminance. This maybe OK or not. If not, all components could be scaled down. The scale factor would be something like the CIEL luminance ratio cubed (or cube-rooted?) so to appropriately linearize the ratio.
Mike
-
Mike,
For us who are NOT pixelmath experts, could you go into a little more detail on how you would apply your proposed fix?
Thanks!
Jim
-
Troy,
I hope you don't mind but I am going to include this in the next version of my cribsheet. This is too good to pass up.
Thanks again!
Jim
-
Hi Troy,
Good PixelMath-Fu! :)
-
Replacing G with Mean(R, B) will boost the pixel's luminance. This maybe OK or not. If not, all components could be scaled down. The scale factor would be something like the CIEL luminance ratio cubed (or cube-rooted?) so to appropriately linearize the ratio.
True. I've been experimenting with that to try to keep the input and output luminances the same, but nothing got the consistent results that the above formula did. I'll keep trying to come up with something.
Don't suppose you know the relationship between the individual channel values and the lum? It's not additive as I'd expect.
For us who are NOT pixelmath experts, could you go into a little more detail on how you would apply your proposed fix?
I'll go back and edit the first post with more explanation when I get a chance.
Troy,
I hope you don't mind but I am going to include this in the next version of my cribsheet. This is too good to pass up.
Thanks again!
No worries at all.
-
For us who are NOT pixelmath experts, could you go into a little more detail on how you would apply your proposed fix?
Jim
Jim,
Actually my suggestion probably won't work. Preserving luminance, as I was thinking, might not make sense, since input luminance itself might be too high due to the RB bloat. Not sure what to do.
Mike
-
Mike,
Thanks anyway. As an old liberal arts major (and I do mean old), you guys who can do the math fascinate me.
Best,
Jim
-
Troy, et al., Cool! It might also be useful to expand SCNR's capabilities to include Magenta and Cyan. Most cases, we'd still want to use a star mask, but we'd be able to target magenta stars that way. Of course, we do have both ColorSaturation and Curves/Saturation enabling us to reduce or alter a specific range as well.
-
G'day Warren. Not sure what you mean about SCNR?
What I liked about the PixelMath solution is that no star masks are needed at all, so no risk of halos. You just drag n drop the process icon on you full, unmasked image.
-
OK, stupid question time,
I am trying to access the process Troy provided in the zip folder but don't know where to put it to get it working :-[
Can somebody just remind me where to access the unzipped file from.
Sorry for the early onset dementia,
Jim
-
You can put the file in the zip anywhere , as long as you remember where. :) in PI, right click and choose "load process icon" and navigate to the file. A process icon called " magenta_ star_reduction " should appear. Just drag n drop that on your image. Double click to see the actual PM window with formulae etc.
-
Troy,
Thanks loads :embarassed:
Jim
-
Ok. Greatly simplified the formulae, and it targets the magenta specifically which is great. Will work best on images before you do any colour shifting to get the teals and golds, as it relies on the relationship between R and B. It simply boosts the G value to the minimum of R and B.
R: $T[0]
G: iif(min($T[0],$T[2])>$T[1],min($T[0],$T[2]),$T[1])
B: $T[2]
Images below show it's effect on a colour wheel. Note the previous versions of the formula affected much more of the colour wheel.
-
Troy,
Great stuff, and I even know how to write that in PixelMath :o
Best,
Jim
-
Works very well.
Thanks Troy.
Mark
-
Got a chance to test. Works great! Thanks much. Len
-
Excellent! I'm so glad others are finding it useful.
-
I must admit I don't drop in on the forum very often......but to find this gem! Brilliant....saves a lot of work and messing around (not knowing what I am doing....and in another program at that!).
Thank you so much for sharing!
Kinch.
-
Super useful, Troy, thanks so much! I'll definitely add this to my bag of tricks. Anyone feel like putting this together into a script or process? ;)
-
Josh, there's a zip file in post #1. In it there is a saved process icon that you can load, then just drag and drop on your image.
-
Perfect! Serves me right for jumping to the second page... I was just looking for your most up-to-date formulation. Nicely done!
-
Troy,
Works very well. Thanks for your work.
Jon
-
First of all: thanks a lot - this is superhelpful!!!
I only found one problem that I don't know how to fix: if I have a bright star in front of a darker region, this makes the halo of the star really noisy. Here is an image before applying this formula: http://2.bp.blogspot.com/-kHl7WhMoY4w/VAz9-0v5T-I/AAAAAAADM5E/XPeVoUAT4YI/s1600/star%2Bpre%2Bmagenta%2Breduction.JPG
And here is it afterwards: http://1.bp.blogspot.com/-G7XFEdDSwZI/VAz9-1tJjTI/AAAAAAADM5I/UYxErqCPgYA/s1600/star%2Bpost%2Bmagenta%2Breduction.JPG
I tried to do something with masks, but it seems as if the problem is that the magenta halo fades into the background and just replacing those pixels creates some noise.
Any ideas are appreciated!
Thanks
MarkS
-
G'day. What the PixelMath formula does is desaturate (make gray) the magenta part of the spectrum, and this has worked on your image. What you're calling noise is colours that are more blue than magenta, and they are remaining untouched by the formula. That's why you're getting deep blues and grays appearing like noise. I fear that changing the formula too much will start affecting other areas of the image that you don't want to change (eg nebulosity).
I'll have a play with the formulae to see if we can add some factor to increase or decrease how much of the reds and blues get affected.
-
here's a version that will kill cyan. i've sometimes had problems with cyan halos when dealing with certain refractors and lenses...
rob
-
Nice add!
-
Works great! Thanks!
-
Silly question time. Do you apply the Pixel Match formula to the whole image or to one that has been star-masked?
-
Not a silly question at all. PixelMath works on a pixel by pixel basis, and this expression just converts every pixel that is magenta to gray. So if the only magenta in your image is halos around stars, you can apply to whole image. But if, for some reason, there's magenta in other parts of your image (like nebulosity) that you may want to keep that colour in, you'd be best to use a star mask so it only applies to the magenta around the stars.
-
I'm just beginning to try to understand PixelMath expressions, so please forgive my ignorance.
Pertaining to this expression:
G: iif(min($T[0],$T[2])>$T[1],min($T[0],$T[2]),$T[1])
I understand this to be saying:
1. Assuming for an SHO combination, $T[0] = SII, $T[1] = Ha and $T[2] = OIII
2. The first argument is comparing the lower of the minimum pixel sample values of SII and OIII to Ha's minimum pixel sample value. The result is either a 1 or a 0.
3. The inline IF statement is saying If the first argument is 1, then G is set to either SII or OIII, which ever has a smaller minimum pixel sample value.
4. However, it the first argument is 0, then G is set to Ha.
If this is correct, there seems to be a possibility that my PixelMath combination will completely ignore my Ha image.
Or am I reading this all wrong?
Incidently, I used this PixelMath expression in my last effort and was highly pleased with the elimination of my purple stars. So I must be mis-interpreting how the expression is evaluated. Help!
-
Hi jlmanatee!
Its simple. Magenta is visible when green is to low.
Therefore Ha is used for the green part to increase green when there is magenta.
Or, Magenta is produced out of red and blue.
when the lowest value in the actual pixel of the red and blue channel is
higher than the Ha (green) then the pixel is magenta and should be increased
by the higher Ha value...
Gerald
-
I must be pretty thick. Yes, I understand that magenta is produced out of red and blue. What I don't understand is the PixelMath formula. If I read it correctly (I doubt myself) the G channel formula's outcome will just be Ha, SII or OIII and not some combination like .2*OIII + .8*Ha or whatever. As an example if I run the numbers with one of my own set of subframes, Ha would be completely ignored because the minimum pixel sample value of my OIII is smaller than my Ha or SII. If this were true, my PixelMath would evaluate to being an SOO, not an SHO. But, like I say, this can't be right. Here's my end result in this particular case. (with all modesty, my best work to date - be kind)
http://cdn.astrobin.com/images/solutions/84ec7986-d799-42d9-8794-37b3f98a180b-1507338624.png
-
what you are saying is true; the pixelmath may evaluate to SOO... but what you are missing is that because of all the conditionals, only the magenta colored pixels are converted to SOO. when all the conditions fail, G (which is T[1]) is assigned to T[1], so everywhere where the pixels do not look magenta, the images is still SHO.
rob
-
Ah, the light bulb is starting to glow. Dimly. Thanks Pfile.
What's really happening (I think) is a pixel-by-pixel determination. That's why they call it PixelMath - Duh. T[0], T[1] and T[2] are decided upon "per pixel" and not as a whole channel necessarily. Mind Blown. More wrapping my head around this to come.
-
yes absolutely, the pixelmath expression is evaluated at every single pixel in the source image(s). you can even use the position of the pixel as one of the inputs to a conditional expression to gain further control over what happens. for instance if you wrote iif(x() > 100, 0, $T), you'd end up with an image that has a 100 pixel-wide vertical strip of pixels from the original image, and the rest of the image black.
rob
-
Ah, the light bulb is starting to glow. Dimly. Thanks Pfile.
What's really happening (I think) is a pixel-by-pixel determination. That's why they call it PixelMath - Duh. T[0], T[1] and T[3] are decided upon "per pixel" and not as a whole channel necessarily. Mind Blown. More wrapping my head around this to come.
Yes, you've got it. Pixel by pixel. Looks like you were thinking the whole image in each channel was getting adjusted, but it's just each pixel.
G: iif(min($T[0],$T[2])>$T[1],min($T[0],$T[2]),$T[1])
The expression looks at each pixel. If the G isn't strong enough, the pixel is magenta=R+B, boost it to the min of R and B. Keep in mind the intent of this expression is for use with SHO images, where the nebulosity and background are typically greens/yellows/browns, and the magenta is usually just a halo around the stars. So the expression has no effect on the nebulosity, just the magenta around the stars - no need for star masks etc. The effect of increasing the G value to that of R or B in magenta areas is basically to desaturate it, as all 3 channels end up becoming very close values.
It is a sledgehammer approach. So if you use it on a standard RGB image instead of SHO, and there's magenta elsewhere in nebulosity (maybe M42 for example?), it will desaturate the nebulosity, too. So in those instances, maybe a star mask would be wise. Only reason I can think of where you'd be doing this, though, might be for magenta/green chromatic abberations around bright stars, for example.