Cannabis Bud Area
Baby Steps to Tokenized Cannabis
Detecting multiple bright spots in an image with Python and OpenCV - PyImageSearch
Today's blog post is a followup to a tutorial I did a couple of years ago on finding the brightest spot in an image. My…
In this docker image I have all of the dependencies for both Leaf Area and Bud Area including working copies and works in progress. We’re going to be using the same setup as with the Leaf Area notebook. OpenCV will be used for preprocessing the image and pixel selection by range. Matplotlib is used from rendering images and graphs. We take advantage of skimage.measure.label for taking measurements and label them. We take these components and use OpenCV to find and annotate the contours.
HSV Range Detector
Running GUI applications using Docker for Mac
This is a short guide explaining how to run GUI applications from within Docker on Mac. This uses XQuartz to enable to…
Creating the initial HSV Mask
Preview the mask
We can easily mask the original image with OpenCV’s bitwise_and which takes the original image and the mask and outputs a masked image.
Cannabis Computer Vision
This is a side-by-side view of the HSV colorspace which the computer uses to isolate the buds and the masked preview. We use the numpy.vstack to vertically stack the images. I chose vstack for the gists here and hstack in the notebook, but it really is a matter of developer preference.
Refining the Mask
We can refine the mask using the same binary threshold, erode, and dilate technique used on the Leaf Area. This will clean up the specs of frost leave from the actual Bud Area.
Before and After Cleaning Up the Contours
You can see the vstack comparing the contours pre and post cleanup.
Enhance Mask with Labeled Components
Using skimage.measure.label we are further filtering out noise by ignoring blobs smaller than 100px. This means buds have to be this size or greater to get added to the labeled mask.
Label the Buds
Now we have what we need to label the bud sites on the preview image.
A Full Copy of the Notebook Below
Below is the full copy of the notebook. I also have a docker image tonsoffun/tensorflow-notebook which I’ve simply added OpenCV 3.3 via anaconda. This docker image supports both Bud and Leaf Area Analysis as well. Keep following along as I show you how we can use our OpenCV masks to train a Mask RCNN.