def grey_dilation(input_var, no_of_blocks=4, fakeghost=2, make_float32=True, size=None, footprint=None, structure=None, output=None, mode='reflect', cval=0.0, origin=0): ''' overload of grey_dilation methods in scipy module with only 3 extra parameters, no_of_blocks=4,fakeghost=2,make_float32=True ''' if fakeghost <= 2: if structure is not None: fakeghost = structure.shape[0] // 2 if fakeghost < 2: fakeghost = 2 operationArgumentDic = { "size": size, "footprint": footprint, "structure": structure, "output": output, "mode": mode, "cval": cval, "origin": origin } v = VoxelProcessing(input_var, no_of_blocks, fakeghost, make_float32, operation="grey_dilation", operationArgumentDic=operationArgumentDic) return v.main()
def binary_propagation(input_var, no_of_blocks=4, fakeghost=2, make_float32=True, structure=None, mask=None, output=None, border_value=0, origin=0): ''' overload of binary_propagation methods in scipy module with only 3 extra parameters, no_of_blocks=4,fakeghost=2,make_float32=True ''' if fakeghost <= 2: if structure is not None: fakeghost = structure.shape[0] // 2 if fakeghost < 2: fakeghost = 2 operationArgumentDic = { "structure": structure, "output": output, "origin": origin, "mask": mask, "border_value": border_value } v = VoxelProcessing(input_var, no_of_blocks, fakeghost, make_float32, operation="binary_propagation", operationArgumentDic=operationArgumentDic) return v.main()
def binary_hit_or_miss(input_var, no_of_blocks=4, fakeghost=2, make_float32=True, structure1=None, structure2=None, output=None, origin1=0, origin2=None): ''' overload of binary_hit_or_miss methods in scipy module with only 3 extra parameters, no_of_blocks=4,fakeghost=2,make_float32=True ''' if fakeghost <= 2: if structure1 is not None: fakeghost = structure1.shape[0] // 2 if fakeghost < 2: fakeghost = 2 operationArgumentDic = { "structure1": structure1, "structure2": structure2, "output": output, "origin1": origin1, "origin2": origin2 } v = VoxelProcessing(input_var, no_of_blocks, fakeghost, make_float32, operation="binary_hit_or_miss", operationArgumentDic=operationArgumentDic) return v.main()
def test_main(self): v = VoxelProcessing(input_svar, no_of_blocks=6, fakeghost=3, make_float32=False, operation="binary_dilation", operationArgumentDic=operationArgumentDic) v_output = v.main() d_output = ndimage.binary_dilation(input_svar, structure=structure) msgs = "binary_dilation_operation_FAIL_with parameters: " self.assertTrue((d_output == v_output).all(), msg=msgs)
def nothing(input_var, no_of_blocks=4, fakeghost=2, make_float32=True): ''' for algorithm testing purpose to make sure blocking and retriving stored output work as expected if output is same as input. Parameters ---------- input_var : type: 3D numpy array no_of_blocks : type: int, number of frame(block) you want in input array with respect to x axis. ex = 4 fakeghost : type: int, extra border around block, generally with respect to structure element size. ex = 1 make_float32 : type: boolean, do you want to type cast input numpy array to float32. Returns ------- output : 3d numpy array, same as input. ''' v = VoxelProcessing(input_var, no_of_blocks, fakeghost, make_float32) return v.main()
def multiply(input_var, no_of_blocks=4, fakeghost=2, make_float32=True, scalar=1): ''' return multiplication of each value in matrix with given scalar integer. Parameters ---------- scalar : int/float value with you want to do matrix multiplication. ''' operationArgumentDic = {"scalar": scalar} v = VoxelProcessing(input_var, no_of_blocks, fakeghost, make_float32, operation="multiply", operationArgumentDic=operationArgumentDic) return v.main()