Author Topic: First steps with PJSR script  (Read 6740 times)

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
First steps with PJSR script
« on: 2009 January 11 12:00:21 »
Hello,

I am currently doing my first steps with PJSR scripts. I started studying the spherize.jsr script. I was wondering where I could find information on the methods that the different classes have available, such as img.interpolate() in function InterpolateColor(). It appears in the list of methods for the Image-class, but I cannot find any documentation, Looking at the PCL documentation (e.g. http://www.pixinsight.com/pcl/doc/html/classpcl_1_1Generic2DImage.html) also did not reveal any details.

Is there any place where I can find more about the PJSR methods? Is there a more or less direct mapping between PCL and PJSR?

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline David Serrano

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 503
Re: First steps with PJSR script
« Reply #1 on: 2009 January 11 12:11:08 »
The fastest reference appears in the Script Editor window itself. At the right there's a tree structure that lists all methods and properties of each object. In the case of methods, the type of the parameters and of the return value is shown, which is enough most of the time.

Welcome to PJSR! ;)
--
 David Serrano

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
First steps with PJSR script
« Reply #2 on: 2009 January 11 12:27:59 »
Well, in the case of interpolate(), the tree view tells me "Number interpolate(Number x, Number y, [int c])", which is not too helpful. What is x, what is y, what is c? In this example, I can derive a little bit from studying the example script, but even then it does not tell me any details such as the meaning of different interpolation types or the behaviour if (x,y) are outside of image boundaries.

I know that some people like programming using an try-and-error style, but personally, I am not too comfortable with this  :( . Any remedy available (without going to the doctor first  :wink: )?

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
First steps with PJSR script
« Reply #3 on: 2009 January 11 13:51:46 »
Hi Georg,

I realize that unfortunately, we lack any documentation for the PJSR, which is a serious problem for developers to get involved into script programming on PixInsight.

As I'm sure you know perfectly, writing such a documentation isn't the easiest task. It is indeed very time-consuming, and time is a scarce resource for us right now.

So, please feel free to ask here about any PJSR property or method you need, and we'll try to provide you with the necessary information. Eventually, we can collect all of our answers into a manual :D

Code: [Select]
Number Image.interpolate( Number x, Number y[, int c] )

This method generates an interpolated sample value for the specified x and y coordinates and the optional channel index c. Coordinates and channel indexes are counted from zero. If no channel is specified, Image.selectedChannel is assumed.

Out-of-range coordinates, i.e. values outside the ranges [0, Image.width-1] for x and [0, Image.height-1] for y, are legal. When an out-of-range coordinates is specified, zero is returned.

Channel indexes must refer to existing image channels, i.e. c must be within the range [0, Image.numberOfChannels-1], or a runtime exception will be thrown.

The current interpolation algorithm, given by the Image.interpolation property, is used. Available interpolations are enumerated in the standard pjsr/Interpolation.jsh header file. Filter-based interpolations, namely:

Code: [Select]
Interpolation_MitchellNetravaliFilter
Interpolation_CatmullRomSplineFilter
Interpolation_CubicBSplineFilter


also use the Image.interpolationSmoothness, Image.interpolationXRadius, and Image.interpolationYRadius properties, although the default values for these properties are in general appropriate for most tasks.

The value returned by Image.interpolate() is a normalized sample value in the range [0,1] (0=black, 1=white). This is the abstract range employed by all PJSR image processing routines for all supported data types.

Hope this helps.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
First steps with PJSR script
« Reply #4 on: 2009 January 11 14:56:22 »
Juan,

thanks for the reply, and I will happily come back to your offer about explaining PJSR as necessary. Maybe some day there will be something like doxygen for Javascript, generating a PCL-like documentation for you...

Have a nice week,
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)