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

Add "no size marker detected" fatal error message to pcv.report_size_marker ? #1638

Open
HaleySchuhl opened this issue Dec 2, 2024 · 0 comments
Labels
enhancement Enhancements to existing features

Comments

@HaleySchuhl
Copy link
Contributor

Is your feature request related to a problem? Please describe.
We generally recommend that color cards be utilized as size markers for scaling pixel measurements, but report size marker is still an option. It's a helpful wrapper for cases where someone doesn't have a color card, which is true of microscopy images for example. If no size marker object is detected under the current parameters, a rather unhelpful error message is triggered in the middle of the function.

Describe the solution you'd like
I propose we detect the lack of marker_contour or roi_mask upstream of this step in the function, and give an informative error message. Also maybe plot marker_bin overlaid on the input image as a debug to help adjust threshold up or down.

Describe alternatives you've considered
Warning message and add "size marker found" observation/return? Continues on with analysis workflow to extract data but those datapoints are unscalable later on and could get filtered out.

Additional context

----> 5 image = pcv.report_size_marker_area(img=img, roi=roi, marker='detect', 
      6                                     objcolor='light', thresh_channel='s', 
      7                                     thresh=120)

File [~/Documents/GitHub/plantcv/build/__editable__.plantcv-3.6.dev68](http://localhost:8889/lab/tree/Documents/Projects/roi/~/Documents/GitHub/plantcv/build/__editable__.plantcv-3.6.dev68)+g9e5e7b8c-py3-none-any[/plantcv/plantcv/report_size_marker_area.py:101](http://localhost:8889/plantcv/plantcv/report_size_marker_area.py#line=100), in report_size_marker_area(img, roi, marker, objcolor, thresh_channel, thresh, label)

     98 marker_area = m['m00']
    100 # Fit a bounding ellipse to the marker
--> 101 _, axes, _ = cv2.fitEllipse(marker_contour)
    102 major_axis = np.argmax(axes)
    103 minor_axis = 1 - major_axis

error: OpenCV(4.10.0) [/Users/runner/miniforge3/conda-bld/libopencv_1717728554055/work/modules/imgproc/src/shapedescr.cpp:355](http://localhost:8889/Users/runner/miniforge3/conda-bld/libopencv_1717728554055/work/modules/imgproc/src/shapedescr.cpp#line=354): error: (-215:Assertion failed) n >= 0 && (depth == CV_32F || depth == CV_32S) in function 'fitEllipseNoDirect'

@HaleySchuhl HaleySchuhl added the enhancement Enhancements to existing features label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancements to existing features
Projects
None yet
Development

No branches or pull requests

1 participant