Blog

Correctly naming your photos

I seem to be very minimal in my strategy of organizing my digital photo collection. I have a single folder on my computer called “Pictures,” and subfolders that correspond to every year (2011, 2010, …) since the year I was born. Some of the years contain subfolders that correspond to noteworthy trips that I’ve taken.

This method makes it extremely easy to back up my entire photo collection by dragging the “Pictures” folder to a different drive. It also makes it easy to reference and review the photos in rough chronological order. This is why I’ve never understood the purpose of third-party “photo management” software, since most such software inevitably reorganizes the underlying directories in its own crazy way, or builds a proprietary index of photos that takes the user away from the actual directory structure. If you’re aware of the organization of your photos on your disk, then any additional management software becomes superfluous.

At any rate, there is one slight issue with this style of organizing photos: all of the various sources of photos (different cameras, scanners, cell phones, etc) give different file names to the photos! So, when all the photos are combined into a single directory, they often conflict with each other, or at the very least become a disjointed mess. For example, the file names can be in the form DSC_xxxx, IMG_xxxx, or something similar, which isn’t very meaningful. Photos taken will cell phones are a little better; they’re usually composed of the date and time the photo was taken, but the naming format is still not uniform across all cell phone manufacturers.

Thus, the optimal naming scheme for photos would be based on the date/time, but in a way that is common between all sources of photos. This would organize the photos in natural chronological order. The vast majority of cameras and cell phones encode the date and time into the EXIF block of each photo. If only there was a utility that would read each photo, and rename it based on the date/time stored within it. Well, now there is:

Download it now! (Or browse the source code on GitHub)

This is a very minimal utility that takes a folder full of photos and renames each one based on its date/time EXIF tag. As long as you set the time on your camera(s) correctly, this will ensure that all your photos will be named in a natural and uniform way.

The tool lets you select the “pattern” of the date and time that you’d like to apply as the file name. The default pattern will give you file names similar to “20111028201345.jpg” (for a photo taken on Oct 28 2011, 20:13:45), which means that you’ll be able to sort the photos chronologically just by sorting them by name!

Pi is wrong! Long live Tau!

At one point or another, we’ve all had a feeling that something is not quite right in the world. It’s a huge relief, therefore, to discover someone else who shares your suspicion. (I’m also surprised that it’s taken me this long to stumble on this!)

It has always baffled me why we define π to be the ratio of the circumference of a circle to its diameter, when it should clearly be the ratio of the circumference to its radius. This would make π become the constant 6.2831853…, or 2 times the current definition of π.

Why should we do this? And what effect would this have?

Well, for starters, this would remove an unnecessary factor of 2 from a vast number of equations in modern physics and engineering.

Most importantly, however, this would greatly improve the intuitive significance of π for students of math and physics. π is supposed to be the “circle constant,” a constant that embodies a very deep relationship between angles, radii, arc lengths, and periodic functions.

The definition of a circle is the set of points in a plane that are a certain distance (the radius) from the center. The circumference of the circle is the arc length that these points trace out. The circle constant, therefore, should be the ratio of the circumference to the radius.

To avoid confusion we’ll use the symbol tau (\tau) to be our new circle constant (as advocated by Michael Hartl, from the Greek τόρνος, meaning “turn”), and make it equal to 6.283…, or 2\pi.

In high school trigonometry class, students are required to make the painful transition from degrees to radians. And what’s the definition of a radian? It’s the ratio of the length of an arc (a partial circumference) to its radius! Our intuition should tell us that the ratio of a full circumference to the radius should be the circle constant.

Instead, students are taught that a full rotation is 2\pi radians, and that the sine and cosine functions have a period of 2\pi. This is intuitively clunky and fails to illustrate the true beauty of the circle constant that \pi is supposed to be. This is surely part of the reason that so many students fail to grasp these relationships and end up hating mathematics. A full rotation should be \tau radians! The period of the sine and cosine functions should be \tau!

But… wouldn’t we have to rewrite all of our textbooks and scientific papers that make use of \pi?

Yes, we would. And in doing so we would make them much easier to understand! You can read the Tau Manifesto website to see examples of the beautiful simplifications that \tau would bring to mathematics, so I won’t repeat them here. You can also read the original opinion piece by Bob Palais that explores this subject.

It’s not particularly surprising that the ancient Greeks used the diameter of a circle (instead of the radius) in their definition of \pi, since the diameter is easier to measure, and also because they couldn’t have foreseen the ubiquity of this constant in virtually all sciences.

However, it’s a little unfortunate that someone like Euler, Leibniz, or Bernoulli didn’t pave the way for redefining \pi to be 6.283…, thus missing the opportunity to simplify mathematics for generations to come.

Aside from all the aesthetic improvements this would bring, considering how vitally important it is for more of our high school students (and beyond) to understand and appreciate mathematics, we need all the “optimizations” we can get to make mathematics more palatable for them. This surely has to be an optimization to consider seriously!

From now on, I’m a firm believer in tauism! Are you?

