marta-marta commited on
Commit
9c41b55
·
1 Parent(s): 9da5a1c

Added function to combine a list of arrays

Browse files
.idea/.name CHANGED
@@ -1 +1 @@
1
- Dataset_Generation_Functions.py
 
1
+ app.py
Data_Generation/Piecewise_Box_Functions.py CHANGED
@@ -1,4 +1,3 @@
1
- import matplotlib.pyplot as plt
2
  import numpy as np
3
  from scipy import signal
4
 
@@ -42,6 +41,8 @@ def hamburger_array(image_size, thickness):
42
  return A
43
 
44
 
 
 
45
  def add_thickness(array_original, thickness):
46
  A = array_original
47
  if thickness == 0: # want an array of all 0's for thickness = 0
@@ -56,22 +57,8 @@ def add_thickness(array_original, thickness):
56
  return A
57
 
58
 
59
- basic = basic_box_array(10, 1)
60
- densitys = [0.25,0,75,1]
61
- # multiple = np.repeat(basic, 3, axis=1 +)#np.multiply(basic,densitys)
62
-
63
- multiple = np.array([basic]*4, order='C')
64
- # multiple = np.concatenate(4*[[basic]], axis=0)
65
- # multiple = np.swapaxes(multiple, 0,2)
66
- # multiple = np.stack(4*[[basic]], axis=-1)
67
-
68
- # multiple = np.moveaxis(multiple, [0], [2])
69
- print(multiple)
70
- print(np.shape(multiple))
71
- multiple = np.multiply(densitys, multiple)
72
- print(np.shape(multiple))
73
- # print(multiple)
74
- plt.imshow((multiple[0]))
75
- plt.show()
76
-
77
-
 
 
1
  import numpy as np
2
  from scipy import signal
3
 
 
41
  return A
42
 
43
 
44
+ ########################################################################################################################
45
+ # The function to add thickness to struts in an array
46
  def add_thickness(array_original, thickness):
47
  A = array_original
48
  if thickness == 0: # want an array of all 0's for thickness = 0
 
57
  return A
58
 
59
 
60
+ # The function to efficiently combine arrays in a list
61
+ def combine_arrays(arrays):
62
+ output_array = np.sum(arrays, axis=0) # Add the list of arrays
63
+ output_array = np.array(output_array > 0, dtype=int) # Convert all values in array to 1
64
+ return output_array