Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
# Get options
args = options()
# Read image
img, path, filename = pcv.readimage(args.image)
#roi = cv2.imread(args.roi)
# Pipeline step
device = 0
# Convert RGB to HSV and extract the Saturation channel
device, s = pcv.rgb2gray_hsv(img, 's', device, args.debug)
# Threshold the Saturation image
device, s_thresh = pcv.binary_threshold(s, 36, 255, 'light', device, args.debug)
# Median Filter
device, s_mblur = pcv.median_blur(s_thresh, 0, device, args.debug)
device, s_cnt = pcv.median_blur(s_thresh, 0, device, args.debug)
# Fill small objects
#device, s_fill = pcv.fill(s_mblur, s_cnt, 0, device, args.debug)
# Convert RGB to LAB and extract the Blue channel
device, b = pcv.rgb2gray_lab(img, 'b', device, args.debug)
# Threshold the blue image
device, b_thresh = pcv.binary_threshold(b, 137, 255, 'light', device, args.debug)
def main():
# Get options
args = options()
# Read image
img, path, filename = pcv.readimage(args.image)
#roi = cv2.imread(args.roi)
# Pipeline step
device = 0
# Convert RGB to HSV and extract the Saturation channel
device, s = pcv.rgb2gray_hsv(img, 's', device, args.debug)
# Threshold the Saturation image
device, s_thresh = pcv.binary_threshold(s, 36, 255, 'light', device, args.debug)
# Median Filter
device, s_mblur = pcv.median_blur(s_thresh, 0, device, args.debug)
device, s_cnt = pcv.median_blur(s_thresh, 0, device, args.debug)
# Fill small objects
#device, s_fill = pcv.fill(s_mblur, s_cnt, 0, device, args.debug)
# Convert RGB to LAB and extract the Blue channel
device, b = pcv.rgb2gray_lab(img, 'b', device, args.debug)
# Threshold the blue image
device, b_thresh = pcv.binary_threshold(b, 137, 255, 'light', device, args.debug)
def main():
# Get options
args = options()
# Read image
img, path, filename = pcv.readimage(args.image)
#roi = cv2.imread(args.roi)
# Pipeline step
device = 0
# Convert RGB to HSV and extract the Saturation channel
device, s = pcv.rgb2gray_hsv(img, 's', device, args.debug)
# Threshold the Saturation image
device, s_thresh = pcv.binary_threshold(s, 36, 255, 'light', device, args.debug)
# Median Filter
device, s_mblur = pcv.median_blur(s_thresh, 0, device, args.debug)
device, s_cnt = pcv.median_blur(s_thresh, 0, device, args.debug)
# Fill small objects
#device, s_fill = pcv.fill(s_mblur, s_cnt, 0, device, args.debug)
# Convert RGB to LAB and extract the Blue channel
device, b = pcv.rgb2gray_lab(img, 'b', device, args.debug)
# Threshold the blue image
device, b_thresh = pcv.binary_threshold(b, 137, 255, 'light', device, args.debug)
# Threshold the blue image
device, b_thresh = pcv.binary_threshold(b, 138, 255, 'light', device, args.debug)
device, b_cnt = pcv.binary_threshold(b, 138, 255, 'light', device, args.debug)
# Fill small objects
device, b_fill = pcv.fill(b_thresh, b_cnt, 150, device, args.debug)
# Join the thresholded saturation and blue-yellow images
device, bs = pcv.logical_and(s_fill, b_fill, device, args.debug)
# Apply Mask (for vis images, mask_color=white)
device, masked = pcv.apply_mask(img, bs,'white', device, args.debug)
# Mask pesky brass piece
device, brass_mask1 = pcv.rgb2gray_hsv(brass_mask, 'v', device, args.debug)
device, brass_thresh = pcv.binary_threshold(brass_mask1, 0, 255, 'light', device, args.debug)
device, brass_inv=pcv.invert(brass_thresh, device, args.debug)
device, brass_masked = pcv.apply_mask(masked, brass_inv, 'white', device, args.debug)
# Further mask soil and car
device, masked_a = pcv.rgb2gray_lab(brass_masked, 'a', device, args.debug)
device, soil_car1 = pcv.binary_threshold(masked_a, 128, 255, 'dark', device, args.debug)
device, soil_car2 = pcv.binary_threshold(masked_a, 128, 255, 'light', device, args.debug)
device, soil_car=pcv.logical_or(soil_car1, soil_car2,device, args.debug)
device, soil_masked = pcv.apply_mask(brass_masked, soil_car, 'white', device, args.debug)
# Convert RGB to LAB and extract the Green-Magenta and Blue-Yellow channels
device, soil_a = pcv.rgb2gray_lab(soil_masked, 'a', device, args.debug)
device, soil_b = pcv.rgb2gray_lab(soil_masked, 'b', device, args.debug)
# Threshold the green-magenta and blue images
nir_img = An NIR grayscale image.
debug = None, print, or plot. Print = save to file, Plot = print to screen.
:param vis_img: str
:param nir_img: str
:param debug: str
:return:
"""
# Read VIS image
img, path, filename = pcv.readimage(vis_img)
# Pipeline step
device = 0
# Convert RGB to HSV and extract the Saturation channel
device, s = pcv.rgb2gray_hsv(img, 's', device, debug)
# Threshold the Saturation image
device, s_thresh = pcv.binary_threshold(s, 36, 255, 'light', device, debug)
# Median Filter
device, s_mblur = pcv.median_blur(s_thresh, 5, device, debug)
device, s_cnt = pcv.median_blur(s_thresh, 5, device, debug)
# Fill small objects
# device, s_fill = pcv.fill(s_mblur, s_cnt, 0, device, args.debug)
# Convert RGB to LAB and extract the Blue channel
device, b = pcv.rgb2gray_lab(img, 'b', device, debug)
# Threshold the blue image
device, b_thresh = pcv.binary_threshold(b, 137, 255, 'light', device, debug)
def main():
# Get options
args = options()
# Read image
img, path, filename = pcv.readimage(args.image)
# Pipeline step
device = 0
# Convert RGB to HSV and extract the Saturation channel
device, s = pcv.rgb2gray_hsv(img, 's', device, args.debug)
# Threshold the Saturation image
device, s_thresh = pcv.binary_threshold(s, 36, 255, 'light', device, args.debug)
# Median Filter
device, s_mblur = pcv.median_blur(s_thresh, 0, device, args.debug)
device, s_cnt = pcv.median_blur(s_thresh, 0, device, args.debug)
# Fill small objects
#device, s_fill = pcv.fill(s_mblur, s_cnt, 0, device, args.debug)
# Convert RGB to LAB and extract the Blue channel
device, b = pcv.rgb2gray_lab(img, 'b', device, args.debug)
# Threshold the blue image
device, b_thresh = pcv.binary_threshold(b, 137, 255, 'light', device, args.debug)
def main():
# Get options
args = options()
# Read image
img, path, filename = pcv.readimage(args.image)
# Pipeline step
device = 0
# Convert RGB to HSV and extract the Saturation channel
device, s = pcv.rgb2gray_hsv(img, 's', device, args.debug)
# Threshold the Saturation image
device, s_thresh = pcv.binary_threshold(s, 36, 255, 'light', device, args.debug)
# Median Filter
device, s_mblur = pcv.median_blur(s_thresh, 0, device, args.debug)
device, s_cnt = pcv.median_blur(s_thresh, 0, device, args.debug)
# Fill small objects
#device, s_fill = pcv.fill(s_mblur, s_cnt, 0, device, args.debug)
# Convert RGB to LAB and extract the Blue channel
device, b = pcv.rgb2gray_lab(img, 'b', device, args.debug)
# Threshold the blue image
device, b_thresh = pcv.binary_threshold(b, 137, 255, 'light', device, args.debug)
def main():
# Get options
args = options()
# Read image
img, path, filename = pcv.readimage(args.image)
# Pipeline step
device = 0
# Convert RGB to HSV and extract the Saturation channel
device, s = pcv.rgb2gray_hsv(img, 's', device, args.debug)
# Threshold the Saturation image
device, s_thresh = pcv.binary_threshold(s, 36, 255, 'light', device, args.debug)
# Median Filter
device, s_mblur = pcv.median_blur(s_thresh, 0, device, args.debug)
device, s_cnt = pcv.median_blur(s_thresh, 0, device, args.debug)
# Fill small objects
#device, s_fill = pcv.fill(s_mblur, s_cnt, 0, device, args.debug)
# Convert RGB to LAB and extract the Blue channel
device, b = pcv.rgb2gray_lab(img, 'b', device, args.debug)
# Threshold the blue image
device, b_thresh = pcv.binary_threshold(b, 137, 255, 'light', device, args.debug)
:param nir_img: str
:param vis_traits: dict
:param nir_traits: dict
:param traits: dict
:param debug: str
:return:
"""
# Read image
print ("starting processing...")
img, path, filename = pcv.readimage(vis_img)
brass_mask = cv2.imread('masks/mask_brass_tv_z1_L1.png')
device = 0
# Convert RGB to HSV and extract the Saturation channel
device, s = pcv.rgb2gray_hsv(img, 's', device, debug)
# Threshold the Saturation image
device, s_thresh = pcv.binary_threshold(s, 75, 255, 'light', device, debug)
# Median Filter
device, s_mblur = pcv.median_blur(s_thresh, 5, device, debug)
device, s_cnt = pcv.median_blur(s_thresh, 5, device, debug)
# Fill small objects
device, s_fill = pcv.fill(s_mblur, s_cnt, 150, device, debug)
# Convert RGB to LAB and extract the Blue channel
device, b = pcv.rgb2gray_lab(img, 'b', device, debug)
# Threshold the blue image
device, b_thresh = pcv.binary_threshold(b, 138, 255, 'light', device, debug)