DIY Photometer for EBC measurement

The forum for discussing all kinds of brewing paraphernalia.
unclepumble

Re: DIY Photometer for EBC measurement

Post by unclepumble » Tue Jun 14, 2011 6:16 pm

Blackaddler wrote:
andybiochem wrote:What I can do is see how the 'photometer' responds to known EBC beers
Nice work.

It could be a problem finding "known" EBC beers, though. I have a feeling that most brewers just guesstimate a calculation based on the maltster's expected figures [which can also vary, somewhat].
The Micros might do it like that, the big boys certainly don't guess, all the beers have tolerances that they have to adhere to, or they are not released to market. colour, ABV, Carbonation, Micro, VDK, PG Etc etc etc, all measured on very expensive equipment, in large professional labs frequently.

UP

User avatar
Blackaddler
Under the Table
Posts: 1326
Joined: Thu Jun 11, 2009 9:28 am
Location: Addlestein, Surrey

Re: DIY Photometer for EBC measurement

Post by Blackaddler » Tue Jun 14, 2011 6:35 pm

I should have thought of that. I've visited too many micros in recent years...
Image

andybiochem

Re: DIY Photometer for EBC measurement

Post by andybiochem » Wed Jun 15, 2011 11:47 am

unclepumble wrote: The Micros might do it like that, the big boys certainly don't guess, all the beers have tolerances that they have to adhere to, or they are not released to market. colour, ABV, Carbonation, Micro, VDK, PG Etc etc etc, all measured on very expensive equipment, in large professional labs frequently.
Yeah, I'm thinking Guinness, John Smiths, Old Speckled Hen etc. I'll have to hunt down some data for these sort of beers.


A quick update...

Whilst the cam-in-a-box seems to work ok (ish), it's a struggle to build the thing and probably not worth the effort in the long run. Although I intend to finish up the software at some point, what I've decided might be a much simpler route is (as GW described) to photograph the standards (the diluted beer samples) along side your 'unknown' beer sample. This should be much more robust, as there is no switching of sample vials, and since everything will appear on the same photograph, all samples will be subject to the same light conditions etc.

So I've knocked up a quick program to grab colour data from a photo, rather than the webcam.

Example:
1) Here's a photo I took of my diluted London Stout samples
The 3rd sample from the left is the 'unknown' target beer.
Image


2) Here is the photo loaded into the software
Image

The software works by the user clicking on each sample, and then on the button it represents. When clicking on the sample, a box of pixels is averaged to get the colour of the beer. The idividual channels (RGB) are then used to build up a calibration curve (the graph: x-axis is % dilution, y-axis is colour intensity from 0 - 255). These three curves are then averaged as well to create a single curve from all 3 channels (the black curve in the graph). This is then used to predict/extrapolate what EBC the Target beer will be.

In actual fact the target beer here is just a 20% dilution, which it has picked up as 22% and an EBC of 11 (the button below the 100% button, I really must label my software properly :roll: ). Given that beer does follow Beer's Law, then the actual EBC of a 20% dilution of a 50 EBC stout is...10. So I'm 1 off.


Now, looking at the graph produced, the blue channel is pretty much useless at dilutions between 30 and 100 %. :x But that red channel looks pretty good....

Here are the channels isolated:
RED
Image


GREEN
Image


BLUE
Image


Straight away you can see how all the samples look the same in the blue channel. In the red channel, there is a much better contrast between each dilution.

So, loading just the red channel back into the software...

Image


Now the software picks up the 20% dilution perfectly as 10 EBC. In fact, the program picks up the correct dilution for ALL of the samples, with perhaps +/- 1% every now and again.

At this point, this might all seem a bit circular...I tell it what 50% looks like, and then when I click on the 50% sample it sure enough says "50%". But the point here is that a curve is being produced which will allow the estimation of any dilution/EBC from 0 to 50. It just so happens that I'm limited to my standards at the moment. It's also pretty accurate, at least for this series of stout dilutions. Next step, as I said, is to build up a profile for different beers / styles to see what difference it makes.

Hurry up weekend!

WishboneBrewery
CBA Prizewinner 2010
Posts: 7874
Joined: Sun Nov 30, 2008 9:06 pm
Location: Keighley, West Yorkshire
Contact:

Re: DIY Photometer for EBC measurement

Post by WishboneBrewery » Wed Jun 15, 2011 5:32 pm

So is this in addition to or replacing the savaged Webcam?

Fecking cool stuff!

andybiochem

Re: DIY Photometer for EBC measurement

Post by andybiochem » Wed Jun 15, 2011 6:01 pm

pdtnc wrote:So is this in addition to or replacing the savaged Webcam?
This replaces the webcam altogether. All you'll need to 'measure' your EBC is a photo of your unknown sample along side a range of dilutions of a known EBC beer...and my software.

For these tests I've used my DSLR camera, so not sure if photos from mobile phones etc would be suitable...I'll run some more tests when I get a chance.

Cheers!

WishboneBrewery
CBA Prizewinner 2010
Posts: 7874
Joined: Sun Nov 30, 2008 9:06 pm
Location: Keighley, West Yorkshire
Contact:

Re: DIY Photometer for EBC measurement

Post by WishboneBrewery » Wed Jun 15, 2011 8:03 pm

The lighting conditions and white balance of the shot must effect results, unless shot in a dark room with a single light illuminating the subject, shoot a Grey-card and tweak the RAW files to it. (might not be needed but a warm or cold light might make a difference)

