我想将这两个投资回报率裁剪为两张图片:
我正在考虑通过脚本同步裁剪这两个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裁剪的线索,我将不胜感激。谢谢!
答案 0 :(得分:2)
此示例可以帮助您:
// 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) )
}