{"id":731,"date":"2015-02-19T19:45:03","date_gmt":"2015-02-19T19:45:03","guid":{"rendered":"http:\/\/trappedphotons.com\/blog\/?p=731"},"modified":"2020-03-06T14:07:17","modified_gmt":"2020-03-06T14:07:17","slug":"pixinsight-star-removal","status":"publish","type":"post","link":"http:\/\/trappedphotons.com\/blog\/?p=731","title":{"rendered":"PixInsight Star Removal"},"content":{"rendered":"<p>Removing the stars from your image can be done for artistic purposes or to separate the nebulosity from the star field so it can be processes differently. &nbsp;Removing the stars&nbsp;is highly dependent on a good star mask. &nbsp;There&#8217;s a couple tricks to getting an accurate star mask. &nbsp;The first is using MultiscaleMedianTransform to kill the larger structure sizes. &nbsp;If your image is in color already, I normally extract the lightness data from it (see Figure 1) to use as a support image for creating the star mask. &nbsp;I typically rename this image star_mask_support.<\/p>\n<p><a href=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure011.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-732\" src=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure011.jpg\" alt=\"Figure01\" width=\"602\" height=\"188\" srcset=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure011.jpg 602w, http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure011-300x94.jpg 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/a><br \/>\n<strong>Figure 1: Extracting lightness data<\/strong><\/p>\n<p>Next, I bring up MultiscaleMedianTransform and make sure it&#8217;s reset to the default settings. &nbsp;Then I disable the residual layer (see Figure 2) and and set the Target to Lightness (CIE L*). &nbsp;You may have to change the layers (while keeping the residual layer disabled) depending on your star sizes. &nbsp;For the data I&#8217;m working with, 4 layers worked quite well. &nbsp;There will typically be a little nebulosity or galaxy structure left after running this. &nbsp;I use the clone stamp tool to remove the the non-stellar stuff before creating a star mask.<\/p>\n<p><a href=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure021.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-733\" src=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure021.jpg\" alt=\"Figure02\" width=\"384\" height=\"587\" srcset=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure021.jpg 384w, http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure021-196x300.jpg 196w\" sizes=\"auto, (max-width: 384px) 100vw, 384px\" \/><\/a><br \/>\n<strong>Figure 2:&nbsp;MultiscaleMedianTransform used to remove larger structures<\/strong><\/p>\n<p>The second trick is to make several star masks to catch the different star sizes (see Figure 3). &nbsp;This part takes a lot of fiddling. &nbsp;I don&#8217;t touch much in the Mask Preprocessing section except the Midtones. &nbsp;For the Mask Generation section I typically leave all options off and vary the Smoothness based on the star sizes I&#8217;m trying to re-create (if the start to look square, I up the value some). &nbsp;The other parameters just take experimentation.<\/p>\n<p><a href=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure031.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-734\" src=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure031.jpg\" alt=\"Figure03\" width=\"800\" height=\"369\" srcset=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure031.jpg 800w, http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure031-300x138.jpg 300w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><br \/>\n<strong>Figure 3: Three passes of StarMask to capture different star sizes<\/strong><\/p>\n<p>Now that you have several different star masks we need to combine them. &nbsp;I like to use PixelMath to do this. &nbsp;Some people use addition but I think that throws things off when you have the same star represented in multiple scale levels, so instead I use the max function (see Figure 4). &nbsp;This way the brightest elements of all three star masks will be combined into on mask. &nbsp;I typically apply this to the image called star_mask and then close the others.<\/p>\n<p><a href=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure041.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-735\" src=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure041.jpg\" alt=\"Figure04\" width=\"500\" height=\"405\" srcset=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure041.jpg 500w, http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure041-300x243.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><strong><br \/>\nFigure 4: Combining star masks with the max function in PixelMath<\/strong><\/p>\n<p>Now that we have an accurate star mask we can start removing stars. &nbsp;Apply your star mask to your image (leave it non-inverted) and then bring up the MorphologicalTransformation tool (see Figure 5). &nbsp;We are going to use the erosion mode which will shrink the stars, pinching in the surrounding data as the star reduces in size. &nbsp;Apply MT to your image and you&#8217;ll see the stars get smaller and fainter. &nbsp;Once the stars are almost non existent I switch back to MMT to smooth out the result a little (see Figure 6). &nbsp;Basically invert the layers you had disabled when creating the star_support image, so if you were using 4 layers before with the residual disabled switch that so the first four layers are disabled and the residual is enabled (if your image is in color remember to switch the target to RGB\/K mode). &nbsp;Figure 7 shows a sequence of how the stars were reduced in this image where the first 6 tiles were using MT and the last 2 using MMT.<\/p>\n<p><a href=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure051.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-736\" src=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure051.jpg\" alt=\"Figure05\" width=\"325\" height=\"446\" srcset=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure051.jpg 325w, http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure051-219x300.jpg 219w\" sizes=\"auto, (max-width: 325px) 100vw, 325px\" \/><\/a><strong><br \/>\nFigure 5: MorphologicalTransformation in Erosion mode<\/strong><\/p>\n<p><a href=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure071.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-738\" src=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure071.jpg\" alt=\"Figure07\" width=\"384\" height=\"587\" srcset=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure071.jpg 384w, http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure071-196x300.jpg 196w\" sizes=\"auto, (max-width: 384px) 100vw, 384px\" \/><\/a><strong><br \/>\nFigure 6:&nbsp;MultiscaleMedianTransform being used to remove stars<\/strong><\/p>\n<p><a href=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure061.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-737\" src=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure061.jpg\" alt=\"Figure06\" width=\"1600\" height=\"198\" srcset=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure061.jpg 1600w, http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure061-300x37.jpg 300w, http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure061-1024x127.jpg 1024w\" sizes=\"auto, (max-width: 1600px) 100vw, 1600px\" \/><\/a><strong><br \/>\nFigure 7: Sequence of star reduction<\/strong><\/p>\n<p><a href=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure081.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-739\" src=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure081.jpg\" alt=\"Figure08\" width=\"1024\" height=\"466\" srcset=\"http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure081.jpg 1024w, http:\/\/trappedphotons.com\/blog\/wp-content\/uploads\/2015\/02\/Figure081-300x137.jpg 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><br \/>\n<strong>Figure 8: Side by side comparison after star removal<\/strong><\/p>\n<p>If you are really having trouble getting an accurate star mask, then there&#8217;s one other trick you can try. &nbsp;It requires that you plate solve your image and use that as a reference for the CatalogStarGenerator script. &nbsp;I only use this as a last resort because the catalogs frequently do not include all the star in the field. &nbsp;But if you simply can&#8217;t separate the stars from the nebulosity in your image this technique might help.<\/p>\n<p>I hope this is useful!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Removing the stars from your image can be done for artistic purposes or to separate the nebulosity from the star field so it&hellip;<\/p>\n","protected":false},"author":1,"featured_media":737,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[5,4],"tags":[],"class_list":["post-731","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pixinsight","category-tutorials"],"_links":{"self":[{"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=731"}],"version-history":[{"count":2,"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/731\/revisions"}],"predecessor-version":[{"id":1291,"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/731\/revisions\/1291"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/737"}],"wp:attachment":[{"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=731"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/trappedphotons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}