The attached file, I am hoping, can be saved to where you normally keep your Process Icons (or wherever). It defines a Pixelmath function that can stretch your images and can be loaded under the Process-Process Icons-Load Process Icons.
GenHypStretchv1.xpsm
Alternatively, you can load the following into Pixelmath via copy and paste into the expression editor.... Two sections, between the, not include the ***s....
Into RGB/K:
*****
iif(b==0,EC=1,EC=0);
iif(b>0,Ds=D*b,Ds=D);
iif(b>0,bs=b,bs=1);
iif(EC==1,q0=exp(-Ds*SP),q0=(1+Ds*SP)^(-1/bs));
iif(EC==1,qWP=2-exp(-Ds*(HP-SP)),qWP=2-(1+Ds*(HP-SP))^(-1/bs));
iif(EC==1,q1=2-2*exp(-Ds*(HP-SP))+exp(-Ds*(2*HP-SP-1)),q1=2-2*(1+Ds*(HP-SP))^(-1/bs)+(1+Ds*(2*HP-SP-1))^(-1/bs));
iif($T<SP,EC*exp(-Ds*(SP-$T))+(1-EC)*(1+Ds*(SP-$T))^(-1/bs)-q0,iif($T>HP,2-EC*(2*exp(-Ds*(HP-SP))+exp(-Ds*(2*HP-$T-SP)))+(1-EC)*(2*(1+Ds*(HP-SP))^(-1/bs)+(1+Ds*(2*HP-$T-SP))^(-1/bs))-q0,2-EC*exp(-Ds*($T-SP))-(1-EC)*(1+Ds*($T-SP))^(-1/bs)-q0))/(q1-q0);
****
& into symbols:
****
D = 1.0;
b =0.5;
SP =0.00;
HP =1.00;
Rnorm;
q0;
qWP;
q1;
Ds;
bs;
EC;
*****
So what does it do?
You may be suprised at what these little equations can do for stretching...
I consider image stretching my make or break process in creating an image - unfortunately it is generally hit-or miss for me. In an effort to potentially improve upon and parameterize image stretching, I have put together a Pixelmath sequence to stretch images in a natural, but controllable manner, that in my initial testing, is showing to improve upon the multiple use of curves or histogram stretch and is easier to duplicate than "hand drawn" curves, or my previously favourite method - Arcsinh stretch + Curves.
The basis of this stretching are general hyperbolic decline decline/growth functions used in empirical forecasting of natural time series processes such as nuclear decay (exponential), chemical reaction rates (concentrations, catalyst site availability), oil,gas, and water well production decline (Arps (Arps, not Arp) equations), and even epidemiology.
I believe that the general hyperbolic stretch routines are suitable to for stretching (even in extremes) due to the properties that: they are piecewise continuous given natural look to the result, their first derivative is always positive (will always maintain the rank order of pixel intensity - avoiding multiple stretch artifacts such as backwards stretches) and piecewise continuous (will avoid spike and backwards stretch situation that can arise with curves), are normalized to run between 0 and 1 and will never "clip" data. In its basic form, the equations provide a stretch to the lower intensity pixels (increasing the contrast), while decreasing the relative contrast at high intensity pixels. Note that this is always the trade-off with stretching, as whatever stretching function is applied from 0 to 1 intensity level, the average slope must equal 1.
In base form, two parameters control the stretch: "D" and "b", with the maximum stretch intensity (dynamic range extension) occuring at 0 intensity (darkest part of image) and continuously reducing to the right hand side of the historgram. In this way, the left side of the histrogram has its contrast between pixels increased while the right hand side has it increased. D is used to control the amount of stretch that is applied in a give application. The equations will accept any value of D>0 (with 0 meaning no stretch/change at all) and 10 being the maximum that I find you can routinely use while controlling the results and <1 used to tweak results and final adjustments. Shown here, is the stretching function, with b=1 for various values of D - the degree of stretching:

If you have used curves before to stretch your image, you would likely have created such a curve within the Curves Process. Particularly with large stretches, using handdrawn points joined by spline can lead to significant artifacts. Not so with these equations, they are precisely and accurately defined everywhere and you will get an exact stretch within the digital precision being used.
The other parameter "b" can be thought of as the "stretch intensity", or how focused the actual stretch is around a single point. For bigger b, the stretch will be greater focused around a single intensity, while a lower b will spread the stretch around. Mathematically, a b=0 represents a pure exponential stretch, while 0<b<1 represents a hyperbolic stretch, b=1 is a harmonic stretch, and b>1 is a highly intense, super-hyperbolic stretch. I find keeping b<2 useful, unless the image has very poor dynamic stretch. Here for a constant D of 2, is the effect of changing b:

As b is increase, the contrast around 0 pixel intensity is increased the most through range expansion - this is at the expense of constrast for high intensity pixels, where stretching reduces contrast. Think of b and D as the trade-off between the two. D is the blunt instrument, controlling how much stretch is used, and b is the surgical instrument - controllling how focussed the stretch is at, in this case, 0 intensity. Early in the stretch, you will be inclined to to use a large factor for D and b.
Two additional parameters are defined: SP and HP. SP which defaults to 0 specifies the pixel intensity at which the maximum stretch is applied. Here is the effect of SP on the stretch function for various values of b and SP.

The b factor will control how focused the stretch will be at that point, and the level of b can be determined by examining how spread out the histogram is. If it is narrower, then use a larger value of b. The way to use SP and b is either use the target image to find the intensity level where you would like to increase contrast the most, and set SP to this intensity level - It should also be the place on the histogram where the slope is greatest. If you want narrowly increase the contrast at this point, use a higher b. If it is a more general level of contrast increase, set b to a lower level. Finally, the histogram peak (mode) location along with the image itself will indicate how much stretch to apply via D.
HP which defaults to 1, is a method to reserve dynamic range for the stars, or the higher end of the intensity charge. Here some charts for various values for b and HP so you can see what the effect is. If you want to increase contrast to the brighter parts the

Stars can easily be overstretched, so it is not uncommon to use a HP value as low as 0.6 or 0.65 to protect high intensity stars with halos. Ideally HP should be set between the values of the brightest nebula and the intensity of the dimmest halos in danger of bloating. A level where there is already a large amount of contrast is best. Alternatively, if stars are already are clipped at 1, or are close to it, using a value of HP>1, can create some room to stretch these stars by controlling their brightness (again no clipping by the stretch routine will occur). Other ways of dealing with bright stars exist, such as removing the stars and stretching independently. Another is to invert the image (so that bright stars appear dark), then stretch this low area using this Pixelmath routine, trying to keep nebulosity intact, and then re-invert the image.
That's it, I could talk endlessly on how to do more complicated things with this stretch, but I was interested if anyone wanted to try it out. I, myself, have just created this function, and will be trying it out (other than testing) on some real image processing shortly. If you would like to try it, I suggest trying it on some of your own unstretched images and play with it. Please provide feedback though - and show me some images.
One last problem:
I would love to have these equations actually draw the curves (as you see above) like is done in the Curves Transformation Process in Pixinsight - show the before and after histograms (I now use Histogram Transformation for this), and actually show a preview image - much like Histogram. However, I never learned Javascript (although I do know C++), and don't have the skills to put this into a Pixinsight script or process. If I could, I would and I believe that would make this a great tool. If you know how, and have some time, let me know.
I hope this is useful to you.
Dave