Fahimeh Orvati Nia commited on
Commit
95a536e
·
1 Parent(s): c60418f
sorghum_pipeline/data/preprocessor.py CHANGED
@@ -27,7 +27,10 @@ class ImagePreprocessor:
27
  boxes = [(j, i, j + d, i + d)
28
  for i, j in product(range(0, pil_img.height, d),
29
  range(0, pil_img.width, d))]
30
- stack = np.stack([np.array(pil_img.crop(b), float) for b in boxes], axis=-1)
 
 
 
31
  # bands come in order: [green, red, red_edge, nir]
32
  green, red, red_edge, nir = np.split(stack, 4, axis=-1)
33
  # build composite using bands: Red, Red-Edge, Green
 
27
  boxes = [(j, i, j + d, i + d)
28
  for i, j in product(range(0, pil_img.height, d),
29
  range(0, pil_img.width, d))]
30
+ # Convert each quadrant to grayscale so each band is single-channel
31
+ stack = np.stack([
32
+ np.array(pil_img.crop(b).convert('L'), dtype=float)
33
+ for b in boxes], axis=-1)
34
  # bands come in order: [green, red, red_edge, nir]
35
  green, red, red_edge, nir = np.split(stack, 4, axis=-1)
36
  # build composite using bands: Red, Red-Edge, Green