An App to Measure your Coffee Grind Size Distribution

Today I would like to present an OS X application I have been developing for a few months. It turns out writing Python software for coffee is a great way to relax after a day of writing Python software for astrophysics.

When I started being interested in brewing specialty coffee a few years ago, one of the first things that irritated me was our inability to recommend grind sizes for different coffee brewing methods, or to compare the quality of different grinders in an objective way. Sure, some laboratories have laser diffraction equipment that can measure the size of all particles coming out of a grinder, but rare are the coffee geeks that have access to these multi-hundred thousands of dollars kinds of equipment.

At first, I decided to take pictures of my coffee grounds spread on a white sheet, and to use an old piece of software called ImageJ, developed by the National Institutes of Health mainly to analyze microscope images, to obtain a distribution of the sizes of my coffee grounds. This worked decently well, and allowed me to start comparing different grinders. Then Scott Rao made me realize that a stand-alone application that doesn’t need a complicated installation and that is dedicated to coffee would be of interest to many people in the coffee industry. Probably just the 10% geekiest of them, but that’s cool.

I’m hoping that this application will help us understand the effects of particle size distributions on the taste of coffee. I don’t think the industry really kept us in the loop with all the laser diffraction experiments, so hopefully we can help ourselves as a community.

If you are interested in measuring the particle size distribution of your grinder, then this app is for you ‒ and it’s free. I placed it as “open source” on GitHub, so if you are a developer, you are welcome to send me suggestions in the form of push requests (the developers will know what that means).

If you would like to get started, I suggest you read this quick installation guide, which will explain how to download the app and run it even though I am not a registered Apple Developer. Then, you can choose to either read this quick summary that will get you running with the basics, or this very detailed and wordy user manual that will guide you through all the detailed options the application offers you.

I would like to show you an example of what can be done with the software. Below, I am comparing the particle size distribution of the Baratza Forté grinder, which uses 54 mm flat steel burrs, with that of the Lido 3 hand grinder, which uses 48 mm conical steel burrs. I set both grinders in a way that produces a similar peak of average-sized particles with diameters around 1 mm, but as you can see, the particle size distributions are very different ! The Forté generates way less fines (with diameters below 0.5 mm) and slightly less boulders (with diameters of approximately 2 mm), which is indicative of a better quality grinder.

An example of figure that can be generated with the coffee grind size software. Each red bar corresponds to one kind of particle diameter generated by the Lido 3 grinder (smallest particles correspond to the leftmost bar, largest ones correspond to the rightmost bar), and their heights correspond to the total contribution of these kinds of particles, by mass. As you can see, the particles that contribute to the largest amount of mass have sizes just above 1 mm. The red circle shows the average particle diameter for the Lido 3, and the horizontal bars show the “characteristic width” of the distribution – this corresponds to the width that covers approximately 68% of all the distribution. Similarly, the blue line and the blue circle describe the distribution of the Forté grinder.

For now, the app is only intended to be used on OS X computers. But if you are running any other kind of system and know your way around Python, you can always download it directly from GitHub and run it with your own installation of Python 3.

This is an example of how to use the coffee grind size application.

I would like to thank Scott Rao for his excitement when I shared this project idea with him, and for beta testing the software. I would also like to thank Alex Levitt, Mitch Hale, Caleb Fischer, Francisco Quijano and Victor Malherbe for beta testing the software.

