【问题标题】:DM-script fast 3D offsetDM脚本快速3D偏移
【发布时间】:2022-12-07 04:01:10
【问题描述】:

尝试实现 3D 数据的偏移功能。这是一个测试代码,

image ThreeDOffSet(image img3D, number shiftx, number shiftY) {
    image img3DTmp, rst
    img3DTmp:=img3D.ImageClone()
    img3DTmp=img3D[icol+shiftx, irow+shifty, iplane]
    //img3D_.showImage()
    return img3DTmp
}
void main() {
    number startTick, stopTick
    startTick = GetHighResTickCount()
    image img3D:=exprSize(200, 200, 1024,random())
    image rst:=img3D.ThreeDOffSet(10, -6)
    stopTick = GetHighResTickCount()
    img3D.showImage()
    rst.showImage()
    result("\nDuration:"+(stopTick-StartTick)/GetHighResTicksPerSecond()+"sec\n")
}
main()

DM 脚本能比这更快吗?

【问题讨论】:

    标签: dm-script


    【解决方案1】:

    找到了更快的方法。这快了 20 倍。

    image ThreeDOffSet(image img3D, number shiftx, number shiftY, number method) {
        number startTick, stopTick, d0,d1, d2, x, y
        image rst
        startTick = GetHighResTickCount()
        if (method==0) {
            rst:=img3D.ImageClone()
            rst=img3D[icol+shiftx, irow+shifty, iplane]
            stopTick = GetHighResTickCount()
        }
        else if (method==1) {
            img3D.get3dsize(d0,d1,d2)
            rst:=exprSize(d0,d1,d2,0)
            x=shiftX
            y=ShiftY
            rst[x,y,0,d0,d1,d2]=img3D.slice3(0,0,0,0,d0-x,1, 1,d1-y,1,2,d2,1)
            stopTick = GetHighResTickCount()
        }
        result("
    Duration:"+(stopTick-StartTick)/GetHighResTicksPerSecond()+"sec
    ")
        return rst
    }
    void main() {
        number method
        image rst
        image img3D:=exprSize(200, 200, 1024,random())
        getnumber("method", method,method) 
        rst:=img3D.ThreeDOffSet(10, 6,method)
        img3D.showImage()
        rst.showImage()
        
    }
    main()
    

    【讨论】:

    • 需要更多的“if-else”来处理 shiftX 和 shiftY 的符号。
    猜你喜欢
    • 2012-11-16
    • 1970-01-01
    • 2018-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-27
    相关资源
    最近更新 更多