Good and bad science, and faster-than-light neutrinos

The results from the OPERA experiment at CERN have caused a huge stir in the media over the last two weeks, and with good reason, since they claim to have measured the arrival of a neutrino beam 60 nanoseconds faster than light.

Before we go on, let’s calm down a bit. Even if these results are somehow confirmed, it wouldn’t “prove Einstein wrong,” or cause scientists to stop using General and Special Relativity on a day-to-day basis. If anything, it would show that Einstein’s theory is incomplete, but no one is disputing this in the first place.

Relativity (general and special) has been put through dozens of independent, precise, elaborate tests, and passed every single one with astonishing accuracy, which means that there’s definitely something fundamentally correct about Einstein’s theory. It shouldn’t be thought of as some kind of “sitting duck” theory, just waiting to be overthrown.

Understandably, the current consensus among the world’s physicists seems to be that there was a measurement error in the OPERA experiment, or that the experimenters neglected to integrate some subtle factor that accounts for the missing 60 ns. (For a wonderfully accessible introduction to the OPERA experiment, as well as particle physics in general, read Matt Strassler’s blog. For a more thorough discussion of possible mistakes, read Lubos Motl’s post on the subject. It’s also worthwhile to read the comments on those blogs.)

Perhaps the most convincing evidence against this experiment is that we have observed neutrino emissions from supernovae (specifically SN 1987A), and these neutrinos more-or-less coincided with our observation of visible light from the same supernova. If neutrinos are really faster than light, we should have observed the neutrinos many months before we observed the light. The only loophole in this argument would be if the OPERA effect is energy dependent, since the OPERA neutrinos had much more energy than the ones from the supernova, but that would present even more problems.

Not being a particle physicist myself, I can’t meaningfully contribute to the discussions on theoretical implications of this experiment, if it’s actually true. I would, however, like to comment on how this story is unfolding from the point of view of the scientific method, and specifically how this story highlights the differences between real science and pseudoscience. I use “pseudoscience” to refer to homeopathy, energy healing products, reiki, dowsing, magnets, pendulums, astrology, and anything else that requires more “faith” than evidence.

In the wake of attending a New Age expo (out of morbid curiosity) and being overloaded with crackpots, quacks, and hucksters, these differences become all the more plain:

  • The fact that the experimenters published any data at all is a sign of great scientific integrity. The fact that they held a press conference before the paper was peer-reviewed is a bit unfortunate, as noted by Lawrence Krauss, but I think the fact that this story made it to mainstream media outlets will help the general public understand the scientific process, as people follow the story. Pseudoscientists, on the other hand, seem to be allergic to data in general, and never publish anything.
  • Essentially, the scientists of the OPERA experiment are saying, “We’ve gathered these data, we used the best possible experimental parameters, we’ve performed all the checks we could think of, and we still see this anomaly. So please, tell us what we did wrong.” This is surely science at its best! This is the kind of behavior that should be an inspiration for a whole generation of new scientists. We will never hear pseudoscientists utter that phrase.
  • Real scientists don’t adhere dogmatically to any theory, no matter how foundational it may be. Even though most physicists agree that there was an error in the OPERA experiment, they still reserve a little room for the possibility that the results are correct, and that Relativity might be violated. Einstein to physicists is not the same as Chopra is to pseudoscientists.
  • Real scientists expect extraordinary evidence for extraordinary claims. Most scientists agree that the evidence collected by the OPERA experiment is not extraordinary. Pseudoscientists make extraordinary claims every time they open their mouth, but present no evidence at all, except anecdotal testimonials from their friends and paid endorsers.
  • If we read the blogs of popular physicists on the subject of the OPERA experiment, we find lively debates on theoretical explanations for the anomalous effect, and discussions on ways the experimenters miscalculated the speed of the neutrinos. The key point is: scientists get excited about the possibility of being proven wrong. Scientists can’t wait to be proven wrong, because it would mean that there’s more science to be done!
  • Perhaps most importantly, real scientists are motivated by a desire to better understand our world. The only motivation of pseudoscientists is money, thinly veiled by a scientific-sounding sales pitch, and a nonsensical product du jour.

In any case, I encourage everyone to follow this story, because it’s a high-profile example of real science at work; a triumph of human achievement. No matter how the results turn out, by observing the process of scientific scrutiny, everyone will be better equipped to spot pseudoscience when it’s in plain sight.

I will update this post as soon as I see a quack energy-healing product that uses faster-than-light neutrinos to balance the flow of energy through your chakras. Post a comment if you find one yourself!

Atheism as a religion

It annoys me to no end when religious people claim that atheism is “a religion” or that atheism is just as “dogmatic” as religious beliefs. This will be the subject of a much longer article at some point, but until then, let me share a quick aside on this topic.

Here’s a key difference between atheists and religious people:

