Photo Histograms Everywhere!

Aug 31
Posted on August 31, 2008 0:56 in Photography, Problems & Solutions, Projects

Most of you probably know that I am a huge fan of photography, my Flickr account being the prove of it. But besides uploading my own photographs I also love to give other photographers feedback on their photography.

One of my common things I like to do when judging a photo is to have a look at the photo’s histogram. Unfortunately to do so, you need to download the photo, load it into your favorite photo application and then look at the graph. This gets a bit tedious if you want to do it quite often.

So I decided to make my own solution that will work in any browser. I have some experience with bookmarklets, and as they are highly cross-browser they looked like the way to go. Unfortunately most browser do not support the next generation CSS/Javascript that will allow for the histogram data to be read out in the browser only, so I had to extend the concept with some server side code. It all worked out though, and after less than a day coding I now have a working system.

Server Side Code

The server side part is a PHP script that parses the photo’s pixels and generates a nice graph using the Google Chart API. The service returns a javascript function when run in the bookmarklet but it can also be called as a service to generate a image or a html block. Here is an example of an image and it’s equivalent histogram created via the server side script.


Geeks in the Country - Cliffs

 

Geeks in the Country - Cliffs

The url of the photo is 

http://farm4.static.flickr.com/3122/2806124294_08cc5efc74.jpg

And the url of the corresponding histogram is

http://histogram.cristianobetta.com/?type=image&rgb=true&image=

http://farm4.static.flickr.com/3122/2806124294_08cc5efc74.jpg

As you can see, the histogram script takes 4 parameters. The image parameter defines the image to be parsed. This can be either a jpg, png, or gif file. The rgb parameter let’s you choose between a grayscale or rgb histogram. A grayscale histogram for this image would look like this.

Geeks in the Country - Cliffs

Finally the type parameter let’s you choose between an image (like the examples above), html object (image pre-wrapped in a img html object) or a piece of Javascript (js, callable as getSrc()). 

Since September 3rd 2008 the service also take a width parameter. For more info see the end of this post.

The Bookmarklet 

The web service gets more powerful when we add a nice bookmarklet. I wanted to be able to load the histogram for any image on the web with just a few clicks. So, I decided to make a bookmarklet that loads a simple GUI, prompts you to click the image you want to analyze, and then shows you the histogram. The result was a bit more code than I hoped for but more solid than I expected. I think the easiest way to show you how it works is with a video.



Download

So enough talking, I guess you want to try it yourself. Drag this bookmarklet into your bookmarks bar and try it out. 

If you really like the service, I would appreciate if you would install your own version of the server side script on your own server, simply because it will save me bandwidth feel free to use the webservice and bookmarklet as much as you want. You can also decide to download the webservice to your own host if you want to.  When installed on your own server, change the host variable in the bookmarklet to point to your own server and all should be fine.

The source of both the server side script and the bookmarklet are available to anyone who wants to play with them and released under GPL2.

Download as Zip

Improvements

There are still a few things that need to be worked out. I invite anyone to have a look at the code and help me out. Some of the main improvements currently are:

  • Caching – Currently nothing is cached. A little bit of caching would make things way less bandwidth demanding. This has been implemented since September 3rd, 2008. Javascript, image, and HTML output is now by default cached for 24 hours.
  • Custom size – Currently the server side script returns a fixed size image, but it would be arbitrary to allow the bookmarklet to send the parameters defining the size. I added a simple height parameter that is optional. Images will always have a aspect ratio of 2:1 as this makes histograms look better, plus it makes it easier to oblige to Google Chart API’s demand of staying under 300.000 pixels. Therefore the max height you can specify is 385 pixels (making the image 385×770, or 296.450 pixels).
  • Correct Histogram Calculation – I don’t think that I’m far off at the moment, but I might have scaled some of the histograms just slightly off from what it is supposed to look like. I need to read up on how histograms are generated in pro-tools.

Geeks in the Country

Aug 28
Posted on August 28, 2008 23:36 in Events, Photography

Melinda and I went for a few days to the English countryside, Dorset to be more precise, as a “Geeks in the Country” gathering organized by Sheila. It was literally like the holiday I didn’t have this year and exactly what I need to relax a bit. 

I am almost done uploading the photos that I took. Dorset is simply gorgeous and I had to limit myself to the amount of photos I could upload. Here are some of the best picks though.

