Collapsing images along a dimension
Frank Valdes wrote on Dec 10, 1999
Q: Is there any one-step way to collapse an image cube from 3 to 2 dimensions?
I am doing two steps: first imslice on the 3-D cube, then followed by
imcombine on all the resulting 2-D images. Tedious for cubes with 30
images.
A: IMCOMBINE can collapse and combine in one step if you are
collapsing along the third (highest) dimension. The "project"
parameter allows IMCOMBINE to treat an N-dim image as a collection of
N-1 dim images. So it sounds like this is what you want for the case
of collapsing the 3rd dim. The combining can use any of the rejection
options and produce the average, median, or subaverage (with minmax
rejection). To get a sum you would need to multiply the image after
the averaging.
Another commonly used task to collapse along any axis is BLKAVG. This
is done by setting the blocking factor to the length of a dimension you
can average or sum everything along a dimension. For example if you
have an AxBxC 3-dim image and you want to collapse the B axis then
cl> blkavg 3dim temp 1 B 1
will produce an Ax1xC 3-dim image. Note that this leaves the image as
3D but one axis only one pixel wide. You can then reduce the dimensionality
with an IMCOPY
cl> imcopy temp[*,1,*] 2dim
In summary,
1) use IMCOMBINE with project if you want to reduce the highest dimension.
2) use BLKAVG and IMCOPY to collapse by averaging or summing along
any dimension.
cl> blkavg im1 im2 1 N 1 # Average second dimension
cl> imcopy im2[*,1,*] im3 # Remove superflous dimension
Last post on Dec 10, 1999