Using MIPAV for astronomical image processing

From MIPAV
Jump to: navigation, search

If we look at image processing from the mathematical perspective, all digital images (no matter how they were acquired) are just arrays of numbers that can be manipulated by image processing software. Across different fields of study, image processing applications, however developed for very specific needs, often use similar routines based on common image processing algorithms.

MIPAV is a very flexible image-processing package. It is platform-independent and free. Although it was intended for medical image processing, it also supports various non-medical imaging formats including FITS, which is used in astronomy. The software has a particular emphasis on image analysis and offers a number of tools for data reduction and image calculation, which can be used in deep sky and planetary imaging. MIPAV has a well-developed “plugin” interface, that allows users to write their own plug-ins. MIPAV has a very active user community that already contributed many freely available plugins, some of which are very useful for astronomy.

Why astronomy?

The following features makes MIPAV a good choice for use in astronomy:

  • It supports both FITS and raw formats, as well as many others including TIFF, JPEG, etc.
  • It has an extensive used documentation in a form of public wiki including instructions for beginners, advanced users and tutorials.
  • It is free.
  • One can write one’s own plug-ins.
  • MIPAV algorithms are more mathematically “transparent” than those used in commercial packages such as Adobe Photoshop or MaxIm DL.
  • The MIPAV API JavaDoc is publicly available for the benefit of developers who are coding against MIPAV public methods, such as those who are interested in creating custom plug-ins.
  • MIPAV keeps the image provenance information in the .xmp files (which is an XML format file). The .xmpl file has the same name as the image file and it keeps a log of all transformations performed on the image, including time, date, algorithms used and parameters applied and even transformation matrices. I found this very helpful.

Topic outline

This topic outlines the technique that can be used for processing galaxy images. MIPAV algorithms were used for both astronomical data reduction and for making “pretty pictures”. Two case studies are presented.

Case study 1 explains how to use MIPAV to reduce the galaxy photometry data from the given sample of multi-band image of M51 – Whirlpool Galaxy from McDonald Observatory. Raw images from R, B and V filter were processed and combined into a single image of M51. The image processing included noise reduction, cropping, scaling, alignment, and creating a single multi-color image of a given galaxy. The result was compared with the result received from processing the same dataset in MaxImDL ver 5.

Case study 2 explains how to use MIPAV to reduce the galaxy photometry data from the given sample of multi-band image of M63 – Sunflower Galaxy from McDonald Observatory. Raw images from R, B and V filter were processed and combined into a single image of M63. The image processing included noise reduction, cropping, scaling, alignment, and creating a single multi-color image of a given galaxy.

Data files

The images used in this project were reduced from raw images received from McDonald observatory.

Images used in the project include:

  • 5 Bias Images
  • 5 flat field images for each filter (R, B and V)
  • No dark frames provided
  • 2 light (science) frames for filter (R, B and V) for M51, M63, NGC4258, and NGC4725

Image file format

All image files are in the Flexible Image Transport System (FITS ) format.

Images were obtained using the 2048 x 2048 LoralFairchild CCD camera mounted on the McDonald Observatory 0.8 meter Prime Focus telescope.

Assumptions

The following assumptions were made while doing image reduction:

  • The dark current was negligible. For each filter, flat frames were exposed at nearly the same time as the science * images.
  • Exposure times are not necessarily balanced correctly between filters.

Case study 1 - M51 galaxy image processing in MIPAV

M51 RGB image created in Adobe Photoshop from 3 monochromatic images (R, B, and V) processed in MIPAV

M51 (NGC5194) is also known as Whirlpool Galaxy was discovered on October 13, 1773 by Charles Messier. Its spiral structure was first determined by Lord Ross in 1845. M51 is a face on spiral galaxy which allows us to see it spiral structure in full detail. M51 is made from two galaxies, where NGC5194 is the larger galaxy and NGC5195 is its smaller companion. Redshift measurements have shown that NGC5195 is located at the same distance from Earth as NGC5194. Both galaxies are probably interacting gravitationally and the large gas and dust halo that surrounds the distorted disk of NGC5195 confirms that suggestion. The blue color in the spiral arms of NGC5194 indicates active star formation, which might be triggered by the gravitation interaction of 2 galaxies.


