Author Topic: New StarDetector JavaScript object  (Read 12071 times)

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
New StarDetector JavaScript object
« on: 2013 July 22 18:07:33 »
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:

open "$PXI_INCDIR/pjsr/StarDetector.jsh"

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

Code: [Select]
#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:

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!
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: New StarDetector JavaScript object
« Reply #1 on: 2013 July 24 12:37:54 »
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