在QuPath中获取注释的内部和外部边距,可以使用以下的脚本示例来实现:
import qupath.lib.objects.PathAnnotationObject
def annotation = getPathObject() as PathAnnotationObject
def region = annotation.getROI()
def bounds = region.getBounds()
def internalMargin = bounds.getMargin()
def externalMargin = bounds.getMargin().inverse()
println "Internal Margin: " + internalMargin
println "External Margin: " + externalMargin
在上述示例中,getPathObject()
函数用于获取当前选中的注释对象。然后,通过getROI()
方法获取注释对象的区域感兴趣(Region of Interest, ROI)。接下来,使用getBounds()
方法获取ROI的边界信息。
通过getMargin()
方法,我们可以获取ROI边界的内部和外部边距。getMargin()
返回一个Insets
对象,该对象包含了上边距、下边距、左边距和右边距的数值。我们可以通过调用inverse()
方法来获取外部边距。
最后,通过打印语句,我们输出内部边距和外部边距的值。
请注意,上述示例是基于QuPath 0.3.0版本的Groovy脚本。在更旧或更新版本中,可能会有一些差异,因此请根据您使用的QuPath版本进行相应的调整。