It is currently Fri Aug 07, 2026 8:17 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 19 posts ] 
Author Message
 Post subject: Hello all
PostPosted: Sat Oct 30, 2021 4:20 pm  (#1) 
Offline
GimpChat Member

Joined: Oct 30, 2021
Posts: 20
Hi and thanks for having me.

I have been using Gimp to process my astrophotography images. My reason for signing up is that I need some better tool to remove gradients - Gimp's gradient tool is too limited and ends up introducing new gradients. I need to select points representative of the background gradients and do a polynomial interpolation so I can be done in one sweep.

My plan is to do this in Python. I'm a bit concerned as there are few documentation links to the Python interface so I'm hoping it is not deprecated. Then, can I use it with Python 2.7 or Python 3 and what if I need numpy, can I use an Anaconda installation?

Any recommendations are welcome.

Henk


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Hello all
PostPosted: Sat Oct 30, 2021 7:05 pm  (#2) 
Have you tried: Color> Components> Extract Component or, Color> Components> Decompose?


Top
 Post subject: Re: Hello all
PostPosted: Sat Oct 30, 2021 7:05 pm  (#3) 
Offline
Administrator
User avatar

Joined: Aug 10, 2012
Posts: 14145
Location: Native to NYC living in Arizona, Gimp 2.8 - 3.0, Win 11 PC.
HenkSB wrote:
Hi and thanks for having me.

I have been using Gimp to process my astrophotography images. My reason for signing up is that I need some better tool to remove gradients - Gimp's gradient tool is too limited and ends up introducing new gradients. I need to select points representative of the background gradients and do a polynomial interpolation so I can be done in one sweep.

My plan is to do this in Python. I'm a bit concerned as there are few documentation links to the Python interface so I'm hoping it is not deprecated. Then, can I use it with Python 2.7 or Python 3 and what if I need numpy, can I use an Anaconda installation?

Any recommendations are welcome.

Henk

I think there are a handful of people here, that might know what you're looking for.
Welcome to Gimp Chat HenkSB.
Please feel free to elaborate further within the forum about your usage of Python.

_________________
Image
"A wise man learns more from a foolish question than a fool can learn from a wise answer"
Image


Top
 Post subject: Re: Hello all
PostPosted: Sat Oct 30, 2021 7:53 pm  (#4) 
Offline
GimpChat Member

Joined: Oct 30, 2021
Posts: 20
Pocholo wrote:
Have you tried: Color> Components> Extract Component or, Color> Components> Decompose?

Yes I have. It is not very helpful because the information is only displayed for one color at a time which makes the problem three times harder IMHO. A color gradient is a continuous function in 3 dimensions and can be manipulated in one combined figure. I don't mind that part of the current gradient removal. The problem is that the gradient is constructed in parallel lines which is inadequate for my purpose.

Another place where something similar bugs me is the Curves dialog. I use that more than anything else especially for color balancing but I find it hard to use. What is lacking is a separate color balancing dialog like Deep Sky Stacker has where the histograms can be manipulated while seeing all color histograms in one figure. Seeing one histogram at a time as the Curves dialog does, makes it much harder. It would be helpful if such a dialog existed. Also, a log scale in the X direction would be nice for astrophotography because on a 32 bit scale the photons for faint nebulosity are all the way to the left.

And last on my wish list is something to make stars smaller. Erode works but when you apply it a few times it starts breaking up. Luckily there is a tool named StarNet++ that removes all stars and is helpful to fix such issues because you can edit the stars separately. That's all!


Top
 Post subject: Re: Hello all
PostPosted: Sat Oct 30, 2021 10:09 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
HenkSB wrote:
And last on my wish list is something to make stars smaller. Erode works but when you apply it a few times it starts breaking up.


Welcome to gimpchat,
Did you tried Filters/Distorts/Value propagate... ? https://docs.gimp.org/2.10/nl/gimp-filt ... agate.html
It works by 1pixel (Ctrl+F to repeat as needed), for smaller stars maybe try "Mode black", in all case you will need to tinker and experiment.
Value propagate works well on a mask as well.

_________________
Patrice


Top
 Post subject: Re: Hello all
PostPosted: Sat Oct 30, 2021 11:32 pm  (#6) 
Offline
Global Moderator
User avatar

Joined: Apr 01, 2012
Posts: 8448
Location: On the other side of your screen
Welcome HenkSB to Gimp Chat. :)
Make your 5 posts quickly then you can post an image for us to look at - let us know what needs to be done to it and we will try to do it giving you the directions to do so, using gimp.

_________________
Image
Free Fun Photo Editing & resources
Poems from the Lord
Gimp Newby
Gimp version 3.2.4 and GMIC-Qt 4.0.2 OS :- Windows 10 Home 64


Top
 Post subject: Re: Hello all
PostPosted: Sun Oct 31, 2021 11:28 am  (#7) 
Offline
GimpChat Member

Joined: Oct 30, 2021
Posts: 20
sallyanne wrote:
Welcome HenkSB to Gimp Chat. :)
Make your 5 posts quickly then you can post an image for us to look at - let us know what needs to be done to it and we will try to do it giving you the directions to do so, using gimp.

That's very nice, thanks! So, since a moderator is asking, here's post 3...


Top
 Post subject: Re: Hello all
PostPosted: Sun Oct 31, 2021 11:28 am  (#8) 
Offline
GimpChat Member

Joined: Oct 30, 2021
Posts: 20
HenkSB wrote:
sallyanne wrote:
Welcome HenkSB to Gimp Chat. :)
Make your 5 posts quickly then you can post an image for us to look at - let us know what needs to be done to it and we will try to do it giving you the directions to do so, using gimp.

That's very nice, thanks! So, since a moderator is asking, here's post 3...

And post 4...


Top
 Post subject: Re: Hello all
PostPosted: Sun Oct 31, 2021 11:29 am  (#9) 
Offline
GimpChat Member

Joined: Oct 30, 2021
Posts: 20
HenkSB wrote:
HenkSB wrote:
sallyanne wrote:
Welcome HenkSB to Gimp Chat. :)
Make your 5 posts quickly then you can post an image for us to look at - let us know what needs to be done to it and we will try to do it giving you the directions to do so, using gimp.

That's very nice, thanks! So, since a moderator is asking, here's post 3...

And post 4...

And post 5. Next up will be an image. Sorry about the spam!


Top
 Post subject: Re: Hello all
PostPosted: Sun Oct 31, 2021 12:00 pm  (#10) 
Offline
GimpChat Member

Joined: Oct 30, 2021
Posts: 20
sallyanne wrote:
Welcome HenkSB to Gimp Chat. :)
Make your 5 posts quickly then you can post an image for us to look at - let us know what needs to be done to it and we will try to do it giving you the directions to do so, using gimp.

Here's an image. I stretched it in DSS (Deep Sky Stacker) quick and dirty, no smoothing, and saved it in Paint as JPG to reduce the size.

Image

The image has purple, blue and green hues in various directions. I know I can fix it by using gradient removal, I have vast experience with that, but it's not what I want because I have to do this all the time, it also creates gradients and it is just too much work. I would like to have control over where the interpolation is done by selecting non-star and non-nebulosity areas, individual points if I have to.

My typical workflow is to start with the stacked image (this one has 60 x 2 minute ones I believe and has been stacked with flats and bias frames in DSS, from a Redcat51 with an ASI2600MC on an AVX). The result is a 32 bit image that has to be stretched at least once to see enough detail. I use curves for that. It is important to keep the white point where it is or else you blow out the core. During the stretching usually the gradients show up from light pollution of the city and the neighbors.

Sometimes I'll remove all stars using StarNet++ so I can work on the nebulosity without messing up the star colors, then blend the stars back in through a new layer. Sometimes I use a star mask using Threshold and a manual selection (with value inversion and multiplication) to blur out all non-star and non-nebulosity parts then subtract it to remove the gradients. But star masks have side effects (ringing stars).

Gradient removal is important. There is a plugin for PS named Gradient xTerminator that is sold commercially and does only that, there is IRIS that does it, others use Astro Pixel Processor, pixInSight, or AstroArt, usually a variety of editors to get the job done. I prefer to use just Gimp and want to see what I can achieve with Python.

Thanks for helping out!


Top
 Post subject: Re: Hello all
PostPosted: Sun Oct 31, 2021 12:27 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jul 06, 2013
Posts: 2662
Location: California
Welcome to the forum! :)


Top
 Post subject: Re: Hello all
PostPosted: Sun Oct 31, 2021 12:49 pm  (#12) 
Offline
GimpChat Member

Joined: Oct 30, 2021
Posts: 20
PixLab wrote:
HenkSB wrote:
And last on my wish list is something to make stars smaller. Erode works but when you apply it a few times it starts breaking up.


Welcome to gimpchat,
Did you tried Filters/Distorts/Value propagate... ? https://docs.gimp.org/2.10/nl/gimp-filt ... agate.html
It works by 1pixel (Ctrl+F to repeat as needed), for smaller stars maybe try "Mode black", in all case you will need to tinker and experiment.
Value propagate works well on a mask as well.

I did a quick try and was impressed in first instance but when I zoomed in I noticed the same as with repeated Erode namely it creates square blobs and distorts the stars significantly. Here's an example,

Image

Thanks for the advice though, I may end up using it.


Top
 Post subject: Re: Hello all
PostPosted: Mon Nov 01, 2021 2:20 am  (#13) 
Offline
Global Moderator
User avatar

Joined: Apr 01, 2012
Posts: 8448
Location: On the other side of your screen
DCP Dehaze will get rid of most of it It's in the plugin GMIC under details
Attachment:
7662_m31_dss_forGimp_small.jpg

Or you could try levels in gimp
Attachment:
7662_m31_dss_forGimp_small (1)levels.jpg

you could also try
duplicate layer, then use burn/linear burn mode
Attachment:
7662_m31_dss_forGimp_small (1)dup layer mode burn.jpg

_________________
Image
Free Fun Photo Editing & resources
Poems from the Lord
Gimp Newby
Gimp version 3.2.4 and GMIC-Qt 4.0.2 OS :- Windows 10 Home 64


Top
 Post subject: Re: Hello all
PostPosted: Mon Nov 01, 2021 11:39 am  (#14) 
Offline
GimpChat Member

Joined: Oct 30, 2021
Posts: 20
Thanks SallyAnn for trying to solve this! The result is a rather orangey though, it looks liek you pulled out all blue from the nebulosity.

I just finished a Scilab script that does the job very well. Let me show what it does in steps. Here's the original image:

Attachment:
m31_dss_forGimp_small.jpg
m31_dss_forGimp_small.jpg [ 4.85 MiB | Viewed 3275 times ]


Basically, I did a Free Select around the nebula in Gimp, filled it in with white, then did a Threshold to select most of the stars, then a Value Invert to return the negative mask to basically selects the non-stars. It looks like this:

Attachment:
m31_dss_forGimp_smallMask.jpg
m31_dss_forGimp_smallMask.jpg [ 2.96 MiB | Viewed 3275 times ]


If you look closely you can see a new line introduced, this is because I did the thresholding in two steps based on the star density. The math will take the average of the non-black areas eventually so it does not affect the gradient intensity later on. The basic image for gradient estimation is obtained by multiplying the original image with this mask:

Attachment:
m31_dss_forGimp_maskedBackground.jpg
m31_dss_forGimp_maskedBackground.jpg [ 4.33 MiB | Viewed 3275 times ]


Then I ran the gradient estimator that I wrote in Scilab. It is based on a least squares estimate using Chebyshev polynomials (for numerical robustness). I tell it how many data points I want for each polynomial parameter. Based on this, it chops up the image in cells, also accounting for the blacked-out area. It collects the average data for each cell and also constructs the Chebushev regression variables for it. Then it performs a least squares for each color and composes the estimated gradient. It looks like this:

... oh shoot, 3 images is the maximum. Let me post this then continue.


Top
 Post subject: Re: Hello all
PostPosted: Mon Nov 01, 2021 11:44 am  (#15) 
Offline
GimpChat Member

Joined: Oct 30, 2021
Posts: 20
So here's the resulting estimated gradient:

Attachment:
grad.jpg
grad.jpg [ 2.06 MiB | Viewed 3274 times ]


Subtracting this from the original (after maximizing the gradient to the old image to prevent negative values where the gradient values are larger than the original, I get the image with gradient removed:

Attachment:
newImg.jpg
newImg.jpg [ 4.57 MiB | Viewed 3274 times ]


This is quite nice! I don't know if this is beginner's luck but my Scilab script worked wonderfully on this example.

The reasone why I picked Scilab and not Python is because Scilab is made for math and avoids the complexities of using numpy and scipy. Furthermore, Gimp's Python does not have those anyway. I suppose I could write a Python wrapper to call Scilab from Gimp so I can keep working with the Scilab script. Let me see how this works out.


Top
 Post subject: Re: Hello all
PostPosted: Mon Nov 01, 2021 12:36 pm  (#16) 
Offline
GimpChat Member

Joined: Oct 30, 2021
Posts: 20
Actually I just improved it a little. In my fiirst try I included all blacked-out areas in the least squares estimation, which was unintended, and makes the gradient dive down in those areas. As a result it maintains too much nebulosity around the borders. Here's the fixed version, gradient and final image.

Attachment:
grad.jpg
grad.jpg [ 2.18 MiB | Viewed 3270 times ]


Attachment:
newImg.jpg
newImg.jpg [ 4.56 MiB | Viewed 3270 times ]


Top
 Post subject: Re: Hello all
PostPosted: Mon Nov 01, 2021 9:31 pm  (#17) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
I think you are doing a hell of a great job with the Andromeda galaxy, you also got a very nice definition of M32 and M110, the result is gorgeous! :clap

_________________
Patrice


Top
 Post subject: Re: Hello all
PostPosted: Wed Nov 17, 2021 4:51 pm  (#18) 
Offline
New Member

Joined: Oct 17, 2021
Posts: 4
Hello! I am Valentina came to you to learn more about the Gimp. I really like working here, but I don't know much yet. I have version 2.8 for the latest version so far I do not dare to switch.


Top
 Post subject: Re: Hello all
PostPosted: Wed Nov 17, 2021 9:10 pm  (#19) 
Offline
GimpChat Member
User avatar

Joined: Jul 06, 2013
Posts: 2662
Location: California
Welcome to the forum! :)


Top
Post new topic Reply to topic  [ 19 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group