An Introduction to Astronomical Image Processing – Part 1

By Chris Longthorn

This is the first of a series of articles designed to introduce the major concepts of astronomical image processing.  I’m going to take it from the beginning assuming that you have taken the images you want, calibrated them and stacked them so that you have a finished image ready for processing to obtain a finished article.
Calibrating and stacking can be covered in a separate article at some other time, but for now we need to understand that every image has both a wanted component called Signal and an unwanted component called Noise.  The stacking and calibration is used to remove as much of the noise as possible, but you can never remove all of it.
The file that you work on could be in any number of formats and it will depend on what you use to do imaging and what you use to do the calibration and stacking, but you should choose a format that keeps all of the information.  I use MaximDL to do the imaging, the calibration and the stacking and this produces a *.fit file, which I then convert to a 16 bit *.tiff (using MaximDL to save both versions).  Do not be tempted to work with *.jpg or *.bmp you’ll end up with a noisy mess.
For the processing I use Adobe Photoshop CS3, with some add-ins, but for these articles I’ll not be using the add-ins.  Other software can be used with much the same effect, such as Gimp and Paint Shop Pro.

The Image
After calibrations and stacking when you open the file in Photoshop you will not see very much.
You will have a very dark image with maybe a few bright stars showing assuming that you have not used the calibration and stacking software to do any stretching.  As you work on the image you need to keep a view of the Histogram.  In Photoshop this lives on a palette which is accessed using Window/Histogram.

Because I image in three colours I always select Colors (apologise for the US spelling, but that is what it says) from the Channel drop down so that I can see the individual effects I’m having on each colour channel.  This histogram belongs to the image above and needs some explanation.

Using the Histogram
I’ve annotated the Histogram palette here so that you can understand what it is showing. Within Photoshop each pixel in the image will have a value for each of the three colours Red/Green/Blue of between 0 and 255 (or 256 levels).

To the left is Black, the value of all three colours here is 0, 0, 0.  To the right is White, the value of all three colours here is 255, 255, 255.  The grey line along the bottom of the box is some signal (just what we want) and this stretches from 0 to 255 in all three colours and what you are seeing here is the stars.  To the left is some more signal, but is mostly black or shades of grey and you’ll see some dark red.  In principle the object of the image processing is to stretch this part of the image so that it occupies more of the Histogram Box like this.

The image will likely have artefacts at the edges because of a small shift due to drive errors between each of the filters, so crop the image to remove the edges.

Levels and Curves
The principle tools used to do the stretching are Levels and Curves.
I use the Levels dialog to do the initial stretching.  This is accessed using Image/Adjustments/Levels… or Ctrl-L.

On the Levels dialog we have a Channel selector from which we can select to perform on individual colours, R/G/B or work on the “luminance” which is RGB all at the same time. There are 3 sliders with associated numerical input one for adjusting the Shadow levels, one for the Midtone levels and one for the Highlight levels.  Moving these sliders or inputting values have these effects

    Shadows make the background darker (going right)
    Midtones makes the midtones brighter (going left) or darker (going right)
    Highlights makes the bright areas brighter (going left)

For our initial stretch we’re going to adjust the midtones only.  Move the slider left until you can see the image fairly easily.  Less is more, so be gentle, don’t overdo it.  The image below shows the effect of a fairly aggressive Midtone level adjustment on the image and the resulting Histogram.  You can see that the histogram now occupies more of the available area.

Now we need to establish the Black point and the White point, we have areas of dark sky background where we can establish the Black point and some bright stars where we can set a White point.  For this we will need to use the Color Sampler Tool.  This is found on the tool palette.

If we use the Color Sampler tool and click it on the image it puts the values of RGB that it reads into the Info palette.  So, click first into a dark part of the image for the Black Point and then into a bright area (star) for the White Point.

This shows the result of this,

