Pondering about a prime lens for my camera – a scientific approach
I recently got caught up in a discussion about getting a prime lens (== a fixed focal length lens) or another zoom lens for my camera. It seems that I will not be getting a lens anytime soon, but I wrote a cool perl script, which I want to share here
I decided I should analyze what focal lengths I used while taking my photos so that I can take a more conscious decision. After some trials and errors, what I came up with was:
find . -exec exiftool {} \; | perl -ne '/^Focal Length.*equivalent:(.*)\)/ && print "$1\n";' | sort | uniq -c
which runs exiftool on all my photos, extracts the 35mm equivalent length (I took my photos with at least 2 different cameras) sorts them and generates a pseudo-histogram.
I thought I was done, but I then realized that something must have been wrong with the data as some of the focal length ranges were well beyond what any of my camera has. I investigated a little and found out that some of the photos from my G3 have an incorrectly calculated 35mm equivalent. This means that such a simple script will not do.
Here is my second try:
find . -exec exiftool {} \; | perl -ne '
if (/^ExifTool/) { $camera = ""; $lens=0; };
if (/^Camera Model Name.*: (.*)/) { $camera = $1; };
if (/^Focal Length.*: (.*)mm/) { $lens = $1; print "\"$camera\" $lens\n"; }; ' > photos-lengths.ssv
Now I have a text file with something like:
"Canon PowerShot G3" 7.2
"Canon EOS 350D DIGITAL" 38.0
This file can be conveniently read into R so that I can plot a real histogram:
lengths <- read.table("photos-lengths.ssv")
lengths_camera <- split(lengths, lengths$V1)
num_cameras <- length(lengths_camera)
old_par <- par(mfrow = c(floor(sqrt(num_cameras)), ceiling(num_cameras / floor(sqrt(num_cameras)))))
# one chart for each camera.
for (c in names(lengths_camera)) {
l <- lengths_camera[[c]]$V2
# filter likely corrupted data.
l_filt <- l [ (5 < l) & ( l < 100) ]
hist(l_filt, xlab="focal length [mm]", ylab="#photos", main=c, breaks = 30);
}
par(old_par);
This little script produces a nice matrix charts with histograms of focal lengths for all the camera. So the conclusions is that I could get a 30mm prime lens, but also a 10-20mm lens would not be a bad idea
April 1st, 2007 at 4:38 pm
[...] Beth wrote an interesting post today onHere’s a quick excerptI recently got caught up in a discussion about getting a prime lens (== a fixed focal length lens) or another zoom lens for my camera. It seems that I will not be getting a lens anytime soon, but I wrote a cool perl script, … [...]
January 14th, 2008 at 10:47 pm
This is great. I had never heard about R until I read this. Nice tool. Thanks! Oh, and I have a 10-20mm lens. It’s pretty nice to have.
February 16th, 2008 at 10:06 am
10 Reasons a Digital Camera Is Your Best Buy…
Choosing a digital camera to capture those all illusive moments should be a well thought out purchase. Selecting a digital camera is by far your best choice. A digital camera can enhance your treasured snapshots by allowing you to make changes and impr…