Atheists don’t need any mechanism of reinforcement for their beliefs. Since we draw our beliefs from the natural world, we don’t need to appeal to imaginary beings and reassure ourselves that they exist, despite overwhelming evidence that they don’t. We don’t need to speak empty words into empty air every day, while banging our heads against the floor. We don’t need to congregate in a large room for a session of mutual emotional masturbation where a charismatic leader (who actually refers to us as a “flock”) assures us that our beliefs are infallible and questioning them is pointless or even dangerous.

We never need to switch off our rational minds, or even put them in the back seat for the purpose of indulging ourselves in believing things that our ignorant barbaric ancestors tell us to believe. Perhaps the words “ignorant” and “barbaric” are too harsh; our ancestors did the best they could. The point is, the ignorance of our ancestors is forgivable. What’s unforgivable is clinging on to that same ignorance in our modern world. Even less forgivable is considering it a virtue to perpetuate such ignorance.

We are capable of drawing feelings of spirituality from the grandeur and complexity of the natural world. Instead of using our imagination to invent more intricate ways of deluding ourselves, we use our imagination to improve the quality of life for current and future generations, since we know that this life is the only one we get, which makes it all the more precious and fragile.

The FujiFilm .MPO 3D photo format

A few weeks ago my dad, in his love for electronic gadgetry, purchased a FujiFilm FinePix REAL 3D camera. The concept is pretty simple: it’s basically two cameras in one, with the two sensors spaced as far apart as an average pair of human eyes. The coolest thing about the camera is its LCD display, which achieves autostereoscopy by using a lenticular lens (kind of like those novelty postcards that change from one picture to another when you look at them from different angles), so if it’s held at the right angle and distance from the eyes, the picture on the LCD display actually appears 3-dimensional without special glasses!

Anyway, I immediately started wondering about the file format that the camera uses to record its images (as well as movies, which it also records in 3D). In the case of videos, the camera actually uses the well-known AVI container format, with two synchronized streams of video (one for each eye). In the case of still photos, however, the camera saves files with a .MPO extension, which stands for Multiple Picture Object.

I was expecting a complex new image specification to reverse-engineer, but it turned out to be much simpler than that. A .MPO file is basically two JPG files, one after another, separated only by a few padding zeros (presumably to align the next image on a boundary of 256 bytes?). Technically, if you “open” one of these files in an image editing application, you would actually see the “first” image, because the MPO file looks identical to a regular JPG file at the beginning.

I proceeded to whip up a quick application in C# to view these files (that is, view both of the images in each file). This quick program also has the following features:

  • It has a “stereo” mode where it displays both images side by side. Using this feature you can achieve a 3D effect by looking at both images as either a cross-eyed stereogram (cross your eyes until the two images converge, and combine into one) or a relaxed-eye stereogram. You might have to strain your eyes a bit to focus on the combined image, but the effect truly appears 3-dimensional.
  • In “single” mode, the program allows you to automatically “cycle” between the two images (a wiggle-gram, if you will), which creates a cheap jittery pseudo-3D effect (see screen shots below).
  • Also in “single” mode, the program lets you save each of the frames as an individual JPEG file by right-clicking on the picture.
So, if you want a quick and not-so-dirty way of viewing your MPO files, download the program and let me know what you think! (Or browse the source code on GitHub)
Here’s a screenshot of the program in “stereo” mode:

And a screenshot of the program in “cycle” mode:

If you like, you can download the original .MPO file shown in the screenshots above.

Now for a bit of a more technical discussion…. Clearly it would be a great benefit to add support for the .MPO format to DiskDigger, the best file carving application in town.

However, from the perspective of a file carver, how would one differentiate between a .MPO file and a standard .JPG file, since they both have the same header? As it is now, DiskDigger will be able to recover the first frame of the .MPO file, since it believes that it found a .JPG file.

After the standard JPG header, the MPO file continues with a collection of TIFF/EXIF tags that contain meta-information about the image, but none of these tags seem to give a clue that this is one of two images in a stereoscopic picture (at least not the tags within the first sector’s worth of data in the file, which is what we’re really interested in).

One of the EXIF tags gives the model name of the camera, which identifies it as “FinePix REAL 3D W3.” Perhaps we can use the model name (the fact that it contains “3D”) to assume that this must be a .MPO file, but I’d rather not rely on the model name, for obvious reasons, although the FinePix is currently the only model that actually uses this format (to my knowledge).

The other option would be to change the algorithm for JPG carving, so that every time we find a JPG file, we would seek to the end of the JPG image, and check if there’s another JPG image immediately following this one. But then, what if the second JPG image is actually a separate JPG file, and not part of a MPO collection?

For the time being, DiskDigger will in fact use the model name of the camera to decide if it’s a .MPO file or just a regular .JPG file. The caveats of doing this would be:

  • It won’t identify .MPO files created by different manufacturers.
  • It might give false positive results for .JPG images shot with the camera in 2D mode.

As always, you can download DiskDigger for all your data recovery needs. And if anyone has any better ideas of how to identify .MPO files solely based on TIFF/EXIF tags, I’d love to hear them!

Update: DiskDigger now fully supports recovering .MPO files, based on deep processing of MP tags encoded in the file!