def test_grey_dilation_operation_sparse_input_struct_zeros(self):
     struct = np.zeros((3, 3, 3))
     print("\n test_grey_dilation_operation_sparse_input_struct_zeros...")
     v_output = vc.grey_dilation(input_svar,
                                 structure=struct,
                                 make_float32=False)
     d_output = ndimage.grey_dilation(input_svar, structure=struct)
     msgs = "test_grey_dilation_operation_sparse_input_struct_zeros"
     self.assertTrue((d_output == v_output).all(), msg=msgs)
 def test_grey_dilation_operation_sparse_input_default_value(self):
     print("\n test_grey_dilation_operation_sparse_input_default_value...")
     v_output = vc.grey_dilation(input_svar,
                                 structure=structure,
                                 make_float32=False)
     d_output = ndimage.grey_dilation(
         input_svar,
         structure=structure,
     )
     msgs = "test_grey_dilation_operation_sparse_input_default_value"
     self.assertTrue((d_output == v_output).all(), msg=msgs)
	def __test_grey_dilation_operation(self,input_var):		
		print("\n grey_dilation Voxel testing...")
		start_time = t.time()
		v_output = vc.grey_dilation(input_var,structure=structure,no_of_blocks=PL[0],fakeghost=PL[1],make_float32=False)
		print("grey_dilation Voxel testing time taken: ",(t.time() - start_time)," sec")
		#print("\n grey_dilation Default testing...")
		start_time = t.time()
		d_output = ndimage.grey_dilation(input_var,structure=structure)
		print("grey_dilation Default testing time taken: ",(t.time() - start_time)," sec")		
		msgs = "grey_dilation_operation_FAIL_with parameters: ",PL
		self.assertTrue((d_output==v_output).all(), msg=msgs)
 def test_grey_dilation_operation_sparse_input_blocks_ten(self):
     print("\n test_grey_dilation_operation_sparse_input_blocks_ten...")
     v_output = vc.grey_dilation(input_svar,
                                 structure=structure,
                                 no_of_blocks=10,
                                 make_float32=False)
     d_output = ndimage.grey_dilation(
         input_svar,
         structure=structure,
     )
     msgs = "test_grey_dilation_operation_sparse_input_blocks_ten"
     self.assertTrue((d_output == v_output).all(), msg=msgs)
 def test_grey_dilation_operation_dense_input_fakeghost_four(self):
     print("\n test_grey_dilation_operation_dense_input_fakeghost_four...")
     v_output = vc.grey_dilation(input_dvar,
                                 structure=structure,
                                 fakeghost=4,
                                 make_float32=False)
     d_output = ndimage.grey_dilation(
         input_dvar,
         structure=structure,
     )
     msgs = "test_grey_dilation_operation_dense_input_fakeghost_four"
     self.assertTrue((d_output == v_output).all(), msg=msgs)
