Coffee Data Science
To better measure the difference between the top and bottom of each hole
Cameras have come a long way over the years, allowing people to take high-quality images. While this can be useful for computer vision applications, often simple changes to the experiment design can greatly improve the quality of these images for specific applications. Enter the coffee!
For a few years I have been applying my image processing skills to picture espresso filter baskets. Two years ago, I tried to get a picture of the top and bottom to measure the shapes of each hole. However, this research came to a halt when I had some trouble aligning the images automatically. I recently did it again, but used manual alignment to improve the process.
While collecting some data, I realized that my imaging settings could be better as well, so let’s discuss them here.
Creating espresso basket images is challenging for several reasons:
- Metal baskets and reflectivity
- the holes are small
- The camera lens has curves
I’ve worked on fine-tuning a lot of these things through SOP data collection and post-processing.
I use some standardized tools:
- A tablet shade to illuminate the holes in the basket.
- A dark room to isolate other light sources.
- Lower the exposure to manage reflections from the tablet screen out of the basket towards the camera.
I have a semi-automated process to make processing easier:
- Label the basket with a blue circle
- Manual thresholding of images
- Automatically remove holes
- Reset any ellipse-shaped hole to a circle shape.
- Adjust lighting through filter
First, the amount of light for the measurement from the top of the filter must match the measurement from the bottom.
So I made a collar out of a paper cup to hold the filter where the top (the inside of the basket) would be at the same height as the bottom of the filter when flipped over.
Then I also made an adjustment for the lighting. The entire screen is needed to calibrate the image (number of pixels per millimeter), but any lighting not below the filter reflects off the camera (my phone’s camera) and back into the filter.
To eliminate this I used full screen brightness for calibration and took another image with a white circle in the middle. This eliminates the reflection problem.
But then I need calibration! To make sure the images align since the phone can move (even on a mount), I manually align the images in the Procreate app. I thought this would be more difficult, but it’s very easy with layers and 50% transparency. I also found funny things like how symmetrical the VST filter baskets are.
I use the calibration image to align the top and bottom images so everything is calibrated to the same scale. This involves linear resizing and rotating objects until the holes are better or more aligned. I have to mirror the bottom image to make sure the holes line up correctly with the top image.
I then run these images through my algorithm. Below are the top and bottom images of the Wafo Classic in false color to represent hole size. There is a blue spot in the image at the top (on the left), and this is not caused by any other problem. It is a persistent feature across multiple captures.
These distributions can be used to better understand a filter basket.