(self, com, size, dsize=(128, 128))
return numpy.dot(off, numpy.dot(scale, trans))
Calculate affine transform from crop
        :param com: center of mass, in image coordinates (x,y,z), z in mm
        :param size: (x,y,z) extent of the source crop volume in mm
        :return: affine transform
Calculate affine transform from crop
        :param com: center of mass, in image coordinates (x,y,z), z in mm
        :param size: (x,y,z) extent of the source crop volume in mm
        :return: affine transform
Calculate affine transform from crop : param com : center of mass in image coordinates ( x y z ) z in mm : param size : ( x y z ) extent of the source crop volume in mm : return : affine transform
def comToTransform(self, com, size, dsize=(128, 128)):
        """
        Calculate affine transform from crop
        :param com: center of mass, in image coordinates (x,y,z), z in mm
        :param size: (x,y,z) extent of the source crop volume in mm
        :return: affine transform
        """

        xstart, xend, ystart, yend, _, _ = self.comToBounds(com, size)

        trans = numpy.eye(3)
        trans[0, 2] = -xstart
        trans[1, 2] = -ystart

        wb = (xend - xstart)
        hb = (yend - ystart)
        if wb > hb:
            scale = numpy.eye(3) * dsize[0] / float(wb)
            sz = (dsize[0], hb * dsize[0] / wb)
        else:
            scale = numpy.eye(3) * dsize[1] / float(hb)
            sz = (wb * dsize[1] / hb, dsize[1])
        scale[2, 2] = 1

        xstart = int(numpy.floor(dsize[0] / 2. - sz[1] / 2.))
        ystart = int(numpy.floor(dsize[1] / 2. - sz[0] / 2.))
        off = numpy.eye(3)
        off[0, 2] = xstart
        off[1, 2] = ystart

        return numpy.dot(off, numpy.dot(scale, trans))
def comToTransform ( self , com , size , dsize = ( 128 , 128 ) ) : xstart , xend , ystart , yend , _ , _ = self . comToBounds ( com , size ) trans = numpy . eye ( 3 ) trans [ 0 , 2 ] = - xstart trans [ 1 , 2 ] = - ystart wb = ( xend - xstart ) hb = ( yend - ystart ) if wb > hb : scale = numpy . eye ( 3 ) * dsize [ 0 ] / float ( wb ) sz = ( dsize [ 0 ] , hb * dsize [ 0 ] / wb ) else : scale = numpy . eye ( 3 ) * dsize [ 1 ] / float ( hb ) sz = ( wb * dsize [ 1 ] / hb , dsize [ 1 ] ) scale [ 2 , 2 ] = 1 xstart = int ( numpy . floor ( dsize [ 0 ] / 2. - sz [ 1 ] / 2. ) ) ystart = int ( numpy . floor ( dsize [ 1 ] / 2. - sz [ 0 ] / 2. ) ) off = numpy . eye ( 3 ) off [ 0 , 2 ] = xstart off [ 1 , 2 ] = ystart return numpy . dot ( off , numpy . dot ( scale , trans ) )