New StarDetector JavaScript object

Juan Conejero

PixInsight Staff
Staff member
Hi all,

Today I have released an update that installs a new standard PJSR header on all platforms: pjsr/StarDetector.jsh. This header defines the StarDetector object as part of the standard PJSR framework.

StarDetector is a JavaScript version of the new star detection engine implemented in the latest versions of the StarAlignment tool. To put the StarDetector object into perspective, see this forum post. This standard header just makes StarDetector an official PJSR member.

The header file is well documented. Before using it, I strongly recommend studying the source code. Once you have downloaded and installed the corresponding update (20130723-development), a portable way to open the header with PixInsight's script editor is entering this command in PI's console:

Code:
open "$PXI_INCDIR/pjsr/StarDetector.jsh"

The following script performs a quick test of the StarDetector object:

JavaScript:
#include <pjsr/StarDetector.jsh>
var D = new StarDetector;
D.test( ImageWindow.activeWindow.mainView.image, true/*starMask*/ );

Just open a deep-sky image (preferably a calibrated linear image) and run this script. It will generate a mask that you can enable on the image to check the detected stars.

There are several preprocessor macros that you can use to control some important features of StarDetector.jsh:

__PJSR_STAR_DETECTOR_VERSION

This macro contains the version number of the star detection engine. Currently it is 1.12.

__PJSR_NO_STAR_DETECTOR_TEST_ROUTINES

This macro is undefined by default. Define it before including the pjsr/StarDetector.jsh header to exclude a number of test functions implemented in the StarDetector object. Normally you should define this macro in production code, where the test routines are not necessary.

__PJSR_STAR_OBJECT_DEFINED

By default, if this macro is not defined, a Star object is defined as follows:

JavaScript:
function Star( pos, flux, size )
{
   this.pos = pos;   // centroid position in pixels, in image coordinates
   this.flux = flux; // total flux
   this.size = size; // area of detected star structure in square pixels
}

The StarDetector.stars() method returns an array of Star objects. If you want to use your own custom version of Star, define the __PJSR_STAR_OBJECT_DEFINED macro before including pjsr/StarDetector.jsh. Your Star object must provide the pos, flux and size members with the same meanings and types as the original structure. These members are of type Point, Number and Number, respectively.

Enjoy!
 
Thank you Juan, this release works perfectly, and the PJSR standardization and consistency with StarAlignment is now and will remain very helpful.

I just posted an update to one of my FWHM measuring scripts in this post, the batch version will follow shortly.

Mike
 
Back
Top