33import os
44import cv2
55import numpy as np
6- from plantcv .plantcv import print_image
7- from plantcv .plantcv import plot_image
6+ from plantcv .plantcv ._debug import _debug
87from plantcv .plantcv import params
98from plantcv .plantcv import outputs
109
1110
1211def analyze_bound_vertical (img , obj , mask , line_position , label = "default" ):
13- """User-input boundary line tool
12+ """
13+ User-input boundary line tool
1414
1515 Inputs:
1616 img = RGB or grayscale image data for plotting
1717 obj = single or grouped contour object
1818 mask = Binary mask made from selected contours
19- shape_header = pass shape header data to function
20- shape_data = pass shape data so that analyze_bound data can be appended to it
2119 line_position = position of boundary line (a value of 0 would draw the line through the left side of the image)
2220 label = optional label parameter, modifies the variable name of observations recorded
2321
@@ -92,7 +90,7 @@ def analyze_bound_vertical(img, obj, mask, line_position, label="default"):
9290 cv2 .line (ori_img , point3 , point4 , (255 , 0 , 255 ), params .line_thickness )
9391 cv2 .line (wback , point3 , point4 , (255 , 0 , 255 ), params .line_thickness )
9492 m = cv2 .moments (mask , binaryImage = True )
95- cmx , cmy = (m ['m10' ] / m ['m00' ], m ['m01' ] / m ['m00' ])
93+ _ , cmy = (m ['m10' ] / m ['m00' ], m ['m01' ] / m ['m00' ])
9694 if x_coor - x <= 0 :
9795 cv2 .line (ori_img , (x , int (cmy )), (x + width , int (cmy )), (0 , 255 , 0 ), params .line_thickness )
9896 cv2 .line (wback , (x , int (cmy )), (x + width , int (cmy )), (0 , 255 , 0 ), params .line_thickness )
@@ -121,7 +119,7 @@ def analyze_bound_vertical(img, obj, mask, line_position, label="default"):
121119 cv2 .line (ori_img , point3 , point4 , (255 , 0 , 255 ), params .line_thickness )
122120 cv2 .line (wback , point3 , point4 , (255 , 0 , 255 ), params .line_thickness )
123121 m = cv2 .moments (mask , binaryImage = True )
124- cmx , cmy = (m ['m10' ] / m ['m00' ], m ['m01' ] / m ['m00' ])
122+ _ , cmy = (m ['m10' ] / m ['m00' ], m ['m01' ] / m ['m00' ])
125123 if x_coor - x <= 0 :
126124 cv2 .line (ori_img , (x , int (cmy )), (x + width , int (cmy )), (0 , 255 , 0 ), params .line_thickness )
127125 cv2 .line (wback , (x , int (cmy )), (x + width , int (cmy )), (0 , 255 , 0 ), params .line_thickness )
@@ -139,12 +137,10 @@ def analyze_bound_vertical(img, obj, mask, line_position, label="default"):
139137 params .line_thickness )
140138 cv2 .line (wback , (x_coor + 2 , int (cmy )), (x_coor - width_right_bound , int (cmy )), (0 , 255 , 0 ),
141139 params .line_thickness )
142- if params .debug == 'print' :
143- print_image (wback , os .path .join (params .debug_outdir , str (params .device ) + '_boundary_on_white.png' ))
144- print_image (ori_img , os .path .join (params .debug_outdir , str (params .device ) + '_boundary_on_img.png' ))
145- if params .debug == 'plot' :
146- plot_image (wback )
147- plot_image (ori_img )
140+ _debug (visual = wback ,
141+ filename = os .path .join (params .debug_outdir , str (params .device ) + '_boundary_on_white.png' ))
142+ _debug (visual = ori_img ,
143+ filename = os .path .join (params .debug_outdir , str (params .device ) + '_boundary_on_img.png' ))
148144
149145 outputs .add_observation (sample = label , variable = 'vertical_reference_position' , trait = 'vertical reference position' ,
150146 method = 'plantcv.plantcv.analyze_bound_vertical' , scale = 'none' , datatype = int ,
0 commit comments