将 XY 校准从 2D 图像复制到 3D 图像

Copying an XY calibration from a 2D image to a 3D image

如何将图像的 2D 轴校准复制到相同大小的 3D 数据集,但具有额外的深度维度?

下面的脚本可以做到这一点。你为此使用 ImageGet/SetDimension....

image img2d := GetFrontImage()
if ( 2 != img2d.ImageGetNumDimensions() ) Throw( "Not 2D")
number sx = img2D.ImageGetDimensionSize(0)
number sy = img2D.ImageGetDimensionSize(1)

image img3d := RealImage("3D",4,sx,sy,10)
for( number i=0; i<2; i++ ){
    img3d.ImageSetDimensionScale( i, img2d.ImageGetDimensionScale(i) )
    img3d.ImageSetDimensionOrigin( i, img2d.ImageGetDimensionOrigin(i) )
    img3d.ImageSetDimensionUnitString( i, img2d.ImageGetDimensionUnitString(i) )
}
img3d.ShowImage()

但是,根据您需要 3D 图像的用途,最好克隆 2D 图像并将其制作成 3D 图像。这将保留所有 meta-data 但将数据值设置为 0.

image img2d := GetFrontImage()
if ( 2 != img2d.ImageGetNumDimensions() ) Throw( "Not 2D")

number sx = img2D.ImageGetDimensionSize(0)
number sy = img2D.ImageGetDimensionSize(1)
number sz = 10
    

image img3d := img2d.ImageClone()
img3d.ImageResize(3, sx, sy, sz)
img3d.ShowImage()