Hannes Kuchelmeister commited on
Commit
1f21e52
·
1 Parent(s): 8df7617

do not add out path to paths in json file

Browse files
annotation-preprocessing/1_splitting_into_patches.py CHANGED
@@ -48,15 +48,16 @@ def extract_object_tiles(obj, stack_images, in_folder, threshold = 0.25):
48
  # Get tiles of the image that contain bounding box of object
49
  for y in range(y_start, y_end, size):
50
  for x in range(x_start, x_end, size):
51
- stack = []
52
- if compute_overlap([x, y, x + size, y + size], [obj.x_min, obj.y_min, obj.x_max, obj.y_max]) > size * size * threshold:
53
- for row, img in focus_stack_images:
54
- box = [x, y, x + size, y + size]
55
- crop = img.crop(box)
56
 
57
- neighbours = get_neighbours(img, x, y, size)
58
- stack.append((row, box[:2], crop, neighbours))
59
- tiles.append(stack)
 
 
 
 
 
 
60
  return tiles
61
 
62
 
@@ -64,11 +65,10 @@ def save_tile(original_file_path, out_dir, x : int, y : int, img, overwrite = Fa
64
  path, file_name = os.path.split(original_file_path)
65
  name, ext = os.path.splitext(file_name)
66
 
67
- out_path = os.path.join(out_dir, path)
68
- save_to = os.path.join(out_path, f'{name}_{x}_{y}{ext}')
69
 
70
- if not os.path.exists(out_path):
71
- os.makedirs(out_path)
72
  if overwrite or not os.path.exists(save_to):
73
  img.save(save_to)
74
  return save_to
 
48
  # Get tiles of the image that contain bounding box of object
49
  for y in range(y_start, y_end, size):
50
  for x in range(x_start, x_end, size):
 
 
 
 
 
51
 
52
+ if compute_overlap([x, y, x + size, y + size], [obj.x_min, obj.y_min, obj.x_max, obj.y_max]) > size * size * threshold:
53
+ stack = []
54
+ for row, img in focus_stack_images:
55
+ box = [x, y, x + size, y + size]
56
+ crop = img.crop(box)
57
+
58
+ neighbours = get_neighbours(img, x, y, size)
59
+ stack.append((row, box[:2], crop, neighbours))
60
+ tiles.append(stack)
61
  return tiles
62
 
63
 
 
65
  path, file_name = os.path.split(original_file_path)
66
  name, ext = os.path.splitext(file_name)
67
 
68
+ save_to = os.path.join(path, f'{name}_{x}_{y}{ext}')
 
69
 
70
+ if not os.path.exists(path):
71
+ os.makedirs(path)
72
  if overwrite or not os.path.exists(save_to):
73
  img.save(save_to)
74
  return save_to