Point 1 (Black) has RGB values of 9, 2, 3 and Point 2 (white) has RGB values of 242, 249, 251.
The night sky is not completely black, like the daytime sky it still scatters light in the blue end of the spectrum and is therefore a very dark blue and we need to reflect this when setting the black point.
We use the Levels dialog again, but this time we are going to adjust the individual R, G and B values to 25, 30, and 35, to get a very dark blue.  As we have to brighten the background here we do this by moving the Output Level Shadows slider to the right to obtain these values in each of the R, G and B channels.
Point 2 is very nearly pure white and in this instance we don’t want to change this.

Now for the first stretch using Curves.  The Curves dialog is accessed using Image/Adjustment/Curves… or Ctrl-M.

We can use the Channel selector to select Luminance (RGB) or individual channels like the Levels dialog and the diagonal line represents the stretch curve, bottom left is 0, 0, 0 and top right is 255, 255, 255.  We want to be able to stretch the midtones in the image without affecting the Black and White points that we have already set up so we can put these points onto the stretch line by Ctrl-Clicking the mouse pointer on or near to the Color Sampler tool points that we already have on the image, the white point one is the difficult one as it could be in a small star, so exact correspondence is best for this one.  Once the point are placed they appear as small squares on the line (highlighted here in yellow).

Now we can click on the line and drag it upwards to boost brightness (or downwards to reduce brightness) and you can use more points to make the curve any shape you want (which can produce some bizarre effects).  Anyway here’s a typical stretch in action.

Now we’re clearly seeing the Horsehead Nebula and the red nebulosity associated with it and also that the histogram is now well stretched across.  This stretch will have slightly altered the Black and White points, so use levels again to re-adjust these back to their previous levels and then if you want, do additional iterations of Curves and Levels until you get close to how you want your final image to look.  So I’ve done a further iteration using individual colour channels to decrease the Red and boost the Green and Blue, which reduces the red cast of the image.

We’re nearly finished with this lesson.  There are three things left to do.

Using Filter/Sharpen/Unsharp Mask… open the Unsharp Mask dialog and you can play with the Amount and Radius to sharpen the image to various levels.  I’d recommend an Amount of between 50% to 100% and a Radius usually of less than 1, but here I’ve used 2.5 to exaggerate the effect.

You can see that the inset in the dialog clearly shows that the stars are sharper, but that it has also sharpened the noise and made the image grainier.  The stretching that we have done of course stretches both the signal and the noise.

Noise Reduction
So now we have a noisy image and we want to reduce the noise.  Actually we don’t want to remove it completely as this will make the image look flat.  There are Photoshop Add-Ins that do an excellent job here, but you can make use of Photoshop’s own noise reductions using Filter/Noise…first use Despeckle, this removes a lot of the speckling and then use Dust and Scratches… with a small Radius (1 or 2 maximum) and a Threshold of 0.

Gradient Removal
The full image above exhibits a gradient; it’s kind of brown towards the bottom.  Again there are Photoshop Add-Ins that will remove this, but there are other methods and this will be the subject of the next article.

Catching the Cosmic Rays in Space
By Paritosh Maulik

We have seen earlier that high energy particles or “cosmic rays”, originated in high energy astronomical bodies, interact with Earth's atmosphere and this makes the interpretation of results somewhat difficult.  Some of these difficulties have been mitigated by high altitude (about 40 km) balloon borne experiments.  In America they wanted to build a Superconducting Super Collider for high energy particle collision experiments.  From such experiments physicists would get a better understanding of the fundamental forces of nature.  The construction started, but the cost went over the budget and the project was eventually cancelled.  One of the scientists involved, Professor Samuel Ting, suggested that a space borne study of cosmic rays may be an alternative to the high energy experiments on Earth and thus the first demonstration project Alpha Magnetic Spectrometer (ASM-01) was conceived.  The AMS project would analyse the high energy particles emanating from the astronomical objects as cosmic rays and therefore there is not need to construct high energy particle accelerator.  AMS-01 is an international collaboration.
In this experiment, a cosmic ray is analysed by an instrument called a Alpha Magnetic Spectrometer (AMS-01), a detector similar to those used in high energy particle experiments.  In fact this is a space born high energy particle experiment. In place of a telescope, the detector is a powerful magnetic coil, made from a permanent magnet.  As the particles enters the coil, their paths gets deflected and from the trajectory of the deflected beam, the properties and possibly the origin of the cosmic rays can be analysed.  The detector is similar the detectors used in the high energy particle experiments.