User avatar
basswulf
Piss Artist
Posts: 107
Joined: Tue Jun 14, 2011 9:55 am
Location: Oxford, UK
Contact:

Re: DIY Photometer for EBC measurement

Post by basswulf » Wed Jun 15, 2011 9:10 pm

The lighting conditions will, I imagine make a lot of difference. You might be able to shoot using a consistent neutral background and then calibrate to that. Watch out also for light drop off due to uneven illumination - in the photo sample above, the background is definitely darker on the right hand side of the frame. The original gadget has the advantage of evening all that out but at the cost of requiring more soldering skills than a lot of people (well, me at least) could muster up.

Overall, very impressive though and I suspect that even with a few vagaries creeping in, it will be good enough for most purposes.

Wulf

Dr. Dextrin

Re: DIY Photometer for EBC measurement

Post by Dr. Dextrin » Wed Jun 15, 2011 9:48 pm

You really need to back-light the samples - in front of a translucent screen, say. If you light from the front, the light has to go through the sample twice so dark samples will look relatively darker than they would with a back-light.

andybiochem

Re: DIY Photometer for EBC measurement

Post by andybiochem » Thu Jun 16, 2011 12:46 pm

Some excellent ideas here, I like the idea of backlighting and white balancing....

...however, this approach is a little more robust than you might think. Due to the fact that all beer samples are photographed under the same conditions, and the way that the algorithm estimates the target beer EBC, it would take a pretty huge cock-up to mess this up.

A couple of examples:

Here is a test using a totally screwed up white balance:
Image

- The dodgy WB has supressed the curve somewhat, but even using the average of all 3 colour channels has predicted a 10 EBC sample as 11 EBC. So 1 out.


Here's one using my iPhone (3GS) in less than ideal conditions (low light, from a window to the right). No post-processing, this is straight off the phone.
Image

- It's predictd the 25 EBC sample as 25 EBC... I chose the red channel calibration curve here as the others look too supressed.


Here's one that I'm gonna call my "Jim Beer Special", i.e. poor conditions, blurry, and finger over the lens :lol:
Image

- again, the red channel looks best, and we get an estimation of 26 EBC from a 25 EBC sample.


So perhaps a little more useable than I expected it to be. I would predict the easiest way to mess the photo up would be to shoot without a consisten background, i.e. so you can see stuff through the samples. This will almost definately screw the curve up. It's no hassle to prop up a bit of paper behind though.


I'd just like to add a thought at this point regarding what it is we're actually measuring here. It's a bit of a pedantic point perhaps, but I think it's pretty important. Since EBC is defined as the "absorbance at 430nm through 1cm of sample multiplied by 25", we are most definately not measuring EBC with this tool. I'm not using a photometer, definately not isolating 430nm light, and not calculating absorbance in a standard manner, and I think it's a bit disingenuous of me to throw around the term 'EBC' when in fact this approach is miles away from the defined technique. I've been using the term 'EBC' here because it's an easy way to discuss the topic, but really I should be saying 'estimated EBC' or 'derived EBC'. I just wanted it to be known that I'm aware of the limitations something like this can have :lol:

Anyhow, this software is almost ready for release into the wild (for free of course). It still needs some tidying up, and error handling. I expect I'll put up a link tomorrow for you guys to try it out...also, BREW DAY tomorrow for me!! and with all this talk of stouts, I think I'll brew something resembling coal =P~

Thanks for all your input on this guys!

dave-o

Re: DIY Photometer for EBC measurement

Post by dave-o » Thu Jun 16, 2011 1:05 pm

What would be great is if we didn't have to have those samples at all.

A possible way of doing this would be for the user to select an area of the paper background to sample. The program could then adjust for light differences between the background your program is calibrated for, and the specified background of the inputted picture.

There would be slightly more fudge factor here, but speaking as a brewer with little time or precision equipment, i'd be far more likely to use it if all i needed to do was take a pic of my beer in front of a piece of paper!

Perhaps you could see whether this gives realistic results?

*EDIT* And i forgot to say: great work! really interesting.
Last edited by dave-o on Thu Jun 16, 2011 1:20 pm, edited 1 time in total.

andybiochem

Re: DIY Photometer for EBC measurement

Post by andybiochem » Thu Jun 16, 2011 1:15 pm

It's a good suggestion, I'll have a think how it could be done.

mshergold

Re: DIY Photometer for EBC measurement

Post by mshergold » Thu Jun 16, 2011 1:49 pm

My head hurts!

Shippo

Re: DIY Photometer for EBC measurement

Post by Shippo » Thu Jun 16, 2011 6:32 pm

Maybe you could create a testcard to photograph alongside the sample rather than having to have a set of solutions of known EBCs each time. Presumably you'd have to calibrate the card against the sample set to allow for printing differences etc, but it would then be easier to keep and reuse than the actual samples...

You could easily get very carried away developing this, but then again it looks like you already have :D Top work though, brilliant stuff!

User avatar
Horatio
Under the Table
Posts: 1214
Joined: Mon Nov 30, 2009 3:07 pm
Location: Stanford le Hope, Essex. UK

Re: DIY Photometer for EBC measurement

Post by Horatio » Thu Jun 16, 2011 8:07 pm

Love it! People like you make the world a greater place. :D
If I had all the money I'd spent on brewing... I'd spend it on brewing!

Dr. Dextrin

Re: DIY Photometer for EBC measurement

Post by Dr. Dextrin » Thu Jun 16, 2011 8:30 pm

When you've finished this, could you change Beer Engine so you just show it a picture of a pint and it prints out the recipe?

Ta. :lol:

Post Reply