19 Replies to “An App to Measure your Coffee Grind Size Distribution”

  1. This is very, very cool. It is quite similar to the “portafilter basket hole size measuring” approach we took (to check portafilter basket hole quality).

    I use a “light table” to take a photo of a basket, a reference size (basket inner diameter, usually) and then do a photographic hole size analysis. Here’s a photo of the result:

    John Weiss wrote it for me, and I’m happy to share the source with you. C code that runs on Linux, so should compile fine on OSX.

    One tip: using a phone with an all-white image works as a very low cost light table for photographing baskets. I think that might work well as a cheap light table for photographing coffee grounds too.

    – John from Decent Espresso


    1. Thank you John ! I made an algorithm that is dedicated to being able to calculate the surface of highly non spherical particles, and at the same time separate two particles that are touching to mimick a large one. The last part is done by selecting a reference pixel (darkest one) and see if all paths from that reference toward a given region of the particle always has to pass through some bright (i.e. edge) pixels. If that’s the case then the region in question is dropped. The rest should be very similar to portafilter holes yes ! If you invert your image colors and know the pixel scale you may be able to use this software too 😛


  2. Hi Jonathan,

    This looks very interesting. Can I ask whether results have been correlated to other means of grind analysis, can it tell us particle sizes @ +/-1stddev?

    Is it yet known what the threshold is for a stddev so wide that effects on brew are significantly poorer?

    Best regards, Mark.

    Liked by 1 person

    1. Hi Mark, thank you. I have not correlated these results with other methods, but it would be an interesting experiment. Some things to note: 1) sieving measures the mass vs which particles can pass through a circular hole, and there’s no guarantee all particles have passed unless you shake for a very long time. My software is a direct measurement of projected surface (on the sheet) as long as the data collection is done properly (it’s explained in the full user manual). Other quantities like volume and mass have to make some assumptions for working, e.g. assuming a 3D surface to projected surface constant for all particles, or assuming that the particles lay flat so that you see their largest axis for calculating volume (these assumptions I make are all detailed in the full manual too). I’m confident that the projected 2D surface could actually be used to calibrate other methods if the software is used correctly, because you can visually inspect the particle detection with the “outline images”. This is not true of particles volume or mass.

      The next version will include error bars based on small-number statistics (Poisson errors) because this is the #1 limitation of this software. It will also include the ability to merge many images to get smaller errors.

      As far as scatter vs taste, this is a very complex question. Immersion will be very different than percolation for example, as flow depends on the amount of fines. This software is also not made for detecting particles smaller than one pixel, so you’d need to take macro pictures with fines in a separate sample collection if you want to go down to very small sizes, and even then an iPhone camera won’t allow you to resolve the micron-sized dust. Plus, we would need to define “significantly poorer” in a taste perception sense, which isn’t easy. I can already say that the difference between Lido 3 and Forté in a V60 cup quality is quite stark, but I’m already using subjective language.


  3. “I made an algorithm that is dedicated to being able to calculate the surface of highly non-spherical particles, and at the same time separate two particles that are touching to mimic a large one”

    Oh ah, that’s pretty fancy, and you’re right, that’s different from our basket analysis software, which measures overall light coming through each hole, and assumes circularity.

    Much has been speculated about coffee particle shape and extraction efficiency.
    Do you think your software could be extended to give some insight in that direction?

    In particular, I’d love to have an approximate measure of *surface area* which might be calcated by looking at how round the particles are.

    As it sounds like you’re almost tracing the edges of each particle, this might be possible…


    Liked by 1 person

    1. Oh yeah sure, the software already measures *projected* surface area. It does not assume circularity in this particular measurement because it just delimitates the non circular contour and counts the number of pixels included. The software already measures the (projected) circularity of all particles too, by calculating the ratio of the projected particle area to the area of the smallest circle that encompasses the full particle. The circularity of each particle is output in a CSV file when you choose “save data”, but currently the software doesn’t do anything else with it. It would be very easy to add an option for displaying a histogram of circularities, or even scatter plots of circularity vs surface.


      1. “It would be very easy to add an option for displaying a histogram of circularities, or even scatter plots of circularity vs surface.”

        Super interesting. You’re giving me ideas on how I might integrate your python code into my Decent Espresso app (also open source and cross-platform

        For example, as Hm Digital’s refractometers are bluetooth, I’ve looked at automating data collection from each shot, into the rest of an espresso shot’s history. Particle size and shape would be also interesting.

        I’ve worked with the Smart Espresso Profiler (from Hungary) to develop an open standard on “espresso shot description” and it has metadata capability, where particle size info would sit nicely. Both Decent and SEP are supporting it, and possibly some other companies too.


        Liked by 1 person

      2. Awesome. I’d be happy to help with it. It is requiring a lot more of the user to measure their particles on each shot, but someone wanting to experiment with this might want to do it, and being able to log it into the Decent would make sense


  4. Very interseting, thank you for your work and sharing.
    I find it hard, to isolate small from big particles. When I use a cheap USB microscope, i see the fines (e.g. 50µm diameter) clinging to the lager particles (e.g. 500µm diameter). I would appreciate methods to isolate these.

    0,1mm² area is about 200µm diameter, so I think that is the resolution you get in your example. But could be higher. fotographing a smaller sheet of paper.


    1. Thanks Stefan. Yes, I’m aware of this phenomenon where fines stick to boulders. I’m pretty sure that for most filter-type grinds, my software will not be able to see these types of ~50 micron fines anyway, unless a crazy resolution camera is used. Otherwise they will be sub-pixel, so my software won’t be able to really tell you how many fines you have. But this will definitely be a potential problem when analyzing finer distributions like espresso, and it’s also a problem for sifting. I don’t have a solution to un-stick them right now.


  5. Thanks for the insight and contribution and looking forward to learn more with the Andriod studio and the enumelator software but my question is psd is directly affected by the temperature 🤒 of the burrs ,Does this affect the sensory result for the lido and fonte


    1. That’s a good question; I don’t think it is affected by burr temperature, but I could be wrong. Maybe the burrs could expand when heated and the grind size could become finer. This could definitely be tested with my software 😛

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s