Such a detector was made and was put top of the Space Shuttle Discovery and collected data from 2 – 12 June in 1998.  This instrument being above the atmosphere, was able to collect information about cosmic rays coming from galactic sources.

The detector in the alpha magnetic spectrometer is a permanent magnet with a strong and uniform magnetic field. The magnetic field bends the path of the charged particle.

Results from AMS-01
Hydrogen and helium were the first elements to form at the birth of the universe. Helium is the second most abundant element after hydrogen.  AMS-01 collected about 3 million cosmic helium, but did not find and anti-helium.  From these measurement it was concluded that in the universe Anti-helium/ Helium ratio is 1.1x10-6, i.e. very little anti-helium.
AMS-01 results also produced some information about the Earth's magnetic field. 
Only the cosmic rays of certain energy level can penetrate Earth's magnetosphere (the magnetic field of Earth forms a shield surrounding the Earth; charged particles cannot enter this region) and the particles below this energy level follow the magnetic field to reach the poles of the Earth. 
As the AMS-01 instrument rotated around the Earth, it measured the levels of cosmic rays entering at different latitudes around the Earth.  It showed different levels of particles entering at different latitudes around the Earth.  These are high energy protons, in the GeV range.  In one plane, a proton of energy lower than 8 ev was found.  Protons of such energy levels was expected to follow the Earth's magnetic field and to the Poles.

Encouraged by the results from AMS-01 instrument, it was decided to build a more powerful instrument AMS-02, based on similar principles.  AMS-O2 is to operate over a longer period to collect more matter and antimatter particles.  The new instrument was to be mounted over the International Space Station and would collect data for three years and then be return to Earth. 
The development of AMS-O2 began in 2000.  Originally it was thought that liquid helium cooled superconducting magnet (SCM )operating at 4K (-269°C) would be used in the detector.  The alternative option was to use a permanent magnet (PM) instead of the SCM.  The advantage of the SCM is that the magnet is very powerful; it bends matter and antimatter more from each other and and the resolution is better at lower energy level. 
Then came the Challenger disaster in 2003 and the future of the missions to ISS was hanging in the balance.  During this period the development of the ASM-02 instrument continued.  Tests at European Space Agency showed that liquid helium would not last for three years.  The Space Shuttle was eventually given a go ahead in 2009, AMS-02 was given a green light to be flown in 2010.  The instrument would be carried on top of the ISS and would be left there; the ISS is to operate till 2015.  During this period, a decision was taken replace the SCM with PM.  The magnetic field of the PM is about 5 times weaker than the SCM and as a result, there will be loss of resolution in separating matter and antimatter.  However this could be corrected by a minor design modification.  The advantage of the PM system is it is cheaper, light and safer, no liquid helium to worry about.  In the final design the resolution of the PM system was as good as the SCM system.  Tests have shown that the PM bases system could operate for a period of 10 years without any deterioration of property; the life expectancy of the SCM based system, on the other hand, was 3 years.

Since the detectors used in this mission are essentially very high energy particle detectors, the instrument was assembled in CERN, Switzerland.  There the detectors were subjected to high energy particles for calibration.  Then the instrument was sent to the European Space Research and Technology Centre in the Netherlands for thermal vacuum, electromagnetic compatibility and electromagnetic interference testing.  These tests are necessary to confirm the survivability in the space weather.  Tests also include vibration tests so that the instrument can withstand the tortuous forces during the launch.  Following the tests at space centre, final alignment test was done at CERN and was sent to the US for launch.  The Space Shuttle Endeavour carried the AMS-02 instrument to to the ISS; the launched date was 16 May 2011 and the instrument was permanently fixed to the ISS on 19 May 2011. 