Image processing log

Image reduction is a technique that applies to the raw data in order to remove known, repeatable sources of system noise, such as dark current from thermally excited electrons, bias signal, pixel-to-pixel sensitivity variations, and variations due to different artifacts on mirror/device surface, due to dust particles and/or design imperfections.Below is a step by step log of image reduction performed in MIPAV. The final images were compared with the images created in MaxImDL ver 5 from the same dataset.

1. Open bias, flat and science images. MIPAV automatically recognizes FITS images. To open RAW images, specify the image dimensions (2080x2048), bin information and image type which should be USHORT or better ARGB_ushort.

Using the Crop Using Boundary parameters dialog to remove 10 px overscan regions from bias, flats and science images

2. Remove overscan regions from bias, flats and science images. Use Crop Using Boundary Parameters tool to crop 10 pixels overscan from the right side of each image. Save images in FITS format.

3. Create the master bias frame by combining several frames into a single master bias frame. Use the Image Calculator Bulk Images- Average algorithm. The algorithm assumes that the noise in the images is uncorrelated and has a zero average value. Save images in FITS format.

4. Subtract the master bias frame from all flat frames (B fats, V flats and R flats). Use the Image Calculator-Subtract algorithm. Save calibrated flat images (flat-bias) in FITS format.

Calibrating flat field images using the Image Calculator dialog box

5. Create a master flat frame for each filter images (Bs, Vs, and Rs) from step 4. In this data set we have 5 flats from each filter. In order to create the master flat, we need to calculate a mean or average value image from all (flat-bias) images for each filter (R, B, and V) step 4. That can be done by either using the Image Calculator Bulk-Images - Average tool. Save result master flats for each filter in FITS format.

Creating a master flat image using Image Calculator-Bulk Images

6. Calibrate all science images using the following equation (science image from the specific filter (R, B, or V) – master bias)/(master flat of the same filer from Step 5). Use Image Calculator to perform this operation for each science image. Do it in 2 steps, first do (science image from the specific filer (R, B, or V) – master bias), and then divide the result image on the master flat of the same filer. Save calibrated science images in FITS format.

7. Manually remove bad pixel(s) from each calibrated science image. This could be done by using the Paint tool. Use the Paint to highlight “bad” pixels and then use Paint to Mask option to convert a painted region to a mask. The tool allows to use eyedropper to set the pixel intensity value or to manually enter the desired intensity value (e.g.the mean value from neighbor pixels). Another option is to replace pixel/voxel value with an interpolated value. Save improved science images in FITS format. The same operation can be also done by using the Replacing pixel value tool.

8. Co-align the calibrated science images from each filter: first all R (2 images), then all B (2 images) and then 2 V images using the Landmark Least Squares algorithm - the algorithm provides a way for registering an image to the reference image by using 3 corresponding point VOIs placed in both images. I used 3 stars as points of references. This algorithm registers images that require rotation and translation. Save images in FITS format.

9. To reveal fine detail apply the Unsharp Mask algorithm to each science image. Although the photometry is not preserved, unsharp mask is a very effective tool for extracting fine detail in deep sky images. It makes sense to perform the unsharp mask filter on the individual science images before combining them into the final image. This technique allows the harder unsharp mask filter to be used initially. By combining the images afterwards, the effects of the filter are averaged out and the final result looks more natural.

Applying Unsharp Mask to M51V image

10. Stack the co-aligned science images from the previous step, by adding each pair of science images using the Image Calculator Add tool. This will also create an enhanced image.The result M51 V image processed in MIPAV and MaxImDL ver 5 is shown on your right. Note that MIPAV image has a different orientation, but that could be corrected by editing the image attributes in the Image Attributes dialog box.