Geeks in the Country - Melplash Show

We went to the Melplash show and had a look at the animals. Never been to a show like this but I really enjoyed it.

 

Geeks in the Country - Melplash Show

During the show they had some parachutists drop in, but unfortunately we were standing in the smoke created by the orientation-flare.

 

West Bay Cliffs (HDR)

I also tried my hand at some HDR to capture the beauty of the country side, and I think they worked out pretty well. I love especially how the next one doesn’t look too much like a HDR.

 

West Bay Harbour (HDR)

The village of West Bay in HDR. Quite gorgeous.

 

Geeks in the Country - Cliffs

These cliffs look like they are made of gold. Wish I could have taken them with me to make more photos of at home.

Geeks in the Country - Durdle Door

Durdle Door. Absolutely amazing. The walk to it is quite a joy too.

 

Dorset Panorama

Besides HDR I also tried my hand at some panorama’s. They worked out quite nice too.

Flickr On Black Bookmarklet

Aug 27
Posted on August 27, 2008 1:36 in Photography, Problems & Solutions, Technology

I decided to test my bookmarklet skills once more and write a little script that could convert a black-on-white Flickr page into a white-on-black Flickr page. The reason for this is that some photos just look better on black.

There are some other solutions that do this but they require you to load the image in a different site, and I thought a bookmarklet could probably do the work faster as it doesn’t need to reload the photo. There was an issue that I bumped in though: quite a few elements on Flickr are white images, which can’t be changed to black. 

So I decided on a different take: hide the Flickr GUI elements, append a new element, load the image in it on black, and show it to the user. This seems to work at the moment with the below bookmarklet.

Flickr on Black

Go to any Flickr photo page, and press the bookmarklet. It should load a black screen with the photo. Either pressing the “Back to Flickr” or the bookmarklet again would bring you back to Flickr in white.

There are two major issues at the moment, The one is critical and that is that somehow mouse overlays, menus, and other items in the Flickr GUI, don’t seem to work after use of this bookmarklet. I don’t know why at the moment so please let me know if you do.

Secondly I would love for the script to autoload a larger sized image for you, as that makes viewing even more pleasant.

So, think you can help, let me know. The source can be found here:“Flickr On Black” source

My Bookmarks For August 10th – August 21st

Aug 21
Posted on August 21, 2008 13:00 in Links

Idea: Personal Data Plugin for Wordpress

Aug 19
Posted on August 19, 2008 22:59 in Problems & Solutions

I have only used Zemanta for a short time after it was launched, mainly because it makes stuff too easy. I noticed loads of people linking back to me as a “related” article produced by Zemanta and barely had any extra traffic or decent contextual link backs coming from it. It just shows me that the people that use Zemanta “just click” to be done with their post quickly.

The idea

It got me thinking though, what would be handy is a plugin that can get me contextual links and images and other data that are my images, links and data.

To give an example, Alper writes in this post about some “Street Photography” a friend made. He then posts some photos from that friend but he also links back to a photo from himself that is related to street photography. Why isn’t there a plugin that can automatically provide you links of your own Flickr photos for example that are “probably” related to your current post.

Another example, in the same post, Alper talks about the photos he took with his 120mm camera this weekend. He then links back to his trip on Dopplr of last weekend. A plugin that would do a Zemanta-like thing would know Alper’s Dopplr account, guess he either meant next or last weekend, and offer some links to those trips.

I wonder if an all-round plugin like this exists or if it is relatively easy to create one?

Use Apple Remote on a G4 Mac

Aug 17
Posted on August 17, 2008 3:08 in Hardware, Problems & Solutions, Software

These days every mac has a remote control receiver and Apple has stopped shipping remotes with their machines because admittedly we all already have one by now. There are a few people though that have a Mac perfectly capable of running Front Row but can’t use the Apple Remote with their Mac because it is too old.

I am one of these, as I have an old Mac Mini G4 setup as a media center. I love it because it can play all my movies, even HD, without many problems, but unfortunately I had some remote-trouble recently. As a solution to my initial lack of remote I bought the Keyspan RF Remote, which did the trick of simulating an Apple Remote  for a while until the Keyspan remote died. As Keyspan doesn’t sell these anymore and they go for quite a few buck on eBay, I started to look for a different solution.

 

 

