Introduction to GRIP
Sections in this page
- GRIP running
- Image file formats
- Some general points
- - Undoing steps
- - Java
- - Blobs
- - Grey levels
- Processing facilities
- - Image menu
- - Measurement menu
- - Geometry menu
- - Levels menu
- - Blob menu
- - (De-)Convolution menu
- Combining images
- Batch processing etc
- - File menu
- - Batch menu
- - Configuration menu
- Downloading GRIP
GRIP was originally designed to stack together astronomical photos taken with a digital camera on a fixed tripod from a light-polluted urban site so that as much faint detail as possible could be seen.
Here is an example:
Since it started in 2001, GRIP has grown to be a comprehensive image processing and measurement tool that can also be used for working with professional images, such as from space projects, to be found on the Internet.
This is what GRIP can look like when running (on 64-bit Windows 7 in this case, but any system on which Java Standard Edition runs will do - that means most computers).
Notice that each image has its own menu bar. Also the main GRIP window, top left, has menus for opening or creating images and for processing batches of images automatically. The top right window at the back is a table of currently opened images and it too has a menu, most importantly for combining any images selected as rows in the table (2 of the 3 images are selected in this example). Three different kinds of image are shown here: a JPEG image having 8 bits per colour channel (or band), a 16-bits-per-channel TIFF image and a 32-bits-per-channel FITS (astronomy format) image. GRIP can handle up to 64 bits (floating point) for any number of channels in an image. The black window at the back, bottom left, is a console window showing information being sent to a log file as GRIP runs. It can show you what is currently happening but you can run GRIP without that window if you wish (the information is still logged in a file).
GRIP can read several different standard image file formats and also save its results for reloading later or for transfer to other applications. The following diagram summarises its use of image file formats and enables various features of GRIP to be introduced.
The red numbers refer to notes below the diagram.
The terms "channel" and "band" are used interchangeably in GRIP. A monochrome image has one channel. A red/green/blue (RGB) image has 3 channels. Images from spacecraft may have any number of channels, in which case GRIP can process them but can only display 3 of the channels simultaneously as one image. If there are more than 3 channels (in a FITS file, for example) each channel will first be displayed in its own monochrome frame. The combination menu can then be used to select any 3 channels for a combined display and so for processing together.
- FITS = Flexible Image Transport System is the standard image file format used in astronomy, approved by the International Astronomical Union (IAU) (link to further details and formal specification). It can store image data, for each pixel in each channel, to various accuracies: 8-, 16- or 32-bit integers or 32- or 64-bit floating point numbers. The larger the number of bits, the more memory is required, either as a disc file or in RAM for displaying and processing the image. FITS is the usual format for storing images from CCD cameras.
- RAW files are produced by digital cameras made for the non-scientific market. That usually means DSLR (digital single-lens reflex) cameras but some fixed lens "compact" cameras can also save their RAW data. RAW is not an abbreviation but it is usually written in capitals to make the meaning clear. Until recently RAW files held pixel data to 12 bit accuracy but increasingly 14 bits is the norm. RAW is a different format for each camera manufacturer and even between models from one manufacturer, so it is the least standard of the formats GRIP can read.
- GRIP can read some RAW formats but not all, using a software product called jrawio, which is unfortunately not keeping up with the latest camera models. For some cameras it may therefore be necessary first to convert RAW to another format, of which the most suitable is TIFF (see note 4). That can be done using various other applications, such as Adobe PhotoShop or, for Canon cameras, Digital Photo Professional (DPP) supplied free with the cameras.
- TIFF is the Tagged Image File Format. It originated in the graphic arts arena but is very widely used, partly because it stores a lot of metadata (data about the image) as well as the image itself. It is also useful here because it can store 16 bits per channel. TIFF is useful for presenting complete images to professional printers.
- JPEG (named after a Joint Photographic Experts Group) is the format known best to amateur photographers. It is convenient because its files can be very small. However small size comes at a price. A lossy method of compression is used. While that may be fine for "snaps" it loses the fine detail that is often important in astrophotos. It can introduce artefacts into the image in the form of ripples or unexpected spots. It is also limited to 8 bit precision so JPEG throws much of the original data away. I have discussed this further on my camera techniques page.
- PNG (Portable Network Graphics) was designed specifically for the Internet. It comes in two flavours: PNG-8 for graphics and PNG-24 for RGB photographs. It compresses without loss so the files are larger than JPEG but do not lose anything. This can be a useful format for putting results on the web or for sending them by email.
- Images with larger bit-depth have the capacity for adding up a lot of normal images without the pixel values reaching the maximum allowed value. That is important for getting faint detail out of images, as explained on my exposure settings page.
- When the diagram was drawn (early 2011) the 64-bits-per-channel accumulator was only used as a temporary holding area for images loaded from floating point (32- or 64-bit) FITS files. That is no longer the case. GRIP's 64-bits-per-channel images now have all the functionality of less deep images.
- The 32-bits-per-channel images are also fully functional as an image. All of the image processing and measurement capabilities of GRIP can now (as of version 11.5.1) be performed in such images without first scaling them down to shallower bit depth. A version of the image is displayed in a window with its own menu bar. The display is either monochrome or RGB colour, depending on whether there are 1 or more channels. Here is an example of an image window with its menu bar:
- One way to obtain an image having 32 bits per channel is to combine a sequence of 16-bit images, "stacking" them (see the Batch/Astro menu). GRIP detects star patterns in each image and then warps the images (like rubber sheets) to add them one on top of another. To prevent the brightness levels reaching a ceiling, such an accumulator image, deeper than 16 bits, is necessary. In earlier versions of GRIP the accumulator then had to be scaled into another 16-bit image for further processing but that is no longer necessary. All processing and measurement can now be done in the full 32-bit image. It can also be saved as a FITS file at any stage.
- In earlier versions of GRIP (before 11.5.1) saving FITS files was not possible so GRIP had its own very simple file format for saving accumulators and loading them back later. The drawback was that only GRIP could read those .accum files. They are now obsolete but GRIP will continue to be able to read them.
- One of the options on the levels menu of a 32-bit image is conversion to a 16-bits-per-channel image. It is done simply by scaling the range of the data currently held in the image linearly into the range from 0 to 65,535.
- Again, in versions before 11.5.1 GRIP could only do image processing and measurement in images having at most 16 bits per channel, so deeper images had first to be converted to this type. That restriction no longer applies. (16 bits per channel is the most a standard Java BufferedImage can hold. GRIP uses its own structure for the deeper images.)
- The levels menu of each image also has options for converting between 16 and 8 bits per channel by simple linear scaling.
- An image having 8 bits per channel is useful for saving as a JPEG file after all processing has been done, so the result can be displayed on the web as a small file. Usually at least a 16-bit TIFF file would be saved too because JPEG loses details.
GRIP does not have an "undo" menu option. This is quite deliberate because we are dealing with large images. An accumulator created by stacking images from my DSLR occupies 250 megabytes. It was deemed an unnecessary overhead to keep making copies of that amount of data just in case a step needed to be reversed. Users should instead save intermediate results as files or use the "Clone" and "Reload from file" options on the image menu.
GRIP is written in Java. That means it is not the fastest image processor but it is still impressive. Java has 2 particular advantages. Firstly it means GRIP will run unmodified on most platforms: on the various flavours of Unix (Linux, Solaris, etc), on Windows, on MacOS, etc. Secondly it is easy for Java programmers to extend it for particular requirements: the API (application programming interface) is documented here and sophisticated programming tools are available completely free from various sources.
Blobs are contiguous groups of pixels that have been detected as being of interest for some reason. A blob might be a star, for example. We don't use the term "object" because that would be confusing to Java programmers (a blob is represented by 2 objects: one describing the boundary and another describing the interior region). In some image processing systems our blobs would be called ROI's (regions of interest).
The general term for the process of detecting blobs is "segmentation": segmenting interesting pixels from the background. A crude method of segmentation is thresholding: detect all pixels that lie within a user-selectable range of brightness levels. GRIP does offer that as an option in the levels menu. Detecting stars is obviously very important for GRIP and so a special algorithm has been developed. It can detect stars even in the presence of background variations such as occur when there is also some nebulosity around. Thresholding would not be adequate in such cases.
Once blobs have been detected, and held as a list of boundary and region descriptions, they can be measured. Not only geometrical measurements such as width or area can be made, but also by referrring back to the pixel data we can measure total brightness in each channel. From there we can go on to compare with reference stars (other blobs in the image) to measure astronomical magnitude and astrometric position. GRIP offers all of these things.
Another term in image processing that can cause confusion is "grey level". It simply means the brightness in a given channel (or band) of the image. In a coloured image (typically having red, green and blue channels) grey level is still a meaningful term within each channel.
The following can be applied to 64- and 32-bit accumulators as well as to 16- or 8-bit images, all monochrome or RGB unless otherwise stated. Most of the image processing options can also be applied to a set of files without them being displayed, from the batch menu on GRIP's small main window.
- Zoom in, out or to fit the window
- Save as (FITS, TIFF, JPEG, etc)
- Clone the window
- Display in pseudocolour
- Show image information (metadata) or processing history
- See pixel coordinates and brightnesses while hovering with the mouse and then click to get a grossly magnified view of any region, clearly showing individual pixels
- Draw a straight or curved line with the mouse and see the profile of brightnesses in all channels along the line, along with line length and angle and statistics of brightnesses in all channels.
- Draw any closed area or define a rectangle (or the whole image) and see a histogram and statistics of brightnesses in all channels, along with geometrical measurements of the shape.
- Move the drawn shape around to measure the same shape in different parts of an image, or use a shape drawn in another image.
- Compare measurements between images.
- Save measurements as CSV (for spreadsheets) or XML files.
- Calibrate the image so that measurements are in calibrated units (eg, arc seconds).
- Other rather experimental facilities.
- Crop the image either manually by defining a rectangle with the mouse or automatically to remove any black rim. A black rim can result because, unlike many other image processors, GRIP expands the image size when rotations or other operations require it, so no part disappears off the edge.
- Flip the image horizontally or vertically.
- Rotate the image through any angle.
- Translate the image by any amount horizontally or vertically.
- Apply gnomonic or inverse gnomonic projections. These take account of the fact that a camera projects a sphere onto a plane. More details here.
- Convert between different bit depths or from RGB to monochrome.
- Do the Bayer interpolation if a truly RAW image was loaded.
- Split channels, giving each its own monochrome image window.
- Invert or stretch contrast, or change it through look-up tables (curves dialogue, with histogram and preview).
- Change saturation or colour balance.
- Correct background either by interpolating variations or by equating the modal values of the channels (the latter is called neutralising the background; in astrophotos the modal values in the histogram are highly likely to be the background levels).
The levels menu also contains options for segmenting the image, detecting blobs and measuring them. So the following are also provided.
- Thresholding by user-selected ranges (selected with sliders), to make a mask within which blobs can then be detected.
- Segment stars. This requires no user intervention and goes through automatically to detect all the stars as a list of blobs. This has been tested on Milky Way photos in which there are tens of thousands of individually detected stars.
- Go on to hover with the mouse so that summary measurements of the nearest detected blob are displayed. Clicking then gives a highly magnified view of the blob in its own image window and with the blob menu on the menu bar.
- Draw graphs and histograms of blob measurements. Plotting brightnesses in different channels against each other can be revealing for star clusters (like an H-R diagram but here we are dealing with brightnesses rather than logarithmic magnitudes).
- Other rather experimental facilities.
This menu only appears when a detected blob has been clicked upon with the mouse and is then displayed greatly magnified in its own image window.
- To follow
Linear and nonlinear convolutions (filters) are available here as well as deconvolution (recovering blurred detail).
The common factor is that a square pattern is applied in the neighbourhood of every pixel in the image. This tends to be time-consuming so progress bars are shown.
Some standard nonlinear filters come first in the menu, for all of which the size of the square pattern can be selected:
- Median filter, for removing extreme values (defective pixels, noise).
- Mean filter
- variance filter
- Nearest extreme filter
- Rank filter
- Gaussian blur. This is useful for bringing out detail in nebulae. Blur grossly (100 pixels or more) and then subtract the result from the original image (using the image combination menu, described below). This process is called unsharp masking and can be very effective.
More general convolutions and deconvolutions are done by setting up a kernel (the square pattern). That can be done in several ways, including sampling the image to get the shape that stars, that ideally should be points, have become as a result of the optical system. Knowing that stars should be points (certainly in any amateur telescope) makes deconvolution more feasible.
In addition to all of the above there is another rich set of operations for combining 2 or more images. This is available from another window that is displayed when GRIP starts: the image table. The table summarises all image windows that are open at any time. It has a menu bar enabling any images in the table to be selected. Depending on the number of images selected, various options become available in the "Combine" menu:
- Add images together, either 100% of each or in proportion as determined by a slider (shown with a preview of the result).
- Subtract one image from another. Either to mid-grey so that details present or absent from both images can be seen, or to zero.
- Multiply images together, either 100% of each or in proportion as determined by a slider (shown with a preview of the result).
- Divide one image by another. Can be used for flat fields, though that could alternatively be done routinely in batch processing.
- Combine 3 monochrome images to make an RGB one. This can be done with images from non-visual bands (eg, infra red images from spacecraft). It can also be used for artistic effects.
- View a pair of images in red/green so that stereo (3D) may be seen with suitable spectacles.
The small window containing the GRIP logo has its own menu bar containing three useful menus.
The File menu enables image and other files to be opened. It also enables star charts to be created. Star charts are useful in GRIP because stars can be identified in images and star data from Hipparcos and Tycho catalogues can then be attached to the identified stars in a simple process that involves clicking on the chart and then on your image. This is particularly important for measuring the magnitudes of stars in relation to known reference stars, a process known as photometry.
Many of GRIP's image processing operations may be applied to a set of files automatically, in sequence. This is done without displaying each individual image, so it is faster. New versions of the images are saved with modified file names (they never overwrite the original files).
Importantly also the batch menu has the options for stacking astrophotographs.
There are a few things that can be set once here and GRIP will remember them whenever it runs.
The program may be downloaded from the next page.