Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROI Autogrid does not work with germination studies #1419

Open
Stylopidae1793 opened this issue Jan 5, 2024 · 2 comments
Open

ROI Autogrid does not work with germination studies #1419

Stylopidae1793 opened this issue Jan 5, 2024 · 2 comments

Comments

@Stylopidae1793
Copy link
Contributor

The ROI autogrid function throws errors at early timepoints in germination studies due to trays which do not have plants in them.

@nfahlgren
Copy link
Member

auto_grid relies on empirical data to set the grid, so if there are no plants there is no way to set the grid with this method

@HaleySchuhl
Copy link
Contributor

Other possible solutions?

  • Canny edge detect the tray itself and be able to define grid of cells based on tray location
  • tape markers on corners (to help determine corners of the tray or actually marking rows & columns) and then be able to define grid
  • same idea but QR codes?

My thought to make a mask of the cells using the soil does not seem promising. Understandably, the pixel values of wet vs dry soil differ in basically all grayscale colorspaces and the tray design itself is prone to connectivity of cells, and I think this connectivity plus the extra noise is causing auto_grid to fail.
image

---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
Cell In[57], line 8
      6 sub_mask = pcv.image_subtract(gray_img1=thresh, gray_img2=roi_mask)
      7 filled = pcv.fill_holes(sub_mask)
----> 8 rois = pcv.roi.auto_grid(mask=filled, nrows=6, ncols=7, radius=100, img=img)

File ~/plantcv/plantcv/plantcv/roi/roi_methods.py:322, in auto_grid(mask, nrows, ncols, radius, img)
    320 if len(np.unique(mask)) != 2:
    321     fatal_error("Input binary mask is not binary!")
--> 322 coord, spacing = _calculate_grid(mask, nrows, ncols)
    323 if img is None:
    324     img = mask

File ~/plantcv/plantcv/plantcv/roi/roi_methods.py:194, in _calculate_grid(mask, nrows, ncols)
    192 for c in contours:
    193     m = cv2.moments(c)
--> 194     cmx, cmy = (float(m['m10'] / m['m00']), float(m['m01'] / m['m00']))
    195     centers.append((cmx, cmy))
    196 # cluster by x and y coordinates to get grid layout

ZeroDivisionError: float division by zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants