Software Development > PCL and PJSR Development

PJSR: Any way to find if two ImageWindow are the same?

(1/2) > >>

bitli:
The following code


--- Code: ---var a = ImageWindow.windows;
var b = ImageWindow.windows;
Console.writeln(a[0], " " , b[0] , " " , a[0]==b[0], " ", a[0]===b[0])

--- End code ---
results in


--- Code: ---[object ImageWindow] [object ImageWindow] false false

--- End code ---
although a[0]and b[0] represent the same window.  I need to check if two windows are the same, is there any way?

-- bitli

NKV:
Do it via View.FullId

bitli:
Thanks. Unfortunately this does not solve my problem as I want to known which windows are new after a process. If a window is closed and then recreated, it may have the same id (as 'star_mask') even if it is new.

Anyhow closing the window from the script does not completely work either (signaled in the Bug list, the workaround I mentionned there does not work actually), so I need to find another approach.

-- bitli

mschuster:
I had a related problem, here is my workaround, which may or may not apply to you.

StarAlignment's 'Detect Stars' working mode creates a new view/window named <name>_stars<n> where <name> is the fullId of the target view and <n> is a typically a one or a two digit suffix added for uniqueness by StarAlignment. My script needs to determine the fullId of this new view. Of course my script knows <name> but not <n>.

So immediately prior to executing the process, my script generates a sequence of fullId's <name>_stars, <name>_stars1, <name>_stars2, ... The first name in the sequence that is NOT the fullId of an open view is assumed to be the name StarAlignment will use.

The code below is a helper function. For StarAlignment the "%d" format is appropriate. For other processes "%02d" is a better choice.

After executing StarAlignment I look for a view with the predicted name, using View.viewById(). If found, great, if not the prediction failed and I throw an error.

This scheme is designed to handle cases like this: Suppose prior to execution <name>_stars, <name>_stars1, and <name>_stars3 are open views. StarAlignment will use <name>_stars2. If no prediction is used and you do the simple thing of looking for the name with the largest <n> suffix, you will fail to find the proper view.


--- Code: ---function uniqueViewId1(baseId) {
   var id = baseId;
   for (var i = 1; !View.viewById(id).isNull; ++i) {
      id = baseId + format("%d", i);
   }
   return id;
}

--- End code ---

Juan Conejero:

--- Quote ---StarAlignment's 'Detect Stars' working mode creates a new view/window named <name>_stars<n> where <name> is the fullId of the target view and <n> is a typically a one or a two digit suffix added for uniqueness by StarAlignment.
--- End quote ---

Unfortunately StarAlignment only provides output properties for registered target images:

Table StarAlignment.outputData

(See the corresponding entry in the reference documentation). Another workaround is to create a complete (full-size) preview on the image window of interest. If you execute the StarAlignment instance in star detection mode (or other control mode such as structure detection) on the preview, it will be replaced and no new image window will be generated.

Navigation

[0] Message Index

[#] Next page

Go to full version