Hi Ginge,
They do not overlap at all so the Pixelmath approach is the only way.
If the CCD array has acquired all the 8 frames simultaneously, then there is no need to register the images. If this is not the case, then it will be necessary to register the images on a synthetic star field (StarGenerator). Another possibility would be creating the mosaic based on plate solves, something that PixInsight cannot do at present (unless you/somebody writes a script or a tool, which wouldn't be too difficult).
We assume also that there are no gaps between CCD elements. This is rare, but we'll make this assumption.
When you open a multiple-image FITS file, PixInsight loads each subimage as an independent image window. Then this is the sequence:
- Use the NewImage tool to generate the mosaic canvas. You should know the final dimensions of the mosaic. Just enter the desired width and height in pixels. I suppose the mosaic elements are grayscale images, so you should also select grayscale as the color space of the newly generated image. NewImage must be executed globally (blue circle icon, or F6).
- Now we can use PixelMath to place each mosaic element at its correct location. The expression looks a bit complicated but it is actually extremely simple; it just distributes all pixels over the canvas, each pixel at its corresponding coordinates. For simplification, let's assume that your eight mosaic frames have the following identifiers:
M1 M2 M3 M4
M5 M6 M7 M8
where I have distributed the elements in two rows and four columns, as you've said. Also let's suppose that the eight frames have exactly the same dimensions in pixels, and that there are no gaps between mosaic elements. Then the PixelMath expression is as folows:
row = y() % height( M1 );
col = x() % width( M1 );
iif( row == 0, iif( col == 0, M1, iif( col == 1, M2, iif( col == 2, M3, M4 ) ) ),
iif( col == 0, M5, iif( col == 1, M6, iif( col == 2, M7, M8 ) ) ) )EDITED: The above expression is wrong. See the correct solution to this problem two posts below.row and
col must be declared as symbols in PixelMath. You must also disable the
rescale result option.
This will do the trick very easily if you only have a few images. If you have a lot, then the above procedure should be implemented as a batch process with a script. It is not difficult. You can open the images, assign the identifiers and build the PixelMath expressions dynamically from JavaScript code. This is the easiest way, and perhaps the most efficient one, as PixelMath is a parallelized process and runs much faster than the equivalent JavaScript code.
To open one of these multiple FITS files, you must use the
ImageWindow.open static method:
Array ImageWindow.open( String url[, String id[, Boolean asCopy]] )The returned array contains all the subimages exactly in the same order they appear in the disk file. For example, you can use:
var myImages = ImageWindow.open( "/path/to/the/image.fit", "M" );and then myImages will contain all the subimages in "image.fit". The first image will be at
myImages[0] and it will have the identifier "M", the second image will be
myImages[1] and will have the identifier "M1", and so on. Building the PixelMath expression is a matter of concatenating a few strings. Put all this together with a file selection dialog (take BatchFormatConversion as an starting example), and you can generate an unlimited number of mosaics in a breeze.