PixInsight Forum (historical)
PixInsight => General => Topic started by: Jack Harvey on 2007 December 20 07:03:10
-
The thread on Ha combine brought up the topic of star shaping, something I am not doing too well at. I usually apply a star mask and then use either a Dilatation filter on Morphological Transform or use Atrous Wavelets but set the Bias to a negative number. My goal is to soften the edges of the stars so they do not look so sharp and punched out from the deconvolution or wavelets used to sharpen the detail inn the object.
I am very interested in the workflow and techniques of others.
--------------------------
El hilo de combinar Ha planteado el tema de la configuración de estrella, algo que no estoy haciendo demasiado bien en la dirección. Suelo aplicar una máscara de estrellas y, a continuación, utilizar un filtro de Dilatación en Morphological Transform o el uso Atrous Wavelets pero el conjunto Bias a un número negativo. Mi objetivo es suavizar los bordes de las estrellas, para que no mire tan fuerte y puñetazos a cabo a partir de la deconvolución o los wavelets utilizadas para afinar los detalles del objeto posada.
Estoy muy interesada en el flujo de trabajo y las técnicas de los demás.
-
Hi Jack,
I get the best results with a Morphological Selection filter. This filter gives you the power to regulate the strenght of the dilation / erosion filter. In this filter, a value of 1 means a pure dilation filter, and a value of 0 means a pure erosion filter.
To do a star shaping process, try a selection filter with a valur of ~0.2, a small opacity (~0.1) and many iterations (perhaps 7 or 8). All this with an active star mask, of course.
Another tip... Try to do the star shaping before applying any process that affects the star shapes. Once you have bright white disks, it's hard to recover the smooth profile of the stars.
And another tip... Many times, when I have an image with a huge dynamic range, I do a progressive midtones raising, applying each time a mild star shaping process. The final result is usually very good.
Good luck!
Vicent.
-
Let me be sure I am understanding as to how to set this filter
Morphological Filter
Operator: Dilation{Maximum}
Interlacing: 1
Iterations: About 7
Amount: 2.00
Selection: No choice as is greyed out
Structuring Element
Size 17
Way 1 of 1
And I selected CIrcular Structure in the buttons
Thresholds Both at 0.00000
-
Hi Jack :)
No, what Vicent suggest (and what I use) is:
Morphological Filter
Operator: Selection 0.2 (or Minimum)
Interlacing: 1
Iterations: About 7 (or up to 10)
Amount: between 0.1 and 0.2
Selection: 0.2 if not using the Minimum
Structuring Element
Size 3x3 or 5x5
Way 1 of 1
CIrcular Structure or Diamond
You may try two ways, one with a circular structure, and the other with a diamond.
Thresholds Both at 0.00000
-
Morphological Filter
Operator: Morphological Selection
Interlacing: 1
Iterations: About 7 (or up to 10)
Amount: between 0.1 and 0.2
Selection: 0.2 if not using the Minimum
Structuring Element
Size 3x3 or 5x5
Way 1 of 1
CIrcular Structure or Diamond
You may try two ways, one with a circular structure, and the other with a diamond.
Thresholds Both at 0.00000
_________________
Another option is to apply the morphological filter many times with less iterations, alternating circular and square structures, to better preserve the circular shape of the stars.
Vicent.
-
Now I think I got it. Thanks
-
I have been using this to shape stars as you guys have suggested. I now note there is a slot <Unnamed> that would seem to suggest that once you set a profile you can save it. How do you do that? Thanks
-
Hello Jack,
Where it says <Unnamed>, type a name for your structure --use a name that can help you later in remembering what the structure is intended for. Then click the Manage button, and the Structure Manager dialog will open.
On the Current Structure section you'll see the name you have given before. Click the Save button to add the new structure to the current structure set module (.ssm file) that you are using. By default all structures are saved to the default.ssm file, which comes with a set of useful predefined structures. Unless you are using lots of custom structures, it's normally a good idea to use this default module.
If you save your own structures in this way, make a backup copy of the .ssm file before installing a new version of PixInsight, because it will be overwritten. (this is something that we have to fix in future versions...).
Cheers,
Juan
-
I did the above and save the StarShaping ssm. When I returned the Morph filters to the default settings then tried to load the newly created Star Shaping by going to Manage, selecting the Star Shaping ssm and hitting Load I did not see the parameters in the Morphological box change to what I had defined as Star Shaping???
-
Jack,
You must select a structure on the Structure Manager dialog, in the Available Structures section. Just select the desired structure with the combo box, then click the Pick button.
-
Ok I tried that and it did insert the 5x5 circular structure name into the name slot. However the above parameters stayed at defaults values and did not switch to the Star Shaping values I saved
Default Star Shaping
Minimal Morph Selection
Interlacing 1 1
Iterations 1 9
Amount 1.0 0.20
Selection greyed out 0.15
-
This is normal. What is saved in the .ssm file is just the structuring element. You can use a structuring element with any morphological filtering parameters.
To save all your settings, you must create a process icon from the MorphologicalTransform window (you know, the blue triangle). Then you can save the icon to a .psm file. You can easily build a good library of MorphologicalTransform icons in this way.
Hope this does the trick for you ;)
-
Thanks Juan I should have figured that out. Appreciate the help.
-
Hi guys,
I have been following this discussion about star shaping with great interest.....I can never get perfectly round stars! :cry:
Question 1: I have tried the various methods above with some success, but its usually quite variable. The first question is about the use of the Morphological erosion filter. On one of my images all the stars were slightly sqashed in the vertical direction looking a bit like a rugby ball lying on its side. I tried the erosion filter with different structure elements with limited success....until I used a 9x9 structure and actually painted on some extra squares to make it look the same shape and orientation as the shape of the stars. Hey presto, a few iterations and the stars were smaller, rounder (very close to true circles) and brighter...close to being ideal.
However, I've tried it since with nothing like the same success. Was I just lucky the first time, or is this how the structure element works? If so, then is there a way to automate it (sample a standard star in the image?). If this was just luck, then how do I know what shape element to pick?
Question 2: I have been heavily processing some images of M42 to try and bring out some very very faint nebulocity inspired by seeing Wade's Halpha image on the gallery (what a picture!!!). My pictures (3 x 5min subs) were taken with a very cheap Tamron 500mm F8 mirror lens on a Canon 400D, so bringing out any of the faint nebulocity was quite a challenge. At one point I overdid the processing on some of the regions and washed out some of the small faint stars. I had lost the history, (d'oh) so rather than start again I created a star mask of the original. I think I used Growth and Comp = 1 (or 0?) to stop the stars from growing. This gave me nice pinpoint, circular stars....but they were white, obviously no colour information in a starmask. So I then used pixelmaths to give me a new image (the original multiplied by the starmask) which resulted in sharp coloured stars. I could then use Pixelmaths again with an iif statement to put the new stars on the final image only where they had been lost.
Now this is really a fiddle as far as I am concerned. The stars are totally (well almost) fabricated. However, the result was very nice. :D .
So I was wondering if this could give any ideas as to an elegant way of automatically improving star shape, effectively by using some of the features of the starmask...i.e. lovely circular stars with the right relative intensity, size, cross-section and position.
Just a thought.
Cheers
Simon
-
Simon I am still struggling also with this. What works for one image will not work for the others and sometimes nothing seems to work without leaving a bunch of artifact. So I am still not convinced on this technique.
Of course nothing can improve on getting nice round stars to start with by good polar alignment and guididng and absence of wind etc. But occasionally Murphey intervenes and you get irregular stars.
Hopefully more advice to come<G>.
In fact it would be instructive if you coluld submit a crop of some of your irregular stars and see if some of the PixInsight Team members could make a step by step tutorial showing the setting used and results.
-
Hi Jack,
Yes, perfect guiding, no wind, no Murphy.....a man can dream :D
I have had another go with another image that had stars slightly extended towards the 2 O'clock and 8 O'clock directions. Again I tried drawing a structure that mimicked this, and hey presto it worked quite well. All the other directions just made things worse.
So I am starting to convince myself that this is how you can use the element shape facility in the morphological feature. But I await confirmation from the PI guys that this fits with the theory...or whether Murphy is just doing a double bluff.
I'll put together a few examples of odd shaped stars tomorrow.
Cheers
Simon
-
Hi Simon
1)
Indeed, morphological filter is a way to go to make the stars rounder, if the deformation is not too big. I mean, it will work very well for slight tracking errors, and some kinds of coma, but it is not perfect. The way to go is simply to draw a shape that resembles the star, or the deformation, just like you should do with a deconvolution.
For example, if you have those rugby balls (vertically), you may try a structuring element like this one:
B W B
B W B
B W B
B = black, W = white
(or 0 and 1...)
One quick way to understand how the morphological filters work, is just making the question: Which is the "%" pixel defined by this neighbourhood? So, the answer, is that the algorithm looks around every pixel, only for those defined as white in the structuring element, and writes the result in a new (temporal) image. By "%", I'm talking about the minimum, maximum, median or any other "statistical" operator (and combinations of them, like closing, aperture, and the not yet implemented skeleton).
The morphological filter has other meanings when working with binary images (pure black and white), from where comes the name "structuring element" for the neighbourhood definition.
So, more than just simply copying the shape of the star, we must know exactly what we want to do, and how to build the structuring element.
When we use multiple ways (more than one structuring element) the partial results are averaged, and the final result is copied to that temporal image. This kind of procedure works well with small structuring elements, and where the effect we want to emulate cannot be builded with the rigid definition performed by the binary structuring element. For example, for the star shaping routine, I'm using these days one way with a square 3x3 kernel (another word for the structuring element) and a 3x3 cross one.
Having said of all these, there is another kind of morphological filters, which I plan to implement this year, that makes uses of grayscale structuring elements. Here the interpretation is not as straight as looking at a neighbourhood, and the filter has some drawbacks (like the overall "bias" is changed"), but may prove to be a good alternative for this procedure.
Of course, you may always try a deconvolution too. The best way to apply it is to the raw data.
If you are not that "orthodox", you may try mixing mild amounts of the morphological filter and a deconvolution. I've used several iterations of a minimum filter and the Wienner deconvolution to make slight out of focus stars brighter in the center, and smaller in size.
Of course, make use of masks to avoid artifacts in other zones of the image. Another tip, using the minimum filter is not always a good idea... you may end with "black holes" in your image. It is better to use a selection, something in the 0.1 to 0.3 range.
2)
This sounds like a "brute force" solution :D
I'll think on something that dramatic to fix star shapes, but it will be a challenge ;)
In most cases, the secret is just to build a good star mask, either with the StarMask process, or manually from the luminance. Since in my workflow I almost always perform a separation between large scale and small scale features, modifying the last is a quick way to build the mask. I just have to raise the black point (with histograms) to leave only stars in the image, and then I blur it a little bit with wavelets. If needed, a closing morphological operator (minimum + maximum) may be used as a intermediate step at the end, to select a minimum size of the stars to be modified. Since I apply a star shaping routine (like the one described by Matt Bendaniels in his web, using several iterations of the minimum filter, at 0.1 amount, and increasing the saturation with curves) just to the bigger stars, a 7x7 or bigger, circular, structuring element is my choise.
Hope this helps... if not, please show me the way to go :D
-
Hi Carlos,
Many thanks for the thorough response. A few points....I agree, everything depends on getting the masks right. I think I've read a number of times in the tutorials and other places in the forum the importance of being able to mask at every stage, and this is something I am now doing with great effect. That's really one of the things that makes PixInsight so powerful in my view.
Regarding your explaination of how the Morphological filter actually works...many thanks for this. This really confirms what I had suspected, but its really nice to have it spelt out by someone who really knows.
Would it make sense to be able to somehow put a square around a single (typical) star and make that the kernel for the filter? And the same would apply to the deconvolution process. Being able to just sample a star from the the actual image might be a very handy addition.
I've done a lot of experimenting with the deconvolution method....and I like the "elegance" of this approach. The problems I seem to have are;
1. The centres become very bright very quickly and can lead to millions of equally blinding pinpoint stars very quickly. And dynamic range extension seems to leave dark rings around the base. I'm using a starmask, so dynamic range extension might be great for the centre of the star, but what is it doing to the background?....is this being decreased during the dynamic range extension process? If so then this would lead to dark rings around the stars. Is there a way of avoiding this, i.e. of getting the background within the starmask to remain the same after deconvolution and dynamic range extension as the background it started with?
2. Again, with an odd shaped star (maybe some guiding error, or maybe a slight flaring) the deconvolution can actually enhance the oddness of shape by packing more intensity into the odd bits rather than evolving towards a nice circle. I can increase the standard deviation and change a few other parameters to give a nice round shape, but these make the stars bigger rather than tighter. Making stars bigger is not a problem, I can do that easily! :lol:
I've tried combinations of morphological filters and deconvolutions, but again without too much sucess. If you start with a nice circular star that is slightly out of focus then I am sure that these will work very well. However, when you start with a slightly odd shaped star then the deconvolution only exaggerates the oddness.
Regarding the "brute force" solution.....I agree wholeheartedly that it is as subtle as a flying brick and about as elegant as a pig in high heels. But it really does seem to do a good job. Here's an example I threw together.....
So here's some crappy stars...the sort I would never be guilty of creating, but other users might :lol: I've really used an agressive colour saturation for clarity....
(http://homepage.ntlworld.com/simon.hicks3/Images/Badstars.jpg)
Here's really tight starmask
(http://homepage.ntlworld.com/simon.hicks3/Images/starmask.jpg)
created using the following settings
(http://homepage.ntlworld.com/simon.hicks3/Images/starmask_setting.jpg)
Note the small smoothness, the zero growth and zero comp values....I want smaller stars, not bigger.
I then ustilise the colour from the original stars simply by using PixelMath and multiplying the badstars image by the starmask image to give
(http://homepage.ntlworld.com/simon.hicks3/Images/BadstarsxStarmask.jpg)
I then want to replace the bad stars in the first image with these stars. So I create another starmask with more typical default settings (i.e. larger, softer openings) and then apply many iterations (maybe 10!) of an erosion mask to try and obliterate the stars out of the image. There are probably more elgant ways of doing this with wavelets, but this will illustrate the point. This leaves the following image...
(http://homepage.ntlworld.com/simon.hicks3/Images/masked_2nd_erosion.jpg)
Note that this could be done much better with wavelets and would provide some much needed background smoothing as well....but carrying on.....the next step is to insert the nice fabricated stars onto this image.
I did this with PixelMath and used a simple iff statement of the form;
iff(nicestars>badstars,nicestars,badstars)
and this gave the following image
(http://homepage.ntlworld.com/simon.hicks3/Images/Nicestars.jpg)
Now most of the brighter stars have been replaced with nice small, round, perfectly coloured stars and they have roughly the correct intensity relative to each other....and the background has not been effected in anyway.....except maybe during the erosion process to obliterate the badstars....but this could be done more elegantly. And these stars should be ideal for subsequent stretching or other manipulation.
I might try this subtle brick approach in a bigger way when the clouds finally lift from the Glasgow area and I can get some actual images to play with.
But I just wonder if there is a way of using something from all of this in a more elegant way?
Just a thought.
Cheers
Simon
-
Hi Jack and Carlos,
I have been playing with the star masking module and pushing it in extreme ways for the above purpose...and realised what is probably obvious to you guys...that this module is relying heavily on wavelets. The PI software really uses these in powerful ways.
So I was wondering if the star shaping could be done better without the starmask module...but just using the underlying wavelets processing. You might still use the starmask module to section off the following processing from the other regions, but not use it to directly create false stars...if you see what I mean.
I first found some bad shaped stars....again nothing to do with me :wink:
(http://homepage.ntlworld.com/simon.hicks3/Images/Badstars2.jpg)
I then applied some ATrousWaveletTransform. I used a 5x5 guassian, put an X by layers 1 to 4 and put layer 5 to +1 with Deringing to maximum. This gave....
(http://homepage.ntlworld.com/simon.hicks3/Images/Badstars2w.jpg)
So the above made the bad star shapes into nice big round stars. I then applied 2 iterations of the morphological erosion with a 9x9 circular kernel to give....
(http://homepage.ntlworld.com/simon.hicks3/Images/Badstars2we.jpg)
This results in nice small circular (ish) stars. But these are a bit dim, so I then applied 20 iterations of a regularised Richardson-Lucy deconvolution to give.....
(http://homepage.ntlworld.com/simon.hicks3/Images/Badstars2wed.jpg)
So the final image has massaged the bad star shapes into much nicer shapes. I'm sure that with a bit more effort they could be tightened further, but this illustrates the point.
I don't actually claim to have invented this technique as I am pretty sure I have seen reference to it somewhere in the forum, and you guys have probably already been doing this for years....I've just discovered it for myself.
Its certainly much quicker and simpler than the previous technique I described, and its also much less 'brute force' like. I think the stars have lost some of their colour though.
Cheers
Simon
-
Hi Simon
Sorry for the delay. I've been quite busy these days, so I had not the time to sit down and write a complete answer. Please have a little more patience.
-
Sorry Carlos....I can be known to race off at a tangent sometimes. Its exciting learning all this new stuff and I'm keen to try out new processes.
I shall now shut up, back away from the keyboard and be patient. 8)
-
Hi Simon :)
I think I've read a number of times in the tutorials and other places in the forum the importance of being able to mask at every stage, and this is something I am now doing with great effect.
Well, I'm not of the opinion that every stage should be masked... but indeed if properly used it will show a significant improvement. The key point here, as always, is to know exactly what you are doing, and what do you want as a result. Image processing is not like cooking a cake, following instructions. It is more likely to the work of a sculptor. You have to uncover the David from the stone :); follow the path the image shows.
Would it make sense to be able to somehow put a square around a single (typical) star and make that the kernel for the filter? And the same would apply to the deconvolution process. Being able to just sample a star from the the actual image might be a very handy addition.
You may try something like this... make a preview over a star, create a new image with it, and use the Binarize process to make it black and white (convert it to grayscale before it). Now manually copy the shape into the MorphologicalFilter's Structuring Element.
As I said earlier, a more refined way to do this, with a "grayscale" structuring element is not possible with the current algorithm. We may find a way to solve this... or just implement the "standard" grayscale morphological transforms I described to you in the previous post. To put it in simple words, one adds or substracts the structuring element to the image, and then looks for the statistical value that is desired. The problem, as is quickly shown, this leads to a change in the overall brightness, it is not just a change in the size of the structures. I have some ideas in mind to partially solve this... but since this process is not a priority right now, it must wait :)
Now, about deconvolution. What you said has been implemented with the first release of both processes: Deconvolution and WienerDeconvolution.
Just look, under the PSF section, for the External PSF tab. There you may include a view as a PSF. The way this works is slighty different for both processes. Deconvolution needs square images, grayscale, while Wiener works with any kind of images.
A word of caution: using a star as the PSF theoreticaly is the best option, but in the practice the results may not be good. Experiment modifying it with morphological filters, curves and the histogram. Also, it is important that the star has been very well centered on the image to be used as PSF, or the deconvolved image will be shifted.
1. The centres become very bright very quickly and can lead to millions of equally blinding pinpoint stars very quickly. And dynamic range extension seems to leave dark rings around the base. I'm using a starmask, so dynamic range extension might be great for the centre of the star, but what is it doing to the background?....is this being decreased during the dynamic range extension process? If so then this would lead to dark rings around the stars. Is there a way of avoiding this, i.e. of getting the background within the starmask to remain the same after deconvolution and dynamic range extension as the background it started with?
To protect star centers use a inverted luminance mask (and the star mask as the deringing support).
Here is a quick explanation on how the dynamic range extension works. Internally, all pixels are handled as floating point numbers, or in other words, as real numbers. It doesn't matter if they go out of range, because they are just numbers, and not interpreted as pixel values. If you set it the lower boundary to "S", and the upper to "H", that "real valued" image will be rescaled so S will be zero, and H 1 (mathematically, [img-S]/[H-S]). Then, every pixel out of the new normalized range values will be clipped (will become 0 or 1). So, if you just increase the extension for the highlights, the image as a whole will be darkened. Imagine that we set it in a way that 2.0 will be the point for white values... when rescaled, the image will be divided by 2, so the brightness will be the half for every pixel. If you are using a star mask, and their sizes are larger than the star itself, you'll see that "ringing" or donut effect. This is just a problem with the mask (or it's combination with the extension). You may try to increase the extension for the shadows, to compensate the effect... but this will leave artifacts if the stars are surrounded with nebulosities or other features that vary the "background" brightness.
A best solution is to fine tune the mask... or don't use it at all (I'm talking about a Star Mask... a mask based on the luminance may prove to be much better in this case). As I said above, use StarMask to build deringing supports for the Deconvolution process, mainly, but I would not trust in it too much as a suitable mask (if you are not capable of fine tune it... I'm not :D, Juan is the expert with that tool).
2. Again, with an odd shaped star (maybe some guiding error, or maybe a slight flaring) the deconvolution can actually enhance the oddness of shape by packing more intensity into the odd bits rather than evolving towards a nice circle. I can increase the standard deviation and change a few other parameters to give a nice round shape, but these make the stars bigger rather than tighter. Making stars bigger is not a problem, I can do that easily!
The PSF is not the ideal image you want to generate. It is the model of the deformation the image underwent to reach the current state. So, this is why it is said that the stars are the "perfect" choise to build PSFs... they are supposed to be (ideally) point sources, so their shape is exactly how the image have been degraded. In the real world, matching exactly the stars with the PSF does not give the optimal results, but indeed is a very good starting point. In your case, instead of using a star as external psf, try to reproduce that shape with the gaussian options (change the ratio and angle, and keep the standard deviation low. Change the function order if needed). Another option, that works well if you have traking errors parallel to the x or y axis of the chip, is to use a motion blur psf. Because of pixel discretization, this doesn't work very well for other angles.
Now about your method. Seems to work very well, but there are lots of faint stars that have not been reshaped. What I'd to is to use morphological filters (with and without masks) to erase all stars, and even other small scale features (also, blur it a little disabling some wavelet layers). Do it to a duplicate of the image. Now, using PixelMath, apply: "img-deletedstars", without rescaling, and create the result as a new image. Close the "blured" image.
That new image will contain all the bright, high frecuency features. Now, again with PixelMath, apply "img-stars", againg without rescalling. The result will be all the large scale features, and the dark high frecuency (small scale) ones.
Process the small scale image to get rounder stars, and then add the result to the large scale image, rescaling the result. This should work ;)
About your second approach, a note: you may create star masks (with the exact current shape) with wavelets disabling the residual layer, and setting all other deringing parameters to the maximum. You'll have to use a trial/error process to find how many layers to discard (or, in other words, where the residual layer is), and which is the best scaling function.
Now, your method works well, but has some side effects... I would try to blur the star just a little bit, and make use of morphological filters to make them rounder before deconvolution. Also, you may try several iterations of this procedure, instead of a crude single processing. BTW, this is exactly the idea behind noise reduction. It works better by slowly approaching the solution, than getting it straight with a strong blur. The same happens with iterative deconvolution algorithms, like Richardson-Lucy. ;)
Thank you very much for your motivation to find another ways to perform these tasks. This is exactly what motivated us from our very beggining: beeing a "source" for innovations and imagination. Please keep those ideas coming. Who knows? maybe we'll end with a new process automating all of this, thanks to your ideas :D
PS: I'll work a with your sample images, and see what happens.
-
Hi Carlos,
Wow, you have really explained a lot there and clarified a lot of different aspects for me. I really appreciate the time and effort you have gone to to explain this. I will read your comments very carefully a number of times and do some experimenting with your suggestions. I'm excited about what the next image will look like!
Many thanks
Simon