Detectors in the AMS-O2
Transition Radiation Detector (TRD) identifies electrons and positrons among other cosmic-rays
Time-of-Flight System (ToF) alerts the sub-detectors of incoming cosmic-rays 
Silicon Tracker (Tracker) detects the particle charge sign, separating matter from antimatter 
Ring-Imaging Cherenkov Detector (RICH) measures velocity of cosmic-rays with high precision
Electromagnetic Calorimeter (ECAL) measures energy of incoming electrons, positrons and gamma-rays
Anti-Coincidence Counter (ACC) rejects cosmic rays traversing the magnet walls
Tracker Alignment System (TAS) checks the Tracker alignment stability 
Star Tracker and GPS defines the position and orientation of the AMS-02 experiment

The following website gives the working principles of the instrument in simple terms 

Assembly of the AMS-02's magnet

Results from AMS-02
Since the instrument is operating above Earth's atmosphere, in the space, it is detecting cosmic rays before the rays have interacted with the atmosphere.  The instruments are very sensitive with high reproducibility. 
The first set of results, for about 18 moth of data collection, during the period of 19th May 2011 to 10th December 2012, were reported on 3rd May 2013. 
The instrument has analysed the largest number of positively charged antimatter, positron, from space against a background of large number of positively charged protons.  It has given the first estimation of the population of positrons in the energy range of 0.5–350 GeV.  The population of positron is low in certain intermediate energy range and then there in the increase in the population of positron with higher energy levels; the the plot flattens out at still higher energy level.  The shape of the plot is to be confirmed by more data.  The shape of the positron population vs. energy plot is in broad agreement with other earlier results.
The population of positron is not time dependent and electron – positron ratio does not appeared to be coming from any preferred direction. 
Although the instrument is expected to look for the nature of the dark matter, but no results have been announced.  The source of positrons may be colliding dark matter particles or pulsars producing electron – positron pair.  
The data analysed so far is the first set of results and represent only about 10% of particle the AMS-02 is expected analyse in its lifetime.  The Alpha Magnetic Spectrometer is one of the most sensitive space borne instruments constructed to date.  Its had a roller coaster life, the original budget was $33 million and the final cost came to $1.5 billion.  High hopes are riding on the results from this instrument. 


Analysing Cosmic Rays in Space 
By Paritosh Maulik

Physicists are using powerful particle accelerators like the Large Hadron Collider in CERN and the Fermi Laboratory in Chicago to understand the fundamental forces of nature.  Nature of these forces is of interest to both the astronomers and cosmologists.  These fundamental forces came into being at the origin of the universe and eventually matter came from these forces.  But no accelerator is powerful enough to match what is out there in the astronomical objects like stars, active galactic nuclei and similar high energy systems.  High energy particles from these astronomical sources are showering on Earth as cosmic rays.  So learning more about the cosmic rays will help us to understand some of the processes occurred in the early Universe. 
But there is a problem; the cosmic rays on the way to the Earth, react with the upper atmosphere and some of the information gets lost.  One solution is to use a particle detector, similar to as used the high energy physics, in the near emptiness of the space.  This is what has been achieved with Alpha Magnetic Spectrometer project.  A particle detector strapped to the International Space Station is collecting information about the cosmic rays.  It has been a very expensive endeavour.  It had its ups and downs; the project nearly got cancelled; but eventually it got the green light and now results are coming in.  We shall have a look at cosmic rays first and then go into the space based detector Alpha Magnetic Spectrometer.

