Skip to content

Commit

Permalink
Merge pull request #17 from AgPipeline/develop
Browse files Browse the repository at this point in the history
Merging develop to master - no review
  • Loading branch information
Chris-Schnaufer authored Oct 15, 2020
2 parents fb944b9 + 384cf1e commit f40710e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker_test_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ BEGIN {
FPAT = "([^,]+)|(\"[^\"]+\")"
}
{
if ($1 != "germplasmName") { # Skipping the header line
printf("(%s %s %s %s %s %s %s %s %s %s %s)\n", $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19)
if ($1 != "species") { # Skipping the header line
printf("(%s %s %s %s %s %s %s %s %s %s %s)\n", $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)
}
}
END {
Expand Down
53 changes: 34 additions & 19 deletions algorithm_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,22 @@ def percent_green(pxarray: np.ndarray) -> float:
Returns the percentage of an image that is green, which can be used
to identify plant cover
"""
# redness value
red = np.sum(pxarray[:, :, 0])

# greenness value
green = np.sum(pxarray[:, :, 1])

# blueness value
blue = np.sum(pxarray[:, :, 2])
if pxarray.shape[2] < 4:
# Get redness, greenness, and blueness values
red = np.sum(pxarray[:, :, 0])
green = np.sum(pxarray[:, :, 1])
blue = np.sum(pxarray[:, :, 2])
else:
# Handle Alpha channel masking
# Get redness, greenness, and blueness values
alpha_mask = np.where(pxarray[:, :, 3] == 0, 1, 0) # Convert alpha channel to numpy.ma acceptable format
channel_masked = np.ma.array(pxarray[:, :, 0], mask=alpha_mask)
red = np.ma.sum(channel_masked)
channel_masked = np.ma.array(pxarray[:, :, 1], mask=alpha_mask)
green = np.ma.sum(channel_masked)
channel_masked = np.ma.array(pxarray[:, :, 2], mask=alpha_mask)
blue = np.ma.sum(channel_masked)
del channel_masked

return round(green / (red + green + blue), 2)

Expand All @@ -156,16 +164,24 @@ def get_red_green_blue_averages(pxarray: np.ndarray) -> tuple:
"""
Returns the average red, green, and blue values in a pxarray object
"""
# redness value
red = np.average(pxarray[:, :, 0])

# greenness value
green = np.average(pxarray[:, :, 1])

# blueness value
blue = np.average(pxarray[:, :, 2])

return (red, green, blue)
if pxarray.shape[2] < 4:
# Get redness, greenness, and blueness values
red = np.average(pxarray[:, :, 0])
green = np.average(pxarray[:, :, 1])
blue = np.average(pxarray[:, :, 2])
else:
# Handle Alpha channel masking
# Get redness, greenness, and blueness values
alpha_mask = np.where(pxarray[:, :, 3] == 0, 1, 0) # Convert alpha channel to numpy.ma acceptable format
channel_masked = np.ma.array(pxarray[:, :, 0], mask=alpha_mask)
red = np.ma.average(channel_masked)
channel_masked = np.ma.array(pxarray[:, :, 1], mask=alpha_mask)
green = np.ma.average(channel_masked)
channel_masked = np.ma.array(pxarray[:, :, 2], mask=alpha_mask)
blue = np.ma.average(channel_masked)
del channel_masked

return red, green, blue


def calculate(pxarray: np.ndarray) -> list:
Expand All @@ -175,7 +191,6 @@ def calculate(pxarray: np.ndarray) -> list:
Return:
Returns a list of the calculated values from the
"""

return_list = [excess_greenness_index(pxarray), green_leaf_index(pxarray), cive(pxarray),
normalized_difference_index(pxarray), excess_red(pxarray), exgr(pxarray),
combined_indices_1(pxarray), combined_indices_2(pxarray), vegetative_index(pxarray),
Expand Down
2 changes: 1 addition & 1 deletion test_data/experiment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pipeline:
studyName: 'S7_20181011'
season: 'S7_20181011'
germplasmName: Sorghum bicolor
species: Sorghum bicolor
collectingSite: Maricopa
observationTimeStamp: '2018-10-11T13:01:02-08:00'

0 comments on commit f40710e

Please sign in to comment.