def firstParticle(imIn, imOut, grid=mamba.DEFAULT_GRID): """ Extraction of the first particle (in scanning order) of binary image imIn. The particle is put into image imOut and removed from imIn. If imIn is empty, imOut is also empty. imIn and imOut must be different. """ imWrk = mamba.imageMb(imIn) mamba.compare(imIn, imWrk, imWrk) mamba.build(imIn, imWrk, grid=grid) mamba.diff(imIn, imWrk, imIn) mamba.copy(imWrk, imOut)
def compare3D(imIn1, imIn2, imOut): """ Compares the two 3D images 'imIn1' and 'imIn2'. The comparison is performed pixelwise by scanning the two images from top left to bottom right starting with plane 0 and it stops as soon as a pixel is different in the two images. The corresponding pixel in 'imOut' is set to the value of the pixel of 'imIn1'. The function returns a tuple holding the position of the first mismatching pixel. The tuple value is (-1,-1,-1) if the two images are identical. 'imOut' is not reset at the beginning of the comparison. 'imIn1', imIn2' and 'imOut' can be 1-bit, 8-bit or 32-bit images of same size and depth. """ outl = len(imOut) in1l = len(imIn1) in2l = len(imIn2) if in1l != outl or in2l != outl: mamba.raiseExceptionOnError(core.MB_ERR_BAD_SIZE) z = 0 x = -1 y = -1 while x < 0 and z < outl: x, y = mamba.compare(imIn1[z], imIn2[z], imOut[z]) z += 1 if x < 0: z = -1 else: z -= 1 return (x, y, z)
def compare3D(imIn1, imIn2, imOut): """ Compares the two 3D images 'imIn1' and 'imIn2'. The comparison is performed pixelwise by scanning the two images from top left to bottom right starting with plane 0 and it stops as soon as a pixel is different in the two images. The corresponding pixel in 'imOut' is set to the value of the pixel of 'imIn1'. The function returns a tuple holding the position of the first mismatching pixel. The tuple value is (-1,-1,-1) if the two images are identical. 'imOut' is not reset at the beginning of the comparison. 'imIn1', imIn2' and 'imOut' can be 1-bit, 8-bit or 32-bit images of same size and depth. """ outl = len(imOut) in1l = len(imIn1) in2l = len(imIn2) if in1l!=outl or in2l!=outl: mamba.raiseExceptionOnError(core.MB_ERR_BAD_SIZE) z = 0 x = -1 y = -1 while x<0 and z<outl: x,y = mamba.compare(imIn1[z], imIn2[z], imOut[z]) z += 1 if x<0: z = -1 else: z -= 1 return (x,y,z)