Author Topic: How to open a process icon in JS  (Read 6679 times)

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
How to open a process icon in JS
« on: 2009 March 18 17:32:25 »
Hi,

I am trying to apply a DBE to an image using JS. I want to define a process icon and then apply it to several images. How can I create a DynamicBackgroundExtraction object from a process icon?

Thanks in advance.

Offline David Serrano

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 503
How to open a process icon in JS
« Reply #1 on: 2009 March 18 18:54:23 »
Interesting question ;).

A process icon is nothing more that a visual representation of one instance of an object. In JS, you don't need any visual representation, since you are going to use the process programatically, and don't need to show anything to the user. So you would just instantiate the object and play with it to your liking.

That said, I don't know how to manage dynamic processes (a category DBE belongs) from JS. A quick look reveals that you can create the object and specify the location of all samples, but it seems that it's not possible to generate samples automatically (although there are settable properties for samplesPerRow, tolerance and such things).

-----

Hmmm... I just read your question again ;). Now I think you've already configured the instance and would like to use it. You need a little of copy and paste: go to Process --> <Etc> --> ProcessContainer and drag and drop your DBE instance onto it. A relevant (and potentially large) piece of JS code will appear in the right panel, just copy it to your code and integrate it as needed.

This is not "creating a DBE object from a process icon" as you asked, but this is the only way I see since AFAIK you have no access to the process icons from JS. Should the desktop background be an object? ;)
--
 David Serrano

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
How to open a process icon in JS
« Reply #2 on: 2009 March 19 01:36:06 »
Hi Andres, David,

Excellent questions and discussion topics. David has already described the required procedure to obtain the JavaScript equivalent to an existing instance (import from ProcessContainer and copy the right-panel's script contents), so let's restart from the end (reverse iterator :) ):

Quote
Should the desktop background be an object?


Definitely yes. I'm working on this (among many other new features) for version 1.5. It is the Workspace JavaScript object, which will give access to most elements of PixInsight's workspace. Another new object is Icon, with two derived objects: ProcessIcon and ImageIcon.

ProcessIcon and ImageIcon allow you to control most properties and methods of icons in PixInsight. For example, you can create process icons with instances generated programatically from JavaScript code, rename them, define their textual information, get copies of their transported instances, save/load .psm files, and delete icons. You can also iconize an image and send the icon to the third workspace, for example. This is Just to enumerate a set of key features.

Workspace allows you to move and organize windows and Icon instances, and to manage multiple workspaces. In fact you can write a fancy workspace organizer with JavaScript very easily :)

Note that these objects and functions are going to be exclusive of PixInsight's scripting engine. The PCL won't define equivalent C++ classes (although a module can define and execute JavaScript code programatically, using the Console C++ class, if the user has given it enough permissions).

Quote
That said, I don't know how to manage dynamic processes (a category DBE belongs) from JS. A quick look reveals that you can create the object and specify the location of all samples, but it seems that it's not possible to generate samples automatically (although there are settable properties for samplesPerRow, tolerance and such things).


No, you can't define samples automatically by telling DBE's interface to generate them. This is because there's no way to interact with a processing interface from JS, and the automatic sample generation feature belongs to DBE's interface, not to the DBE process.

Although you can define DBE samples very easily from JS code, by doing so you can't force a DBE instance to acquire actual sample values from a particular image. So even if you define an instance with a set of DBE samples regularly located over an image, you still depend on a user loading the instance from DBE's interface.

Now this leads us to a third category of improvements to PixInsight's scripting engine: interaction with processing interfaces. To accomplish this task a new ProcessingInterface object should be defined. ProcessingInterface (from which a corresponding derived object should be created automatically for each installed interface) should expose a large number of dynamic and static methods and data items available on PI's processing interfaces. For example, DBE's automatic generation feature would be available as a method of the DBE interface object. These mechanisms are extremely complex and still unclear. Basically, with this implemented you could automatize an entire workflow, turning the entire PixInsight environment into a robot. This has endless possibilities, but the amount of work required is immense. :)
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
How to open a process icon in JS
« Reply #3 on: 2009 March 19 03:45:44 »
Quote from: "Juan Conejero"

Definitely yes. I'm working on this (among many other new features) for version 1.5. It is the Workspace JavaScript object, which will give access to most elements of PixInsight's workspace. Another new object is Icon, with two derived objects: ProcessIcon and ImageIcon.

ProcessIcon and ImageIcon allow you to control most properties and methods of icons in PixInsight. For example, you can create process icons with instances generated programatically from JavaScript code, rename them, define their textual information, get copies of their transported instances, save/load .psm files, and delete icons. You can also iconize an image and send the icon to the third workspace, for example. This is Just to enumerate a set of key features.


Thanks Juan. I'm looking forward for version 1.5.

I am trying to implement a postcalibration / prestacking process to remove gradients in the images. I usually photograph from very light polluted skies (Madrid) and the different gradients in the images affect the quality of the stacking. Substracting the median of the images before stacking helps a lot, but it is better to use PixInsight's Background Extraction.
This, however, have to be done manually and it is very time consuming.