This is when I found about the Mantra TR1 sold by Twisted Melon which is a simple IR receiver that can work with the standard Apple Remote. These guys at Twisted Melon normally write the remote control software Mira which can be used together with the Mantra TR1, which was in turn created to give those people without a build-in remote control receiver a cheap solution. The Mantra TR1 was just £14.38 including shipping from Australia, so it was a very good deal (better than the Keyspan RF Remote).

Software

I wouldn’t recommend buying the Mantra TR1 together with the Mira software though. The software hasn’t been maintained for a while and is buggy as hell, on both my Mac Mini and my Macbook. Instead I would advise you to go for SofaControl (£9) which is another application that can work with this receiver and does a way better job.

About the Mantra TR1

Finally I thought I’d share with you my opinion of the hardware. The photo on their site is pretty big although the receiver seems to be small. I thought it would therefore be quite bulky but it isn’t. It’s quite cute and small and weighs basically nothing. Reception is pretty good and basically works through my TV as I had it behind my TV for a while and it still worked.

It has a little red light that blinks when it receives a remote signal. This can be quite annoying if you want to keep the receiver in sight but as I said it works fine even out of sight. One of the interesting things though of seeing the light is that I noticed that sometimes it receives my command but doesn’t do anything. I don’t know if this is because of bad reception or not but it is very seldom and not that annoying.

All and all I know have a proper remote for my Mac Mini media center again and that for only £24.

Make your own Mac VPN with ShareTool

Aug 15
Posted on August 15, 2008 1:32 in Problems & Solutions

I wanted to investigate the option of having a cheap and easy VPN solution so that I could secure my data when I am on public WiFi. Obviously the real die-hard techies can set up their own VPNs with industry grade tools, or setup a VPN using SSH tunneling, but I didn’t want to spend too much time figuring out all the details. So, I did a quick Google search and found ShareTool.

ShareTool is a very simple application that lets you connect to your home network and enjoy the Bonjour services there (like printing, network file sharing, etc). What they add as an extra is something called “secure browsing” which makes a secure tunnel to your home network and lets you then browse the internet encrypted over this connection. They use a special Firefox profile that they preload for you, and honestly this is really handy for people that just want to browse securely without releasing all their details in plaintext on the public WiFi.

I wanted to do more though than just browsing so I decided to look at how they did this tunneling. I discovered they set up a SOCKS proxy which I decided could be used to divert all traffic through, not just web traffic. So, I set it up and it works. I don’t want to write out all the details so why don’t I just show you (watch on Vimeo for High Definition quality video).


I hope this helped some people use open WiFi a bit more wisely.

What do Crumpler and Ben & Jerry’s have in common?

Aug 13
Posted on August 13, 2008 0:06 in Offline

After Melinda’s blog post earlier today about Ben & Jerry’s forgotten flavors, I got to talk to her about why somehow I get the same “vibe” from both B&J and Crumpler. it got me to think that these two companies have quite something in common, but I can’t figure out what the deeper cause is that makes me think this.

Here is what I realized the two quite different companies have in common:

  • They don’t sell normal “stuff”: B&J might have some basic flavors like “Vanilla like it oughta be”, and Crumpler might sell a few bags that look like an average no-name brand, but in general both brands sell products that stick out because their products are pretty unique and recognizable. Do I only notice this because they both only target very specific crowds?
  • They give their products weird names: My Crumpler bag is called a “Warm Shower”, my favorite B&J ice cream is called “Half Baked”. Not very normal names and often with a double meaning. 
  • They have an odd sense of humor: Take a quick look at the Crumpler site or the side of a bucket of B&J and you know what I mean. Cows, naked men, funny situations, etc.
  • Their products are “expensive” but not “luxurious”: The average Crumpler bag and B&J ice cream cost a bit more than their generic counterparts, but somehow they are not about luxury. If you would buy a luxury bag, it would be made of leather, but Crumpler does not sell leather bags. If you would get some Sainsburry’s luxury ice cream, it would probably be served with some special topping, like a cherry or something, and maybe they provide it in a nice “special” crystal-like but still plastic bucket, but B&J ice cream never gets served like that. 
So do these companies have something more intrinsic in common than I know of? Please tell me, I want to know.