Skip to content

Commit

Permalink
np.where for mask layer if available
Browse files Browse the repository at this point in the history
  • Loading branch information
HaleySchuhl committed Sep 3, 2024
1 parent ff9db9a commit 753e8b4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion plantcv/geospatial/read_geotif.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def read_geotif(filename, bands="R,G,B", cropto=None):
# Check if user input matches image dimension in z direction
if depth != len(bands):
warn(f"{depth} bands found in the image data but {filename} was provided with {bands}")
print("maximum pixel value: " + str(np.max(img_data)))
print("minimum pixel value: " + str(np.min(img_data)))
# Mask negative background values
img_data[img_data < 0.] = 0
if np.sum(img_data) == 0:
Expand All @@ -128,7 +130,13 @@ def read_geotif(filename, bands="R,G,B", cropto=None):
fatal_error(f"your specified mask is not binary")
else:
# apply mask
# img_data[mask_layer == 0] = 0
#img_data = apply_mask(img=img_data, mask=mask_layer, mask_color="black")
#img_data = np.ma.array(img_data, mask=mask_layer)
img_data = np.where(mask_layer == 0, 0, img_data)
#img_data[mask_layer > 1] = 0
print("Post masking")
print("maximum pixel value: " + str(np.max(img_data)))
print("minimum pixel value: " + str(np.min(img_data)))
# Find which bands to use for red, green, and blue bands of the pseudo_rgb image
id_red = _find_closest_unsorted(array=np.array([float(i) for i in wl_keys]), target=630)
id_green = _find_closest_unsorted(array=np.array([float(i) for i in wl_keys]), target=540)
Expand Down

0 comments on commit 753e8b4

Please sign in to comment.