Hi Jack,
Before continuing, I must say that our HDRComposition script is light years above that procedure in sophistication and accuracy. Yes, HDRComposition eats memory and runs extremely well on a 64-bit version of PixInsight, not so well on 32-bit versions with less than 4 GB of RAM. When we implement it as a regular process most of these memory problems will be overcome.
Open a Long duration and a short duration Master of one channel
File > Open

Let's rename the images as L and S for the sake of simplicity in PixelMath expressions.
Normalize the long duration to the short duration
Normalization is a multipurpose word that can refer to many different things. In this context, normalization could be done in this way:
(L - Med(L)) * AvgDev(S)/AvgDev(L) + Med(S)
applied to L with the
rescale option disabled. This expression will do two things:
- Scale the long exposure to adopt the average signal levels of the short exposure.
- Replace the mean background of the long exposure with the mean background of the short exposure.
There are other ways to do this, but I personally tend to favor average deviation (the AvgDev function) as a robust estimator of dispersion. Of course, your images must be in either a floating point format or in 32-bit integer format, or you'll probably lose some data.
Set a limit to reject all pixels above a certain value (i.e. 40,000) and execute on the Long duration
Grow the rejection by 2-6 pixels
Now execute what they call Replace Missing Values
The "Grow the rejection" part involves building a mask and applying a dilation filter. This would be quite easy to do, but I don't understand why growing a rejection mask is of any use here, and I in fact can see a lot of problems and very few advantages by doing so (but I may be missing something here). Ignoring this part, your task would be simply:
iif( L > 40000/65535, S, L )
applied to L with rescale enabled. This expression simply replaces L with S where L is above 40000 in the 16-bit range. Since we have previously scaled L to have the same signal levels and background as S, both images are statistically compatible. The final rescaling is useful here to ensure maximum usage of the available numerical range.
Set the image weight of the Short duration to 0.00001
I think this makes no sense if you perform the combination with a PixelMath expression as above.
Combine the two images with a Mean or Average
Better than this would be an adaptive combination. This can be done very easily with a variant of the above PixelMath expression:
iif( L > 40000/65535, L*S + (1 - L)*L, L )
There are other variants that we can explore, for example a weighted combination. But first let's see if any of these can work out something useful
