Tutorial (PixInsight):
Cropping and Resizing Images
At some point, we inevitably end up cropping images. Usually this is during the initial stages of post-processing, to remove black bars around images that have been registered with one another (common for astrophotographers imaging in monochrome). Other times it is to get rid of unsightly parts of an image (such as excessive coma along the corners) or simply to reduce the amount of background surrounding our intended target (if it appears small in the image). Moreover, we may want to resize images to make them larger or smaller, while retaining everything in them.
This tutorial mainly covers a basic function of PixInsight - cropping your images. It does so covering two processes. These are the DynamicCrop and Crop processes (the former is dynamic whereas the latter is non-dynamic). Each of these processes are covered in detail to instruct the user how to operate them fully. This tutorial also covers resampling your images to resize them while retaining all the information displayed. This is done using the Resample process.
Assumed for this tutorial:
Please feel free to ask questions or leave comments via the comments section on the bottom of this page.
This tutorial mainly covers a basic function of PixInsight - cropping your images. It does so covering two processes. These are the DynamicCrop and Crop processes (the former is dynamic whereas the latter is non-dynamic). Each of these processes are covered in detail to instruct the user how to operate them fully. This tutorial also covers resampling your images to resize them while retaining all the information displayed. This is done using the Resample process.
Assumed for this tutorial:
- Knowledge of operating PixInsight, related to dealing with images and processes (read this, sections 3 and 4).
Please feel free to ask questions or leave comments via the comments section on the bottom of this page.
1. Cropping using DynamicCrop
DynamicCrop, as per its name, is a dynamic process. This means that once initialised on a particular image, it opens a session on that image and needs to be closed fully in order to be used on another image that is open. Below shows a non-linear colour image open alongside DynamicCrop.
To initialise DynamicCrop, we can either create an area in our image by clicking and dragging, or we can click the Reset button on DynamicCrop. If we click the Reset button, the entire image is selected by default.
If we click the Execute button at this point, nothing happens because the entire image is selected so no cropping actually takes place. To reduce the area selected, we simply go to either of the four sides of the image and click and drag inwards to move the border. Please note that if you accidentally click and drag from somewhere inside the area already selected, you will simply move the selected area as opposed to modifying its selection. To avoid this, simply zoom out of your image one step. Hovering the mouse over the image boundaries changes the mouse icon to indicate we are going to modify the selection area. At this point we can click and drag that side inwards.
This can be repeated to the other three sides to define the area of the image that you wish to retain (the areas outside the selection will be cropped out).
To crop this part of the image, we simply click the Execute button (green tick icon) and the image is modified. DynamicCrop can be closed at that point if you do not need to use it further.
You can avoid having to drag the sides of the area selected inwards by simply not clicking the Reset button on DynamicCrop to begin with. If you simply open your image and then the DynamicCrop process, without clicking its Reset button or clicking anywhere in the image, simply click and drag an area inside your image.
This area can be refined further by doing as before - clicking and dragging its sides inwards or outwards. It can also be moved around by clicking anywhere inside and dragging it around. There is another transformation we can apply to it however - rotation. If you want to rotate the selected area, simply hover the mouse on any of the four corners, just outside the area selected. The mouse pointer will change to indicate rotation and you can click and drag the area selected to rotate it clockwise or anticlockwise, as you choose.
You may also define a specific angle and whether or not it is meant to be clockwise in the process window itself.
Clicking Execute as this point will produce the cropped image, with the rotation selected applied as well.
As pixels are square, rotating by anything other than 90°, 180° or 270° will require PixInsight to do some interpolation to make up your image as it would have looked had it been captured at the rotated angle you have set. By default, DynamicCrop will automatically determine and use the best algorithm for this Interpolation, though you can manually set one from its list, if desired.
Finally, we can actually select an area with DynamicCrop that is bigger than the image itself - it can be bigger on one, two, three or all four sides. If you click the Reset button and the image itself is selected alone, you can choose to drag the sides outwards rather than inwards, thus expanding the area selected beyond the image's boundaries. You are not allowed to manually create a selected area bigger than the image itself (e.g. if you zoom out), to help users avoid it (as it is not usual for a user to want to do this!). However, once you have an area defined, it can be manually expanded beyond the image's boundaries, as aforementioned.
Finally, we can actually select an area with DynamicCrop that is bigger than the image itself - it can be bigger on one, two, three or all four sides. If you click the Reset button and the image itself is selected alone, you can choose to drag the sides outwards rather than inwards, thus expanding the area selected beyond the image's boundaries. You are not allowed to manually create a selected area bigger than the image itself (e.g. if you zoom out), to help users avoid it (as it is not usual for a user to want to do this!). However, once you have an area defined, it can be manually expanded beyond the image's boundaries, as aforementioned.
If we click Execute at this point, the image will be the same but with a black border around it, as per the area that is over the image's boundaries. We can define a particular colour to this border, however. This is done in DynamicCrop's Fill Color tab. Here, we can enter specific R, G and B values from 0 to 1 corresponding to how we want the border colour to look like.
At the bottom of DynamicCrop, you see a preview of the colour that results from the R, G and B values entered thus far. Once you are happy, clicking Execute produces this coloured border.
This covers how to use the DynamicCrop process fully. Remember that since it is a dynamic process, you will need to close it and re-open it if you are going to use it on another image you have open. If however you wish to apply the same crop to a set of images, you can drag the New Instance button from DynamicCrop on to the PixInsight workspace and simply drag and drop this process icon over each and every image you have open, to apply exactly the same crop parameters to each image.
2. Cropping using Crop
The Crop process is a non-dynamic process, unlike DynamicCrop. As a result, it is simply opened on the side and an image that is open can be selected from its list at the top (so it reads certain parameters about the image, such as its current size).
If we expand the Resolution and Process Mode tabs, we can see more of how Crop works.
In Process Mode, the default mode selected is Absolute margins in pixels. This means that you will define your crop in pixels. We may select several other options from this menu.
If we select any of the options related to Inches or Centimetres, then what we do to our image will depend on the values under Resolution, since these values define how many pixels there are per unit length (Inches or Centimetres). I strongly recommend leaving the default Process Mode of Absolute margins in pixels selected as it is much easier to work with than real life unit length (since the Resolution then plays a role into how much what you enter is actually worth from your image).
To crop using Crop, we have two options. Firstly, we can enter a specific number of pixels we want left over under Target px for Width and Height. If we choose to reduce the number of pixels in Width by 1000, Crop will crop out 500 pixels from the left and 500 pixels from the right (whatever you enter is divided by 2 and is done to either corresponding side of the image). We can also enter a value under % for Width and Height and the Target px values are calculated according to what we enter. Since number of pixels always has to be integer numbers, not all values of % are allowed and PixInsight will automatically set the closest % value allowed.
To crop using Crop, we have two options. Firstly, we can enter a specific number of pixels we want left over under Target px for Width and Height. If we choose to reduce the number of pixels in Width by 1000, Crop will crop out 500 pixels from the left and 500 pixels from the right (whatever you enter is divided by 2 and is done to either corresponding side of the image). We can also enter a value under % for Width and Height and the Target px values are calculated according to what we enter. Since number of pixels always has to be integer numbers, not all values of % are allowed and PixInsight will automatically set the closest % value allowed.
Above, I cropped my image by approximately 80% in both Width and Height. Notice how the Margins/Anchors tab at the top has some values entered. These are entered automatically by PixInsight when you choose to set your crop parameters under the Dimensions tab. You can however enter values here yourself. This is required if you wish to crop more from the top than the bottom, for example, since by default Crop will crop the same from the top as from the bottom. The same applies if you wish to crop more from the left than from the right, for example. We could enter values such as:
The numbers were entered as negative numbers in order to actually crop (subtract from our image). These led to the following crop:
If we choose to enter positive numbers here, or enter values of Target px or % for Width and/or Height larger than the original (e.g. more pixels or over 100%), then we are doing the opposite of cropping. In this scenario, the image is expanded beyond its boundaries by the amounts specified by the user. Using Margins/Anchors allows the user to define specifically how many pixels to expand by in each side. Using Dimensions means that whatever the user chooses to expand by, is done equally to both sides corresponding to Width and Height. As with DynamicCrop, we can define the colour of the border produced by expanding the image beyond its boundaries, by entering R, G and B values under the Fill Color tab.
This covers everything it takes to use the non-dynamic Crop process for cropping one's images.
3. Resizing using Resample
Resizing one's images may be desired for publication (online or in print), or for upscaling a binned 2x2 image to unbinned 1x1 size, for example. For these purposes, PixInsight has the Resample process.
To start off, we should select the image we wish to resize in Resample's list at the top. This will populate the process with parameters read from the image itself, such as its present size.
Above, I have expanded the Interpolation and Resolution tabs for clarity. The Resample process is extremely simple to use. You simply have to enter new values under Target px for Width and Height, or values for % for both Width and Height, corresponding to the resize you wish to perform. For example, if we enter 50% for both Width and Height, PixInsight automatically tells us how many pixels this is going to be under Target px.
So long as we keep Preserve aspect ratio enabled, we will be forced to enter the same % values for both Width and Height. Similarly, entering a custom value for Width under Target px will automatically enter a corresponding one for Height according to the image's aspect ratio. Disabling this gives the user freedom to distort the image, though it is very likely you will never really want to disable Preserve aspect ratio for an astrophotograph.
Under the Resolution tab we can alter the number of pixels per unit length we wish. This will re-calculate the physical image size under Dimensions accordingly, as shown below.
Under the Resolution tab we can alter the number of pixels per unit length we wish. This will re-calculate the physical image size under Dimensions accordingly, as shown below.
The reduction in physical size of the image is due to the fact that though we have kept the same image size in pixels, we are now packing 300 pixels in every inch as opposed to the original 72 pixels per inch.
Any resampling done to the image will require some level of interpolation so that PixInsight re-creates your image faithfully in comparison to the original. There are number of algorithms available for selection, if desired, though leaving Algorithm set to Auto under Interpolation is a good idea simply because PixInsight will automatically select an appropriate algorithm. This has always worked exceptionally well for me.
It is likely you will only really use the Resample process when finalising an image for publication, whether it is online or for printing. Either way, its parameters will allow you to get the most out of the final images in terms of reproducing them faithfully in prints or online.
Any resampling done to the image will require some level of interpolation so that PixInsight re-creates your image faithfully in comparison to the original. There are number of algorithms available for selection, if desired, though leaving Algorithm set to Auto under Interpolation is a good idea simply because PixInsight will automatically select an appropriate algorithm. This has always worked exceptionally well for me.
It is likely you will only really use the Resample process when finalising an image for publication, whether it is online or for printing. Either way, its parameters will allow you to get the most out of the final images in terms of reproducing them faithfully in prints or online.
Comment Box is loading comments...