Example #6
0
def main():
    structure = np.ones((3, 3, 3))
    #.............test1. dense.......
    filename = 'gyroidUniform.npy'
    input = np.load(filename, mmap_mode="r")

    print(
        "..............................dense.............................................."
    )

    #0.Nothing..............
    print("\n nothing testing...")
    output = vc.nothing(input, blockSize=50, fakeGhost=4, makeFloat32=False)
    print("\nresult: ", (input == output).all())
    print(output.dtype, input.dtype)
    #1.grey_dilation..............
    print("\ngrey_dilation VoxelProcessind")
    output = vc.grey_dilation(input, structure=structure, makeFloat32=False)
    print("\ngrey_dilation Default")
    d = ndimage.grey_dilation(input, structure=structure)
    print("\nresult: ", (d == output).all())
    print(output.dtype, input.dtype)
    #2.grey_erosion..............
    print("\ngrey_erosion VoxelProcessind")
    output = vc.grey_erosion(input,
                             makeFloat32=False,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
    print("\ngrey_erosion Default")
    d = ndimage.grey_erosion(input,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
    print("\nresult: ", (d == output).all())
    #3.grey_closing..............
    print("\ngrey_closing VoxelProcessind")
    output = vc.grey_closing(input,
                             makeFloat32=False,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
    print("\ngrey_closing Default")
    d = ndimage.grey_closing(input,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
    print("\nresult: ", (d == output).all())
    print(output.dtype, input.dtype)
    #4.grey_opening..............
    print("\ngrey_opening VoxelProcessind")
    output = vc.grey_opening(input,
                             makeFloat32=False,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
    print("\ngrey_opening Default")
    d = ndimage.grey_opening(input,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
    print("\nresult: ", (d == output).all())
    #5.binary_closing..............
    print("\nbinary_closing VoxelProcessind")
    output = vc.binary_closing(input,
                               makeFloat32=False,
                               structure=None,
                               iterations=1,
                               output=None,
                               origin=0,
                               mask=None,
                               border_value=0,
                               brute_force=False)
    print("\nbinary_closing Default")
    d = ndimage.binary_closing(input,
                               structure=None,
                               iterations=1,
                               output=None,
                               origin=0,
                               mask=None,
                               border_value=0,
                               brute_force=False)
    print("\nresult: ", (d == output).all())
    print(output[151][151][151])
    #6.binary_opening..............
    print("\nbinary_opening VoxelProcessind")
    output = vc.binary_opening(input,
                               structure=None,
                               iterations=1,
                               output=None,
                               origin=0,
                               mask=None,
                               border_value=0,
                               brute_force=False)
    print("\nbinary_opening Default")
    d = ndimage.binary_opening(input,
                               structure=None,
                               iterations=1,
                               output=None,
                               origin=0,
                               mask=None,
                               border_value=0,
                               brute_force=False)
    print("\nresult: ", (d == output).all())
    #7.binary_dilation..............
    print("\nbinary_dilation VoxelProcessind")
    output = vc.binary_dilation(input,
                                makeFloat32=False,
                                structure=structure,
                                iterations=1,
                                mask=None,
                                output=None,
                                border_value=0,
                                origin=0,
                                brute_force=False)
    print("\nbinary_dilation Default")
    d = ndimage.binary_dilation(input,
                                structure=structure,
                                iterations=1,
                                mask=None,
                                output=None,
                                border_value=0,
                                origin=0,
                                brute_force=False)
    print("\nresult: ", (d == output).all())
    #8.binary_erosion..............
    print("\nbinary_erosion VoxelProcessind")
    output = vc.binary_erosion(input,
                               makeFloat32=False,
                               structure=None,
                               iterations=1,
                               mask=None,
                               output=None,
                               border_value=0,
                               origin=0,
                               brute_force=False)
    print("\nbinary_erosion Default")
    d = ndimage.binary_erosion(input,
                               structure=None,
                               iterations=1,
                               mask=None,
                               output=None,
                               border_value=0,
                               origin=0,
                               brute_force=False)
    print("\nresult: ", (d == output).all())
    #9.binary_fill_holes..............
    print("\nbinary_fill_holes VoxelProcessind")
    output = vc.binary_fill_holes(input,
                                  makeFloat32=False,
                                  structure=None,
                                  output=None,
                                  origin=0)
    print("\nbinary_fill_holes Default")
    d = ndimage.binary_fill_holes(input, structure=None, output=None, origin=0)
    print("\nresult: ", (d == output).all())
    #10.binary_hit_or_miss..............
    print("\nbinary_hit_or_miss VoxelProcessind")
    output = vc.binary_hit_or_miss(input,
                                   makeFloat32=False,
                                   structure1=None,
                                   structure2=None,
                                   output=None,
                                   origin1=0,
                                   origin2=None)
    print("\nbinary_hit_or_miss Default")
    d = ndimage.binary_hit_or_miss(input,
                                   structure1=None,
                                   structure2=None,
                                   output=None,
                                   origin1=0,
                                   origin2=None)
    print("\nresult: ", (d == output).all())
    #11.binary_propagation..............
    print("\nbinary_propagation VoxelProcessind")
    output = vc.binary_propagation(input,
                                   makeFloat32=False,
                                   structure=None,
                                   mask=None,
                                   output=None,
                                   border_value=0,
                                   origin=0)
    print("\nbinary_propagation Default")
    d = ndimage.binary_propagation(input,
                                   structure=None,
                                   mask=None,
                                   output=None,
                                   border_value=0,
                                   origin=0)
    print("\nresult: ", (d == output).all())
    #12.black_tophat..............
    print("\nblack_tophat VoxelProcessind")
    output = vc.black_tophat(input,
                             makeFloat32=False,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
    print("\nblack_tophat Default")
    d = ndimage.black_tophat(input,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
    print("\nresult: ", (d == output).all())
    #13.morphological_gradient..............
    print("\nmorphological_gradient VoxelProcessind")
    output = vc.morphological_gradient(input,
                                       makeFloat32=False,
                                       size=None,
                                       footprint=None,
                                       structure=structure,
                                       output=None,
                                       mode='reflect',
                                       cval=0.0,
                                       origin=0)
    print("\nmorphological_gradient Default")
    d = ndimage.morphological_gradient(input,
                                       size=None,
                                       footprint=None,
                                       structure=structure,
                                       output=None,
                                       mode='reflect',
                                       cval=0.0,
                                       origin=0)
    print("\nresult: ", (d == output).all())
    #14.morphological_laplace..............
    print("\nmorphological_laplace VoxelProcessind")
    output = vc.morphological_laplace(input,
                                      makeFloat32=False,
                                      size=None,
                                      footprint=None,
                                      structure=structure,
                                      output=None,
                                      mode='reflect',
                                      cval=0.0,
                                      origin=0)
    print("\nmorphological_laplace Default")
    d = ndimage.morphological_laplace(input,
                                      size=None,
                                      footprint=None,
                                      structure=structure,
                                      output=None,
                                      mode='reflect',
                                      cval=0.0,
                                      origin=0)
    print("\nresult: ", (d == output).all())
    #15.white_tophat..............
    print("\nwhite_tophat VoxelProcessind")
    output = vc.white_tophat(input,
                             makeFloat32=False,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
    print("\nwhite_tophat VoxelProcessind Default")
    d = ndimage.white_tophat(input,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
    print("\nresult: ", (d == output).all())
    #16.intMultiply..............
    print("\nintMultiply VoxelProcessind")
    output = vc.intMultiply(input,
                            makeFloat32=False,
                            blockSize=50,
                            fakeGhost=1,
                            scalar=10)
    print("\nintMultiply Default")
    d = input * 10
    print("\nresult: ", (d == output).all())

    print(
        "..............................Sparse.............................................."
    )

    input = random(400, 80000, density=0.3, dtype="float64")
    input = input.todense()
    input = np.array(input)
    input = np.reshape(input, (400, 200, 400))

    #0.Nothing..............
    print("\n nothing testing...")
    output = vc.nothing(input, makeFloat32=False)
    print("\nresult: ", (input == output).all())
    print(output.dtype, input.dtype)
    #1.grey_dilation..............
    print("\ngrey_dilation VoxelProcessind")
    output = vc.grey_dilation(input, structure=structure, makeFloat32=False)
    print("\ngrey_dilation Default")
    d = ndimage.grey_dilation(input, structure=structure)
    print("\nresult: ", (d == output).all())
    print(output.dtype, input.dtype)
    #2.grey_erosion..............
    print("\ngrey_erosion VoxelProcessind")
    output = vc.grey_erosion(input, makeFloat32=False, structure=structure)
    print("\ngrey_erosion Default")
    d = ndimage.grey_erosion(input, structure=structure)
    print("\nresult: ", (d == output).all())
    #3.grey_closing..............
    print("\ngrey_closing VoxelProcessind")
    output = vc.grey_closing(input, makeFloat32=False, structure=structure)
    print("\ngrey_closing Default")
    d = ndimage.grey_closing(input, structure=structure)
    print("\nresult: ", (d == output).all())
    print(output.dtype, input.dtype)
    #4.grey_opening..............
    print("\ngrey_opening VoxelProcessind")
    output = vc.grey_opening(input, makeFloat32=False, structure=structure)
    print("\ngrey_opening Default")
    d = ndimage.grey_opening(input, structure=structure)
    print("\nresult: ", (d == output).all())
    #5.binary_closing..............
    print("\nbinary_closing VoxelProcessind")
    output = vc.binary_closing(input, makeFloat32=False)
    print("\nbinary_closing Default")
    d = ndimage.binary_closing(input)
    print("\nresult: ", (d == output).all())
    #6.binary_opening..............
    print("\nbinary_opening VoxelProcessind")
    output = vc.binary_opening(input, makeFloat32=False)
    print("\nbinary_opening Default")
    d = ndimage.binary_opening(input)
    print("\nresult: ", (d == output).all())
    #7.binary_dilation..............
    print("\nbinary_dilation VoxelProcessind")
    output = vc.binary_dilation(input, makeFloat32=False, structure=structure)
    print("\nbinary_dilation Default")
    d = ndimage.binary_dilation(input, structure=structure)
    print("\nresult: ", (d == output).all())
    #8.binary_erosion..............
    print("\nbinary_erosion VoxelProcessind")
    output = vc.binary_erosion(input, makeFloat32=False)
    print("\nbinary_erosion Default")
    d = ndimage.binary_erosion(input)
    print("\nresult: ", (d == output).all())
    #9.binary_fill_holes..............
    print("\nbinary_fill_holes VoxelProcessind")
    output = vc.binary_fill_holes(input, makeFloat32=False)
    print("\nbinary_fill_holes Default")
    d = ndimage.binary_fill_holes(input)
    print("\nresult: ", (d == output).all())
    #10.binary_hit_or_miss..............
    print("\nbinary_hit_or_miss VoxelProcessind")
    output = vc.binary_hit_or_miss(input, makeFloat32=False)
    print("\nbinary_hit_or_miss Default")
    d = ndimage.binary_hit_or_miss(input)
    print("\nresult: ", (d == output).all())
    #11.binary_propagation..............
    print("\nbinary_propagation VoxelProcessind")
    output = vc.binary_propagation(input, makeFloat32=False)
    print("\nbinary_propagation Default")
    d = ndimage.binary_propagation(input)
    print("\nresult: ", (d == output).all())
    #12.black_tophat..............
    print("\nblack_tophat VoxelProcessind")
    output = vc.black_tophat(input, makeFloat32=False, structure=structure)
    print("\nblack_tophat Default")
    d = ndimage.black_tophat(input, structure=structure)
    print("\nresult: ", (d == output).all())
    #13.morphological_gradient..............
    print("\nmorphological_gradient VoxelProcessind")
    output = vc.morphological_gradient(
        input,
        structure=structure,
        makeFloat32=False,
    )
    print("\nmorphological_gradient Default")
    d = ndimage.morphological_gradient(input, structure=structure)
    print("\nresult: ", (d == output).all())
    #14.morphological_laplace..............
    print("\nmorphological_laplace VoxelProcessind")
    output = vc.morphological_laplace(input,
                                      structure=structure,
                                      makeFloat32=False)
    print("\nmorphological_laplace Default")
    d = ndimage.morphological_laplace(input, structure=structure)
    print("\nresult: ", (d == output).all())
    #15.white_tophat..............
    print("\nwhite_tophat VoxelProcessind")
    output = vc.white_tophat(input, makeFloat32=False, structure=structure)
    print("\nwhite_tophat VoxelProcessind Default")
    d = ndimage.white_tophat(input, structure=structure)
    print("\nresult: ", (d == output).all())
    #16.intMultiply..............
    print("\nintMultiply VoxelProcessind")
    output = vc.intMultiply(input, makeFloat32=False, scalar=10)
    print("\nintMultiply Default")
    d = input * 10
    print("\nresult: ", (d == output).all())
d = ndimage.binary_fill_holes(input_var, structure=structure)
print("scipy binary_fill_holes: ", (t.time() - start_time), " sec")
print("\nresult: ", (d == output).all())

#0.Nothing..............
print("\n nothing testing...")
start_time = t.time()
output = vc.nothing(input_var, no_of_blocks=7, fakeghost=4, make_float32=False)
print("vc nothing: ", (t.time() - start_time), " sec")
print("\nresult: ", (input_var == output).all())

#1.grey_dilation..............
print("\ngrey_dilation VoxelProcessing")
start_time = t.time()
output = vc.grey_dilation(input_var,
                          no_of_blocks=6,
                          structure=structure,
                          make_float32=False)
print("vc grey_dilation: ", (t.time() - start_time), " sec")
print("\ngrey_dilation Default")
start_time = t.time()
d = ndimage.grey_dilation(input_var, structure=structure)
print("scipy grey_dilation: ", (t.time() - start_time), " sec")
print("\nresult: ", (d == output).all())

#2.grey_erosion..............
print("\ngrey_erosion VoxelProcessing")
start_time = t.time()
output = vc.grey_erosion(input_var,
                         no_of_blocks=7,
                         make_float32=False,
                         structure=structure)
Example #8
0
print(process.memory_info())
print("\nNothing testing....")
start_time = t.time()
x = int(process.memory_info().rss)
output = vc.nothing(input, fakeGhost=3)
y = int(process.memory_info().rss)
print("Memory: ", (y - x) / 1000000)
print("sec:    ", (t.time() - start_time))
print("result: ", (input == output).all())

print(process.memory_info())
#.......test1..........
print("\ngrey_dilation VoxelProcessind")
start_time = t.time()
x = int(process.memory_info().rss)
output = vc.grey_dilation(input, fakeGhost=3, structure=structure)
y = int(process.memory_info().rss)
print("Memory: ", (y - x) / 1000000)
print("sec:    ", (t.time() - start_time))
# python -m memory_profiler memory.py
print(process.memory_info())
#......
print("\ngrey_dilation Default")
start_time = t.time()
x = int(process.memory_info().rss)
d = ndimage.grey_dilation(input, structure=structure)
y = int(process.memory_info().rss)
print("Memory: ", (y - x) / 1000000)
print("sec:    ", (t.time() - start_time))
print(process.memory_info())
Example #9
0
                             fakeghost=2,
                             make_float32=True,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',
                             cval=0.0,
                             origin=0)
#9
output_var = vc.grey_dilation(input_var,
                              no_of_blocks=4,
                              fakeghost=2,
                              make_float32=True,
                              size=None,
                              footprint=None,
                              structure=structure,
                              output=None,
                              mode='reflect',
                              cval=0.0,
                              origin=0)
#10
output_var = vc.grey_erosion(input_var,
                             no_of_blocks=4,
                             fakeghost=2,
                             make_float32=True,
                             size=None,
                             footprint=None,
                             structure=structure,
                             output=None,
                             mode='reflect',