M51Vcropped.jpg M51VisualMaxImDLsmall.jpg
M51V image processed in MIPAV M51V image processed in MaxImDl ver.5

11. Improve the result image contrast using the Look up table tool. Lookup table (LUT)- maps the frequency distribution in a histogram to pseudo-color values. In MIPAV, a look up table plays the role similar to stretching in MaxImDL. It allows to remap the original intensities to monitor intensities or to other intensities. LUT indicates what number is to be substituted for each pixel value during the processing of the image, however processing with a LUT does not change the image. One of the advantages of LUT digital processing is that the processing parameters (factors) can be selected to produce images with contrast characteristics need. For more information, refer to Changing Image Contrast topic of this WIKI.

Using the Blackbody LUT to improve contrast for M51 V image in MIPAV

Combining science images using alpha-blending

To compare galaxy image taken through different filters, one can load 2 science images (e.g. B and R or R and V, etc.) in the same image frame and then compare them using alphablending. MIPAV alphablending is a technique that adds transparency information to translucent objects. When two images share the same frame, one can adjust the alphablending settings so that to see a blend of both images and can compare overlapping regions in two datasets. The level of translucency for one image is inversely proportional to the other.E.g., if image A is 75 percent transparent (25 percent opaque), then image B is 75 percent opaque (25 percent transparent).

M51 V (Image A) and M51 B (Image B) images are combined using alphablending, A/B ratio is 0.5/0.5


Noise reduction

MIPAV offers a variety of noise reduction algorithms. For example the following algorithms (either one or in combination) can be applied to the image to reduce noise and to reveal fine detail:

I would suggest to experiment with these filters. Refer to M51V image after applying various noise reduction/fine detail techniques below for some examples.

M51V image after applying various noise reduction and detailzation techniques

M51VisualOriginalSmall.jpg M51VisualUnsharpSmall.jpg M51Visual nlnoisereductionSmall.jpg
M51 in V band after general processing in MIPAV. Refer to Image processing log steps 1-11 M51 in V band after applying Unsharp mask with the following parameters:Scale of Gaussian -X-dimension=0.5, Y-dimension=0.5, Weight of Blurred Image = 0.75 M51 in V band after applying Unsharp mask first and then Nonlinear Noise Reduction with the following parameters: Brightness Threshold = 3200.00; Gaussian mask SD =0.5
M51VisualRidSmall.jpg M51VisualAnDiffSmall.jpg M51Visual ceSmall.jpg
M51 in V band after applying Unsharp mask first and then Filters (Spatial): Regularized Isotropic (Nonlinear) Diffusion with the following parameters: Number of Iterations =3; Gaussian Standard deviation =0.5; Diffusion parameter =0.15 M51 V band after applying Unsharp mask first and then Filters (Spatial) Anisotropic Diffusion with the following parameters: Scale of Gaussian - X-dim =0.5; Y-dim=0.5; 10 iterations; k=15 M51 in V band after applying the Unsharp mask first and then Coherence-Enhancing Diffusion filter with the following parameters: 3 iterations, Diffusitivity denominator = 0.001, Derivative scale space = 0.5, Gaussian space scale=2.0

Image provenance

An exert from M51Visual_unsharp1_nlnoisereduction.xmp, which corresponds to the rightmost image in the first row from the M51V image after applying various noise reduction/fine detail techniques section.

MIPAV allows to keep a history of all of the actions (algorithms, utilities and transformations applied) performed on images. The history includes the specific parameters that were set for the action. Each time an image is modified and saved in MIPAV (no matter in which format) the history of actions and their parameters appears in the corresponding .xmp file (an XML file).

Final touch in Adobe Photoshop or Gimp

M51 RGB image created in Adobe Photoshop from 3 monochromatic images (R, B, and V) processed in MIPAV

