Closed jsab101 closed 9 months ago
Hi @jsab101 thanks for opening this issue. I've downloaded the example image and can confirm that it appears to be grayscale image data. I'm wondering if not all images in the dataset are grayscale. Because I'm unable to replicate your error locally when the functions are run separately.
Can you try to add this to your readimage
step and see if that resolves the error in 1/5 of the images?
img, path, filename= pcv.readimage("300060513-66541894-9c9e-4fc9-8344-c3ea2f2e4b79.jpg", mode="gray")
This worked! Thank you!
Feel free to reopen this issue with any further questions. Thanks :D
I cannot successfully threshold a subset of my images. All images have been taken the same way, but my code fails for about 20% of the images.
I started with
thresh = pcv.threshold.binary(gray_img = img, threshold = 200 , object_type="dark") bsa_fill = pcv.fill(bin_img = thresh, size = 24)
and got the error: RuntimeError: Image is not binary (at the pcv.fill step)
I thought that while the images look grayscale to the eye, they may not be so I tried selecting a colorspace to threshold:
cs_plot = pcv.visualize.colorspaces(rgb_img=img, original_img=False)
and I got the error: RuntimeError: Input image is not RGB!
I then tried the otsu autocthreshold method
thresh = pcv.threshold.otsu(gray_img=img, object_type="dark")
And got the error:
error: OpenCV(4.8.1) /Users/runner/miniforge3/conda-bld/libopencv_1698890312282/work/modules/imgproc/src/thresh.cpp:1555: error: (-2:Unspecified error) in function 'double cv::threshold(InputArray, OutputArray, double, double, int)'
I then tried to convert my image to 8-bit greyscale
image = img.astype("uint8")
and got the error (with the otsu threshold): error: OpenCV(4.8.1) /Users/runner/miniforge3/conda-bld/libopencv_1698890312282/work/modules/imgproc/src/thresh.cpp:1555: error: (-2:Unspecified error) in function 'double cv::threshold(InputArray, OutputArray, double, double, int)'
and with the binary threshold:
RuntimeError: Image is not binary (at the pcv.fill step)
Example image -
Expected behavior I expect the image to be thresholded and thus be able to be further processed.
Local environment (please complete the following information):
Additional context Strangely this only occurs for a subset of my images when I am trying to run a multi-plant workflow. All the images I am having trouble with work when processed individually in a jupyter notebook.