imagedimensiondm-script

Concerning extracting the size info of the image


I am trying to extract the dimension size info of the image with GetSize() and Get3DSize() as follows:

try { 2DData.Get3DSize (sizeX, sizeY, sizeZ); }
catch { 2DData.GetSize (sizeX, sizeY); Break; } 
OKDialog ("Size in Z direction ="+ sizeZ)

For 2D data, Get3DSize() apparently does not work and the stuff within catch() will be executed to catch this error. Strange is that the size in the Z direction can still be extracted and it is 1. What happens here?


Solution

  • GMS will internally use dimension size 1 for "non-existing" dimensions.

    GetSize() and Get3DSize() are only old convenience "shorthand" commands. I would recommend using:

        image test := realImage("",4,100)
    //    image test := realImage("",4,10,20)
    //    image test := realImage("",4,10,20,30)
        number x,y,z
        test.ImageGetDimensionSizes(x,y)
        result("\n x="+x)
        result("\n y="+y)
        test.ImageGetDimensionSizes(x,y,z)
        result("\n x="+x)
        result("\n y="+y)
        result("\n z="+z)
        result("\n # values:"+(x*y*z))