sjtans commited on
Commit
475d498
·
verified ·
1 Parent(s): 67a1302

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -269,7 +269,7 @@ def update(filepath, filepath_result, filepath_coordinates, z, c):
269
  return (filepath_show, display_boxes), (filepath_result_show, display_boxes)
270
 
271
 
272
- def filter_coordinates_alt(filepath_coordinates, z, image_shape=(512, 512, 10)):
273
 
274
  depth = 3
275
  coordinates = np.loadtxt(filepath_coordinates, delimiter=",")
@@ -283,22 +283,30 @@ def filter_coordinates_alt(filepath_coordinates, z, image_shape=(512, 512, 10)):
283
  #rel_z = np.abs(coordinates[:, 0]-z)
284
  #rel_z = rel_z[:, np.newaxis]
285
 
286
- markers = np.zeros((image_shape[0], image_shape[1], 2*depth-1))
287
 
288
  x_coord = tuple(coordinates[:,2])
289
  y_coord = tuple(coordinates[:,1])
290
- rel_z_coord = tuple(coordinates[:,0]-z)
291
- print(rel_z_coord)
292
- values = [1] * len(rel_z_coord )
 
 
293
 
294
  markers[x_coord, y_coord, rel_z_coord] = values
295
 
296
- print(rel_z_coord)
297
-
298
- boxes = sc.ndimage.gaussian_filter(markers, sigma=(5,5, depth)) > 0.001
299
 
300
- print(boxes)
301
- return [(boxes[:,:, depth],'nothing')]
 
 
 
 
 
 
 
 
302
 
303
  def add_boxes_norm_path(filepath, boxes):
304
  img = imread(filepath)
 
269
  return (filepath_show, display_boxes), (filepath_result_show, display_boxes)
270
 
271
 
272
+ def filter_coordinates_alt(filepath_coordinates, z, image_shape=(512, 512)):
273
 
274
  depth = 3
275
  coordinates = np.loadtxt(filepath_coordinates, delimiter=",")
 
283
  #rel_z = np.abs(coordinates[:, 0]-z)
284
  #rel_z = rel_z[:, np.newaxis]
285
 
286
+ boxes = np.zeros(image_shape)
287
 
288
  x_coord = tuple(coordinates[:,2])
289
  y_coord = tuple(coordinates[:,1])
290
+ size = tuple(4-np.abs(coordinates[:,0]-z))
291
+
292
+ for x, y, size in zip(x_coord, y_coord, size):
293
+ boxes = draw_box(markers, x, y, size)
294
+
295
 
296
  markers[x_coord, y_coord, rel_z_coord] = values
297
 
298
+ return [(boxes,'nothing')]
 
 
299
 
300
+ def draw_box(array, x, y, size):
301
+ x0 = max(x-size, 0)
302
+ y0 = max(y-size, 0)
303
+
304
+ x1 = min(x+size+1, array.shape[0]-1)
305
+ y1 = min(y+size+1, array.shape[1]-1)
306
+
307
+ array[x0:x1, y0:y1] = 1
308
+
309
+ return array
310
 
311
  def add_boxes_norm_path(filepath, boxes):
312
  img = imread(filepath)