问题
In DigitalMicrograph I have a 3D data cube of size [X x Y x Z] and I would like to extract a single spectrum at position X/Y. I know I can address the sub-volume by two opposing corners (x1/y1/z1) and (x2/y2/z2). But when I do this in the script below, I only get a LinePlot display with a single value. What am I doing wrong ?
number px = 5
number py = 3
image SIblock := GetFrontImage()
number sx, sy, sz
Get3DSize( SIblock, sx, sy, sz )
image spec = SIblock[ px, py, 0, px+1, py+1, sz ]
ShowImage( spec )
回答1:
You solution addresses the right section of the volume but as a [1 x 1 x sz] image. You could rotate the image, but a better solution is to use the slice1() command which directly access a 1-dimensional subvolume as in the following modified script:
number px = 5
number py = 3
image SIblock := GetFrontImage()
number sx, sy, sz
Get3DSize( SIblock, sx, sy, sz )
image spec := Slice1( SIblock, px,py,0, 2,sz,1 )
image specCopy := ImageClone( spec )
ShowImage( specCopy )
The command has 7 parameters: the source image (any dimension), the starting coordinate of the volume as x/y/z and a triplet describing the sampling: The direction ( 0=x 1=y 2=z ), the number of steps in that direction and a stepsize.
Note that my script also used image spec :=
and not image spec =
. The difference is, that =
copies the values (and creates a new image) while :=
assigns the right-handside. spec is just another name for the identical memory space of SIblock. Changing the values of spec would change the according subvolume of SIblock. My script therefore creates another image specCopy with the command ImageClone() to really creat a separate 'extracted' image.
来源:https://stackoverflow.com/questions/26275689/how-do-i-extract-a-spectrum-from-a-3d-spectrum-image