How to use the plantcv.readimage function in plantcv

To help you get started, we’ve selected a few plantcv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danforthcenter / plantcv / scripts / dev / fluor_z600_L1-brachy.py View on Github external
def main():
  # Get options
  args = options()
  
  # Read image (converting fmax and track to 8 bit just to create a mask, use 16-bit for all the math)
  mask, path, filename = pcv.readimage(args.fmax)
  #mask = cv2.imread(args.fmax)
  track = cv2.imread(args.track)
  
  mask1, mask2, mask3= cv2.split(mask)
  
  # Pipeline step
  device = 0
  
  # Mask pesky track autofluor
  device, track1= pcv.rgb2gray_hsv(track, 'v', device, args.debug)
  device, track_thresh = pcv.binary_threshold(track1, 0, 255, 'light', device, args.debug)
  device, track_inv=pcv.invert(track_thresh, device, args.debug)
  device, track_masked = pcv.apply_mask(mask1, track_inv, 'black', device, args.debug)
  
  # Threshold the Saturation image
  device, fmax_thresh = pcv.binary_threshold(track_masked, 20, 255, 'light', device, args.debug)
github danforthcenter / plantcv / scripts / dev / gehan_brachy / vis-tv / vis_tv_z3500_L2_e82.py View on Github external
def main():
  # Get options
  args = options()
  
  # Read image
  img, path, filename = pcv.readimage(args.image)
  brass_mask = 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, 49, 255, 'light', device, args.debug)
  
  # Median Filter
  device, s_mblur = pcv.median_blur(s_thresh, 5, device, args.debug)
  device, s_cnt = pcv.median_blur(s_thresh, 5, device, args.debug)
  
  # Fill small objects
github danforthcenter / plantcv / scripts / dev / gehan_brachy / vis-nir-sv / vis_nir_sv_z2500_frame0_h2_e82_brachy_drought.py View on Github external
result.write("\n")
  result.write('\t'.join(map(str,boundary_header)))
  result.write("\n")
  result.write('\t'.join(map(str,boundary_data)))
  result.write("\n")
  result.write('\t'.join(map(str,boundary_img1)))
  result.write("\n")
  for row in color_img:
    result.write('\t'.join(map(str,row)))
    result.write("\n")
  result.close()
    
############################# Use VIS image mask for NIR image#########################
  # Find matching NIR image
  device, nirpath=pcv.get_nir(path,filename,device,args.debug)
  nir, path1, filename1=pcv.readimage(nirpath)
  nir2=cv2.imread(nirpath,-1)
  
  # Flip mask
  device, f_mask= pcv.flip(mask,"vertical",device,args.debug)
  
  # Reize mask
  device, nmask = pcv.resize(f_mask, 0.11532,0.11532, device, args.debug)
  
  # position, and crop mask
  device,newmask=pcv.crop_position_mask(nir,nmask,device,57,2,"top","right",args.debug)
  
  # Identify objects
  device, nir_objects,nir_hierarchy = pcv.find_objects(nir, newmask, device, args.debug)
  
  # Object combine kept objects
  device, nir_combined, nir_combinedmask = pcv.object_composition(nir, nir_objects, nir_hierarchy, device, args.debug)
github danforthcenter / plantcv / scripts / dev / gehan_brachy / vis-nir-sv / vis_nir_sv_z3500_frame0_h2_e82_brachy_drought.py View on Github external
result.write("\n")
  result.write('\t'.join(map(str,boundary_header)))
  result.write("\n")
  result.write('\t'.join(map(str,boundary_data)))
  result.write("\n")
  result.write('\t'.join(map(str,boundary_img1)))
  result.write("\n")
  for row in color_img:
    result.write('\t'.join(map(str,row)))
    result.write("\n")
  result.close()
    