From step 1 to step 12, I was very pleased with the results. However, when I tried to convert grayscale monochrome images into color ones using the Gray to RGB conversion tool, it did not work very well. The problem is, I believe, as follows: when MIPAV does the gray to RGB conversion it truncates intensities to 0-256 range, which is not enough for deep sky astronomy images(it works well with planetary images, though). I need to investigate this further.

I saved save monochromatic R, B, and V images in FITS format and used FITS Liberator to convert them into 16-bit TIFF files for further processing in Adobe Photoshop.

Then I followed the instruction provided on the FITS Liberator web site and created the color image of M51. Because the color channel information was preserved, I was able to create the final "pretty picture " image in Adobe Photoshop.

Since MIPAV allows to save monochromatic R, B, and V images as PNG or JPEG files, another option would be to all 3 images as JPEG files, and then transfer them to Gimp for further processing. In that case all software used is free.

How to create a pretty picture image in Adobe Photoshop

Case study 2 - M63 image processing in MIPAV

M63 image reduced from raw images (R, G, and B frames) received from McDonald observatory in MIPAV and color combined in Adobe Photoshop

M63 also known as Sunflower Galaxy was discovered by Pierre Méchain on June 14, 1779. The galaxy (at that time called a nebula) was then listed by Charles Messier as object 63 in his catalog. Later in 19th century William Parsons, 3rd Earl of Rosse identified spiral structures within the galaxy, thus making Sunflower galaxy one of the first galaxies with spiral structure identified. In 1971, a supernova with a magnitude of 11.8 appeared in one of the arms of M63.

Image processing log for M63

For M63 data reduction I used the same set of 11 steps which I used for M51.

Noise reduction

For a given dataset I applied the following noise reduction algorithms: 1. First I applied Unsharp mask with the following parameters was applied to all M63 science images R,V and B: Scale of Gaussian - x dim - 0.5, y-dim - 0.5, weight of blurred image =0.75. 2. Then I used Nonlinear Noise reduction filter and applied it to all science images which come from the previous step using the following parameters:

  • For R images - brightness_threshold less than 0.172237074375152; (image min) and Gaussian_std_dev float 0.5;
  • For V images - brightness_threshold double less than 0.4902107357978821 (image min) and Gaussian_std_dev float 0.5;
  • For B images - brightness_threshold double less than 0.13539797365665437 (image min) and Gaussian_std_dev float 0.5.

I used Nonlinear Noise Reduction because this algorithm uses nonlinear filtering to reduce noise in an image while preserving both the underlying structure and the edges and corners. I found it working really good for preserving the beautiful spiral structure of M63. Read more ...

M63 V image after applying both Unsharp mask and Nonlinear Noise Reduction, note the core of the galaxy
M63 B image after applying both Unsharp mask and Nonlinear Noise Reduction, note the spiral arms

3. And finally I applied Filters (Spatial): Coherence-Enhancing Diffusion to make spiral - sunflower like structure more prominent. I used this filter because is useful for filtering relatively thin, linear structures, e.g. spiral arms. In order to preserve the core, I, first, masked it, and then applied the C-E-D filter to the whole image. For all science frames (R, B, and V) I used the following parameters: 3 iterations, Diffusitivity denominator = 0.001, Derivative scale space = 0.5, Gaussian space scale = 1.0.

M63 R image after applying Unsharp mask + Nonlinear Noise Reduction+Coherence-Enhancing Diffusion, note the spiral structure near the core
M63 V image after applying Unsharp mask + Nonlinear Noise Reduction+Coherence-Enhancing Diffusion, note the core
M63 B image after applying Unsharp mask + Nonlinear Noise Reduction+Coherence-Enhancing Diffusion, note the spiral arms

Conclusions

The bottom line is that one can use MIPAV to process grayscale deep sky images and it works well. When one needs to do the final step and create a beautiful multi-color image, one can save MIPAV images as JPEG files and proceed further with Adobe Photoshop, or Gimp, or PaintNet (the last ones are free).