Example #1
0
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()
Example #2
0
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()
Example #3
0
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()
Example #4
0
 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)
Example #5
0
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()
Example #6
0
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()
Example #7
0
    def test_init(self):

        v = VoxelProcessing(input_svar,
                            no_of_blocks=6,
                            fakeghost=3,
                            make_float32=False,
                            operation="binary_dilation",
                            operationArgumentDic=operationArgumentDic)
        self.assertEqual(v.get_X(), 400, "wrong X size")
        self.assertEqual(v.get_Y(), 400, "wrong Y size")
        self.assertEqual(v.get_Z(), 400, "wrong Z size")
        self.assertEqual(v.get_make_float32(), False, "wrong get_make_float32")
        self.assertEqual(v.get_fakeghost(), 3, "wrong get_fakeghost")
        self.assertEqual(v.get_sparsed(), True, "wrong get_sparsed")
        self.assertEqual(v.get_block_size(), 80, "wrong get_block_size")
        self.assertEqual(v.get_no_of_blocks(), 5, "wrong get_no_of_blocks")
        self.assertEqual(v.get_operation(), "binary_dilation",
                         "wrong get_operation")
        self.assertEqual(v.get_operationArgumentDic(), operationArgumentDic,
                         "wrong get_operationArgumentDic")
        self.assertTrue(isinstance(v, VoxelProcessing),
                        msg="not create instance of voxelprocessing")