Showing posts with label histogram. Show all posts
Showing posts with label histogram. Show all posts

Friday, February 19, 2010

The focal lengths I use

A long time ago I wrote a small script that spits out a histogram of all the focal lengths you use. This is done by querying spotlight on Mac OS X. The script is as follows:

#!/usr/bin/perl

$start=shift;
$end=shift;
$delta=shift;
$flength=$start;
$onlyin=shift;
$filetype=shift;

print "Generating histogram of focal lengths starting at $start, ending at $end, and with stepsize $delta in the directory $onlyin\n";

while ($flength<$end)
{
print "$flength\t";
$endbin=$flength+$delta;
$commandstring="mdfind -onlyin $onlyin \"(kMDItemFocalLength>=$flength) && (kMDItemFocalLength < $endbin) && (kMDItemDisplayName = '*.$filetype*'cd) \" | wc -l";
system($commandstring);
$flength+=$delta;

}


#mdfind "kMDItemFocalLength>=10 && kMDItemFocalLength < 15) " | wc -l



Copy and paste this in a textfile (I named it flengthscript.pl) and save it in your home directory. Now open a terminal and type
perl flengthhistoscript.pl 0 300 5 "Your directory location here" NEF

Replace the location with the location where you store your images and replace NEF by whatever filetype you use or leave it blank to analyse all filetypes.

The script spits out a simple tab delimited list of focal lengths followed by the number of images it found in the range of the focal-length number+the delta that you chose. You can simply graph this in any graphing program such as Igor Pro, gnuplot, Numbers, IDL, Excel, etc.

Here is the output on about 20k RAW files that are currently on my harddisk. You can see I favor 18, 35, and 50 mm and also the top of my tele range which is 200 mm. This indicates I might like some longer lenses as well as wider lenses to add to my repertoire.

Wednesday, May 16, 2007

What kind of photographer are you?

I was reading this interesting post on the inside lightroom blog. It shows how to use lightroom to show which lenses you use most. At the end, the writer poses the interesting question of how to make a histogram of which actual focal lengths you use. I don't think this is possible inside Lightroom, so I set out to write a very simple perl script to do it using the spotlight services in Mac OS X. Here it is:

cat flengthhistoscript.pl
#!/usr/bin/perl

$start=shift;
$end=shift;
$delta=shift;
$flength=$start;
$onlyin=shift;

print "Generating histogram of focal lengths starting at $start, ending at $end, and with stepsize $delta in the directory $onlyin\n";

while ($flength<$end)
{
print "$flength\t";
$endbin=$flength+$delta;
$commandstring="mdfind -onlyin $onlyin \"kMDItemFocalLength>=$flength && kMDItemFocalLength < $endbin) \" | wc -l";
system($commandstring);
$flength+=$delta;

}

Just copy and paste this (starting at the # mark and ending at the closing curly bracket) and save it in your Home folder as "flengthhistoscript.pl". You can call it in the following way:
perl flengthhistocript.pl 0 300 2.5 ~ > histo.dat

from your commandline (terminal.app), which will bin all files that have a defined focal length in your home folder (the tilde can be replaced by any folder you'd like) starting at a focal length of zero mm and ending at 300, with a 2.5 mm bin width. It saves the output in a text file called histo.dat. Here is an example of my Pictures folder plotted in Igor Pro, my favorite plotting program:


You can see that I tend to photograph on the short end. The big peak is in the bin 17.5 - 20mm, which is the short end of my standard kit lens (18mm), which tells me I should probably get myself a wider lens as I am constantly using it as short as possible. The peaks below it are my fisheye 10.5 mm and probably some images shot using Mariska's Point and shoot. One could adapt the above script quite easily to only give results for certain cameras, dates, locations, etc. as spotlight indexes all that info. Now go figure out your lens pattern!