如何通过脚本将多 ROI 裁剪为 DM 中的图像?
How to crop multi-ROIs as images in DM by scripting?
我想将这两个 ROI 裁剪为两个图像:
我正在考虑通过脚本同步裁剪这两个 ROI,我找到了 D. R. G. Mitchell 编写的关于从 ROI 创建图像的代码。所以我写了这个:
image front := GetFrontImage()
imagedisplay imgdisp = front.ImageGetImageDisplay(0)
number roinum = imgdisp.ImageDisplayCountRois()
number x
for (x=0; x<roinum; x++)
{
roidisp = ImageDisplayGetROI(imgdisp,x)
image crop = front []
ShowImage(crop)
}
但它实际上只适用于一个投资回报率。如果您能给我一个关于如何处理多个 ROI 裁剪的线索,我将不胜感激。谢谢!
这个例子应该对你有帮助:
// ROIs are objects of the image display, so get that one first
Image input := GetFrontImage()
ImageDisplay disp = input.ImageGetImageDisplay(0)
// Iterate over all ROIs found on the display
number nRoi = disp.ImageDisplayCountROIs()
for (number i=0; i<nRoi; i++ )
{
ROI myRoi = disp.ImageDisplayGetROI( i )
// Test if the ROI has the properties you want
if ( !myROI.ROIIsRectangle() ) continue
if ( !myROI.ROIGetVolatile() ) continue
// Read the ROI region and use that to copy the data
number t, l, b, r
myROI.ROIGetRectangle( t, l, b, r )
// Use slice2 to address the area and ImageClone to get a clone
// inclusing tags, calibration etc.
image cut := input.Slice2(t,l,0, 0,(r-l),1, 1,(b-t),1 ).ImageClone()
cut.ShowImage()
// Optionally set some names
cut.SetName( input.GetName()+" #"+(i+1) )
// Optionally modify the roi
myRoi.ROISetVolatile( 0 )
myRoi.ROISetMoveable( 0 )
myRoi.ROISetLabel( "cut #"+(i+1) )
}
我想将这两个 ROI 裁剪为两个图像:
我正在考虑通过脚本同步裁剪这两个 ROI,我找到了 D. R. G. Mitchell 编写的关于从 ROI 创建图像的代码。所以我写了这个:
image front := GetFrontImage()
imagedisplay imgdisp = front.ImageGetImageDisplay(0)
number roinum = imgdisp.ImageDisplayCountRois()
number x
for (x=0; x<roinum; x++)
{
roidisp = ImageDisplayGetROI(imgdisp,x)
image crop = front []
ShowImage(crop)
}
但它实际上只适用于一个投资回报率。如果您能给我一个关于如何处理多个 ROI 裁剪的线索,我将不胜感激。谢谢!
这个例子应该对你有帮助:
// ROIs are objects of the image display, so get that one first
Image input := GetFrontImage()
ImageDisplay disp = input.ImageGetImageDisplay(0)
// Iterate over all ROIs found on the display
number nRoi = disp.ImageDisplayCountROIs()
for (number i=0; i<nRoi; i++ )
{
ROI myRoi = disp.ImageDisplayGetROI( i )
// Test if the ROI has the properties you want
if ( !myROI.ROIIsRectangle() ) continue
if ( !myROI.ROIGetVolatile() ) continue
// Read the ROI region and use that to copy the data
number t, l, b, r
myROI.ROIGetRectangle( t, l, b, r )
// Use slice2 to address the area and ImageClone to get a clone
// inclusing tags, calibration etc.
image cut := input.Slice2(t,l,0, 0,(r-l),1, 1,(b-t),1 ).ImageClone()
cut.ShowImage()
// Optionally set some names
cut.SetName( input.GetName()+" #"+(i+1) )
// Optionally modify the roi
myRoi.ROISetVolatile( 0 )
myRoi.ROISetMoveable( 0 )
myRoi.ROISetLabel( "cut #"+(i+1) )
}