Centres of mass and another reason to love Photoshop

With the experimental work on this project pretty much wrapped up I’ve been spending a large amount of time playing with spreadsheets, making frame-by-frame measurements from high-speed video files, and plotting data up as I start to draw together a paper. With hundreds of experiments completed the real task is identifying those which demonstrate the results in the best way, without displaying so much data that the whole thing becomes unmanageable.

Part of this process is deciding which types of results show things best. For example, if I am trying to demonstrate the effect of mass flux (how much material is put into the experiments per second), am I best showing the effect on the speed that the flow moves, or  in how far the flow finally reaches? Should I be plotting mass flux at all, or should I actually be plotting things in terms of the concentration of the flow (which varies as a function of mass flux)? Should I describe the deposit rather than the flow?

Because different types of flow form different shaped deposits one of the ways of describing the deposit is by its centre of mass; how far down the flume is the midpoint of the resting mass? A long flat deposit will have a midpoint much further away then a simple wedge, where much of the material as not travelled far at all. This is a really useful way of describing how mobile the flow must have been which formed the deposit, but it’s a non-trivial thing to measure.

Today, I worked out a solution and I’m going to put it up here in case a) anyone else finds it useful, and b) I forget how I did it.

All you need is a copy of Photoshop. I’m guessing GIMP might do it as well, but it’s a long time since I’ve used it.

So, we start off with an image of a deposit.

Deposit 1Next up we simply mask out the face of the deposit on a new layer.

MaskWith that done, we get to the clever bit. You need a simple black-to-white gradient (there’s one as default in the gradient tool), and apply it over the masked shape.

gradientYou’ll notice that in the Histogram tool it gives us a total pixel count in the shape of 31,125 pixels. The histogram demonstrates how many pixels of each shade are in the image.

Now, you move your cursor across the histogram window, looking for the point which represents the 50th percentile (you could equally do this for any other percentile you’re interested in). Note it also gives you the colour level (in this case 76):

50th percentileThis level represents where on the scale of 0 – 255 levels of grey the midpoint lies. So in our case 50% of the pixels have shades between 0-75, and the other 50% of the pixels have shades between 77-255. It’s also worth remembering that level 0 is black (no brightness) while 255 is white (full brightness).

So now we simply open the info panel, and move our cursor over the image itself to identify whereabouts along it we get level 76 (you might have to ensure the image is in RGB). That’s our mid point. The image below shows a selection which divides the left 50% of deposit from the right 50%. We can verify the result by looking at the pixel count in the histogram window which is showing the number of pixels within the selection in the gradient layer (should be half that we started with – in this case 31125 / 15560 = 2).

Complete2So there we go. We now can use the scale on the background image (checkerboard grid at the bottom is 1cm, the lined grid is 2cm) to identify the centre of mass in the deposit at about 25.5 cm.

Hopefully this may be of use to someone somewhere.

About Pete Rowley

Earth Scientist with a background in volcanology and sedimentology. Enjoys a good rant, beer, and games. Dislikes reality TV, crowds, and unreasonable people.
This entry was posted in Experimental, Science and tagged , , , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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