Commit
·
822d985
1
Parent(s):
60acf32
Optimizing functions to produce dataset with large image sizes
Browse files
Data_Generation/Piecewise_Box_Functions.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import numpy as np
|
|
|
|
| 2 |
import math
|
| 3 |
|
| 4 |
|
|
@@ -77,12 +78,11 @@ def update_array(array_original, array_new, image_size):
|
|
| 77 |
def add_pixels(array_original, additional_pixels, image_size):
|
| 78 |
# Adds pixels to the thickness of each component of the box
|
| 79 |
A = array_original
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
A =
|
| 87 |
-
return A
|
| 88 |
-
|
|
|
|
| 1 |
import numpy as np
|
| 2 |
+
from scipy import signal
|
| 3 |
import math
|
| 4 |
|
| 5 |
|
|
|
|
| 78 |
def add_pixels(array_original, additional_pixels, image_size):
|
| 79 |
# Adds pixels to the thickness of each component of the box
|
| 80 |
A = array_original
|
| 81 |
+
filter = np.array(([0, 1, 0], [1, 1, 1], [0, 1, 0])) # This filter will only add value where there are pixels on
|
| 82 |
+
# the top, bottom, left or right of a pixel
|
| 83 |
+
|
| 84 |
+
# This filter adds thickness based on the desired number of additional pixels
|
| 85 |
+
for item in range(additional_pixels):
|
| 86 |
+
convolution = signal.convolve2d(A, filter, mode='same')
|
| 87 |
+
A = np.where(convolution <= 1, convolution, 1)
|
| 88 |
+
return A
|
|
|