Cosmic Rays, an Introduction
It was late 1800 – early 1900; radioactivity had been discovered.  Radioactivity is from the naturally occurring minerals on the Earth.  Some of the elements are not stable.  Such elements emit sub-atomic particles and transform into another element.  This called radioactive decay.  The question was asked, if the radioactivity is from the Earth bound minerals, we should expect lower radioactivity as we go away from the surface of the Earth.  This was found to be the case; lower radioactivity away from the surface of the Earth, but then it began rise again as one went higher up.  Radioactivity as measured as charged particles, on top of the Eiffel tower was higher than its base.  The source of this radiation was not clear.
Eventually it was concluded that the Earth is continuously showered with high energy subatomic particles (rays) from extra-terrestrial (cosmic) sources as charged particles.  Fusion of hydrogen atoms into heavier atoms produces gamma rays; these gamma rays react with the atmosphere and one of the products is an electron.  Because of this process, it was thought that the cosmic rays are electromagnetic (photon) in nature.  Then it was found that the cosmic rays are deflected by magnetic fields and therefore the cosmic “rays” are charges particles and not electrically neutral photons as originally suggested.  However the  term “rays” got stuck.  These particles are mainly high energy protons, but also contain some heavier atomic nuclei.  When these high energy particles meet the upper atmosphere, these particles loose some of their energy and the lost energy is converted into x-rays, gamma rays and other subatomic particles.
The high energy of cosmic rays suggests the cosmic ray source to be extra-solar such as neutron stars, supernova, active galactic nuclei, quasars and gamma ray bursts.  Primary Cosmic rays consist of about 99% alpha particles (positively charged helium nucleus), about 1% heavier nuclei and a very small fraction of positron and anti-protons.  The reaction between the primary cosmic rays and the atmosphere produces further subatomic particles.  This is called secondary cosmic rays.  Some of these subatomic particles were first detected in cosmic rays.  Astronauts in the Apollo mission noticed light flashes even with eyes closed. This was thought to be due to cosmic rays passing through the eye.  Astronauts in the International Space Stations also have reported similar experiences.

Although it was suspected that the cosmic ray sources are extra-solar objects, only recently there has been some direct evidence on the possible source of cosmic rays.  Materials ejected during supernova outburst move fast.  These fast moving materials create a shock wave and if protons get trapped into this shock wave, the combined energy of the shock wave and magnetic field cause the protons to move in and out across the shock wave boundary many times.  Eventually the protons acquire enough energy and leave the shock wave as a cosmic ray.  In principle we should be able to detect these cosmic rays and pinpoint their direction.  However the presence of our terrestrial magnetic field interacts with the cosmic rays and as a result their direction gets lost by the time these reach the detectors.
These high energy protons or cosmic rays when collide with low energy protons; the interaction produces gamma rays.  The gamma rays travel in straight line and from the direction of the gamma rays, the source can be determined.  The gamma rays produced from such reactions should have energy around 150 – 200 MeV (150 – 200x106eV).  In 2012, NASA’s Fermi Gamma Ray Space Telescope detected such high energy gamma ray sources from two supernova remnants in the Milky Way galaxy.  This result confirmed that cosmic rays have their origin in galactic sources and came nearly 100 year, since the discovery of cosmic rays by Hess in 1912. 
Cosmic rays can have still higher energy than discussed above.  Cosmic rays with energy greater than 1015eV are called Ultra-high energy cosmic-rays (UHECR).  On occasions Cosmic rays with energy of 3x1020eV has been observed.  Such high energy cosmic-rays pose a problem for the scientists.  Theoretically cosmic-rays above energy of 5x1019eV should interact with the cosmic-microwave background and produce sub-atomic particles.  By this process all cosmic rays arriving on Earth should have energy below the above theoretical level. 
It is believed that the UHECR originate from extragalactic sources, such as active galactic nuclei, or dormant quasars associated with super-massive black holes.  Any theory to explain the nature of the possible source should include how such high energy particles are produced and how the particles escape the magnetic field of the spiral galaxy.

