Reputation: 11
I wrote a little program that copies the frame and position of a ROI from an image to an other image of the same size. What I want to do now is to connect the two ROIs in way that when I move one ROI the other one is moving accordingly.
On Dave's mitchell DM scripting website, I found that he used the function ConnectObject. but he does not explain how it works. I read the DM3's documentation and I couldn't find any information about that function.
Upvotes: 1
Views: 131
Reputation: 2949
For simple things there is another option:
In this case, the ROIs are "linked" automatically, because they really are only a single object in memory (but displayed on two displays.) Changing one will change the other. However, this linkage is "lost" if you save/load the images, because when you load the image, all ROIs (in memory) are newly created. Here is some simple example code:
image img1, img2
GetTwoLabeledImagesWithPrompt("Select two images of same size.", "Select", "Source", img1, "Destination", img2 )
imageDisplay disp1 = img1.ImageGetImageDisplay( 0 )
imageDisplay disp2 = img2.ImageGetImageDisplay( 0 )
number nR = disp1.ImageDisplayCountROIs()
for ( number i = 0; i<nR; i++ )
{
ROI theROI = disp1.ImageDisplayGetROI(i)
disp2.ImageDisplayAddROI(theROI)
}
Upvotes: 0
Reputation: 2949
There are two concepts here which would work. You can use one of two methods:
1) Use "ConnectObject" to attach some functionality to when a ROI is moved, i.e. when you move ROI 1 it "triggers" code which you can use to update other rois.
2) Use "ImageDisplayListeners" to attach functionality to when any ROI on a specific imageDisplay is moved, i.e. when a ROI an image A is moved it triggers code which you can use to update other rois.
You will find example code in this answer.
Upvotes: 0