############################# Use VIS image mask for NIR image#########################
  # Find matching NIR image
  device, nirpath=pcv.get_nir(path,filename,device,args.debug)
  nir, path1, filename1=pcv.readimage(nirpath)
  nir2=cv2.imread(nirpath,-1)
  
  # Flip mask
  device, f_mask= pcv.flip(mask,"vertical",device,args.debug)
  
  # Reize mask
  device, nmask = pcv.resize(f_mask, 0.1304,0.1304, device, args.debug)
  
  # position, and crop mask
  device,newmask=pcv.crop_position_mask(nir,nmask,device,65,0,"top","left",args.debug)
  
  # Identify objects
  device, nir_objects,nir_hierarchy = pcv.find_objects(nir, newmask, device, args.debug)
  
  # Object combine kept objects
  device, nir_combined, nir_combinedmask = pcv.object_composition(nir, nir_objects, nir_hierarchy, device, args.debug)
github danforthcenter / plantcv / scripts / image_analysis / vis_sv / vis_sv_z500_L1.py View on Github external
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, 5, device, args.debug)
  device, s_cnt = pcv.median_blur(s_thresh, 5, device, args.debug)
  
  # Fill small objects
github danforthcenter / plantcv / scripts / image_analysis / vis_sv / vis_sv_z2500_L1.py View on Github external
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, 5, device, args.debug)
  device, s_cnt = pcv.median_blur(s_thresh, 5, device, args.debug)
  
  # Fill small objects
github danforthcenter / plantcv / scripts / dev / vis_tv_z3500_L2_e82.py View on Github external
def main():
  # Get options
  args = options()
  
  # Read image
  img, path, filename = pcv.readimage(args.image)
  brass_mask = 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, 49, 255, 'light', device, args.debug)
  
  # Median Filter
  device, s_mblur = pcv.median_blur(s_thresh, 5, device, args.debug)
  device, s_cnt = pcv.median_blur(s_thresh, 5, device, args.debug)
  
  # Fill small objects
github danforthcenter / plantcv / scripts / dev / vis_tv_z500_L2.py View on Github external
def main():
  # Get options
  args = options()
  
  # Read image
  img, path, filename = pcv.readimage(args.image)
  brass_mask = 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, 49, 255, 'light', device, args.debug)
  
  # Median Filter
  device, s_mblur = pcv.median_blur(s_thresh, 5, device, args.debug)
  device, s_cnt = pcv.median_blur(s_thresh, 5, device, args.debug)
  
  # Fill small objects
github danforthcenter / plantcv / scripts / dev / gehan_brachy / vis-nir-tv / vis_nir_tv_z2500_h2_e82_brachy_drought.py View on Github external
result.write("\n")
  for row in shape_img:
    result.write('\t'.join(map(str,row)))
    result.write("\n")
  result.write('\t'.join(map(str,color_header)))
  result.write("\n")
  result.write('\t'.join(map(str,color_data)))
  result.write("\n")
  for row in color_img:
    result.write('\t'.join(map(str,row)))
    result.write("\n")
    
############################# Use VIS image mask for NIR image#########################
  # Find matching NIR image
  device, nirpath=pcv.get_nir(path,filename,device,args.debug)
  nir, path1, filename1=pcv.readimage(nirpath)
  nir2=cv2.imread(nirpath,-1)
  
  # Flip mask
  device, f_mask= pcv.flip(mask,"horizontal",device,args.debug)
  
  # Reize mask
  device, nmask = pcv.resize(f_mask, 0.11532,0.11532, device, args.debug)
  
  # position, and crop mask
  device,newmask=pcv.crop_position_mask(nir,nmask,device,22,9,"top","left",args.debug)
  
  # Identify objects
  device, nir_objects,nir_hierarchy = pcv.find_objects(nir, newmask, device, args.debug)
  
  # Object combine kept objects
  device, nir_combined, nir_combinedmask = pcv.object_composition(nir, nir_objects, nir_hierarchy, device, args.debug)
github danforthcenter / plantcv / scripts / dev / gehan_brachy / vis-sv / vis_sv_z1500_frame0_L2_e82.py View on Github external
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)