Coffee Data Science
To better measure the difference between the top and bottom of each hole
Cameras have greatly advanced over the years allowing people to take high quality images. While this can be useful for computer vision applications, often simple changes in design of experiment can greatly improve the quality of these images for specific applications. Enter coffee!
For a few years, I have been applying my image processing skills to image espresso filter baskets. Two years ago, I looked at trying to image the top and bottom to measure per hole shapes. However, this investigation halted when I had some trouble aligning the images automatically. Recently, I have been at it again, but I used manual alignment to improve the process.
While collecting some data, I realized my imaging setup could also be better, so let’s discuss them here.
Imaging espresso baskets is challenging for a few reasons:
- Metal baskets and reflectivity
- The holes are tiny
- Camera lens have curves
I have worked on adjusting for many of these things through data collection SOP and post-processing.
I use a few standardized tools:
- A tablet screen to illuminate the basket holes
- A dark room to isolate other light sources
- Lower exposure to handle reflections of the tablet screen off of the basket back to the camera.
I have a semi-automated process to make processing easier:
- Label basket using a blue circle
- Manually threshold images
- Automatically remove non-holes
- Readjust any ellipse shaped hole to a circle shape.
- Adjust illumination across the filter
First, the amount of light for the measurement of the top of the filter should match the measurement from the bottom.
So I made a collar using 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 it is flipped over.
Then I also made an adjustment for lighting. The full screen is needed to calibrate the image (# of pixels per millimeter), but any lighting not underneath the filter reflects off of the camera (my phone camera) back onto the filter.
To eliminate this, I used the full screen brightness for calibration, and I take another image with a white circle in the middle. This eliminates the reflection problem.
But then I need calibration! To make sure the images are aligned given that the phone might shift (even in a stand), I manually align the images in the app Procreate. I thought this would be more difficult, but it is very straight-forward with layers and 50% transparency. I also found fun things like how symmetric VST filter baskets are.
I use the calibration image to align both the top and bottom images so that everything is calibrated to the same scale. This involves linear resizing and object rotation until the holes are best or most aligned. I have to mirror the bottom image to make sure the holes are correctly aligned with the top image.
Then I run these images through my algorithm. Below are the top and bottom images of the Wafo Classic in false color to depict hole size. There is a splotch of blue in the image of the top (on the left), and this is not due to some other issue. It is a persistent feature in multiple captures.
These distributions can be used to better understand a filter basket.