Dark Matter and Cosmic rays
As the name suggests we do not know the true nature of the dark matter, but several scenarios  have been suggested.  Some of these are or 
1. Dark matter is special group of particles called neutralino, about 100 times heavier than a proton 
2. Penrose process.  Near a black hole, one particle can break down into two particles; one of the particles can have mass-energy greater than the incoming particle and can escape the black hole, while the other drops into the black hole.  The black hole can lose its angular momentum by this process.  The escaping particle can react with the incoming particles to form very high energy protons and this is the source of ultra-high energy cosmic ray. 
3. According to another proposition super heavy dark matter can decay into high energy cosmic ray particles with a fraction of the mass of the super heavy dark matter.

In simple terms antimatter is the counterpart of the matter with opposite charge.  When matter and antimatter meet, these annihilate each other.  An electron has negative charge and its antiparticle is a positron with a positive charge; a positively charged proton has its negative counterpart, an anti-proton.  Some of the antiparticles were first observed in Cosmic rays.  Electrically neutral neutrons also have its counterpart anti-neutron.  An anti-neutron is also electrically neutral, but has certain properties which are opposite to “normal” neutron. 
Matter made from particles exists, then we can expect antimatter made from anti-particles.  In fact antimatter has been made in the laboratory.  CERN was first to produce nine anti-hydrogen particles made up of anti-proton and positron were produced in in 1995 and by 2002 tens of thousands atoms of anti-hydrogen were made in CERN. This amount was large enough to study the properties of anti-hydrogen in detail.
Theoretically we should have equal amounts of matter and antimatter in the universe.  But we come across only matter and not antimatter.  It has been suggested that there is an anti-universe out there; it is just matter of contacting such a place.

This shows the principle of muon radiography.  As near-horizontal muons pass through the volcano, they are absorbed by the rock through which they are passing.  The denser the rock, the more muons are absorbed.  The backward flux muons are used for normalisation.

The Mu-Ray muon telescope prototype at Vesuvius.

Photo of the Cleveland Volcano, Aleutian Islands, taken from the International Space
Station on 23 May 2006. The volcano emitted a plume of ash but did not erupt.

Muon Radiography
Before we leave the cosmic rays, here is an application of cosmic rays.  Secondary cosmic rays contain a sub-atomic particles called a muon. Muon is absorbed by rocks.  This property has been used to map inside volcanoes.As the muons pass through the volcano, it is absorbed by the rocks.  The absorption depends on the density of the rock.  This property has been used to locate and map the molten rock within the volcano.  The spatial resolution by muon mapping is in the order of about 10 metres, whereas for other methods it is about 100 metres.  The muon mapping can also be carried out over time to monitor the change in the internal structure of the volcano. 
Currently a project is running in Italy to map Vesuvius.  Muons travelling at very low angle pass through the rocks and is picked up a solid state detector that is placed opposite.  Denser rocks absorb more muons.  The internal rock structure is then mapped by tracing the flux of the muons.  Muons coming from the opposite side of the volcano are used for background correction.  Vesuvius is about 500 m wide and 300 m deep.  The muons have to penetrate about 2 km of rock, so only muons of very high energy, travelling near horizontal, can penetrate the rock.  This has been a very challenging project.  The prototype detector has detection area of about 1m2 and the final version will have detector will be about 10m2.  The detector technology is borrowed from particle physics. The present set is collecting data from spring of 2013.  The next phase will have detector of 4m2
Thus it appears that the universe is teeming with high energy particles.  Understanding of these would help us to know the processes going on in early universe.  One of the problems is, as these high energy particles enter the atmosphere, a lot of information is lost.  Therefore, if we can intercept these particles before these interact with the atmosphere, we can get some more useful information.  Alpha Magnetic Spectrometer (AMS) is project has been designed to do this.  We shall look into this at another time.


Seeing Cosmic Rays on the International Space Stations.  See

ESO Science in School, No. 27, Autumn 2013

Antimatter, F Close, Oxford University Press, 2010).