Posts Tagged learn

Learning Photography — Prime Lenses

Whether you’re new to photography or you’ve been shooting for a while, if you’re still using your kit zoom lens — you should consider getting a prime lens as your next lens.

July 16 - The Spiffy New Lens
An EF 85mm f/1.2L II mounted on my 40D

What is a “prime” lens? A prime lens is a lens with a fixed focal length meaning that it can not zoom. So you may wonder why in the world would you want to get a lens that doesn’t allow you to zoom? Well there are at least a dozen reasons I could give you — among them: primes are cheaper (generally for the quality you get), sharper, and faster.

Zoom optical systems are generally fairly complex because they have to correct for more factors; thus, with a simpler design, primes often require less glass (lower price) and/or produce a higher quality image (higher image quality). Furthermore, prime lenses often have larger apertures (especially for the price). You’ll find primes with apertures around f/1.4 for under $500, whereas most zoom lenses with an aperture of f/2.8 are going to very likely cost over $1k! Faster apertures also make these lenses great for taking photos at night or in a dim room without a flash. The shallow depth of field makes these lenses great for taking portraits with a beautiful background blur as well.

In addition to the tangible benefits, prime lenses also help reinforce important concepts in photography. Many photographers become lazy and use zooming to compose their images. Zooming rather than physically moving yourself to recompose your shot makes a big difference! Using a prime lens forces you to move around to recompose and makes you a better photographer. Using a prime also encourages the photographer to focus on other thing such as focusing and exposure.

Shows the same subject shot at 24mm vs. 200mm.

Shows the same subject shot at 24mm vs. 200mm.

You can see in this example that the same subject shot at two different focal lengths produce two extremely different images. Notice how the wide shot at 24mm emphasizes the shape of the glass and there is quite a bit of the background in view. In contrast, the 200mm shot compresses the detail and the glass looks pretty flat. Not as much of the background is also in the shot because the field of view is narrower. Because of this, telephoto lenses are generally preferable for shooting portraits because it does not emphasize facial features such as the nose or chin.

So which lenses should I get? Here’s a list of some prime lenses…

Read the rest of this entry »

, , , , , , , , , , , , , , , , , , , , , ,


Python Talk

I gave a talk on Python for cplug yesterday.  

Check out the slides here.


During the talk, I wrote a simple Python script to pull content off the web and parse the data… here’s the jist of what I did:

First, lets pull a webpage off the internet:

import httplib
def get_webpage():
   conn = httplib.HTTPConnection('')
   rd = conn.getresponse()
   print rd.status, rd.reason

This function creates a HTTPConnection object for and the connection object is stored in conn.
We then do a GET request for the Python wiki page. The result of the request is stored in the connection and we can access the status by calling getresponse() which returns a HTTPResponse object.
The status can be accessed with .status and .reason and the data can be accessed with .read().

This yields the plain-text html of the wiki page. This is not very interesting or useful so lets do something else with this data… lets write a frequency counter:

 def get_freqct(data):
     wordlist = data.split(' ')
     freqct = {}
     for s in wordlist:
       if s not in freqct:
     return freqct 

We can pass the data (a string) we got from the first function to our get_freqct function. The function first uses the built-in string function to split the string by a white-space delimiter returning a list of words. We then iterate through the wordlist and generate the frequency count using the dictionary data type. At this point we have something fairly interesting but simply printing out this list is fairly cluttered… lets sort it!

You can quickly sort the contents of this dictionary with the sorted function:

import httplib
from operator import itemgetter

sol = sorted(d.items(), key=itemgetter(1))

This statement takes the items in d (the dictionary) and returns a list of tuples (key,data) and is sorted by the data field of the tuple using the itemgetter function. So you’ll end up with a sorted list of tuples ordered by the data field.

Then we can print the list with the following for loop:

   for word,count in sol:
      print word, ":", count

This for loop unpacks the contents of each of the tuples in the sorted list (sol) into the variables word and count. The variables are then printed with the print statement.

If you run this code… you’ll realize that a lot of HTML tags (or parts of HTML tags) get counted. This is not very desirable so lets filter them out using a regular expression!

data = re.sub(r'<[^>]+>','',data)

This regular expression takes the raw data (string) returned by the get_webpage function and replaces each occurrence of an HTML tag with an empty string.

Deconstructing the regular expression:
<- matches the ‘<‘ symbol
[^>]+ – matches one or more of anything except the ‘>’ symbol (where + means one or more)
>- matches the ‘>’ symbol

…and put it all together:

import httplib
import httplibfrom operator import itemgetter
import re

def get_webpage(site,page):
   conn = httplib.HTTPConnection(site)
   conn.request("GET", page)
   rd = conn.getresponse()
   print rd.status, rd.reason

def get_freqct(list):
    freqct = {}
    for s in list:
      if s not in freqct:
    return freqct

def main():
   data = get_webpage('',"/wiki/Python_(programming_language)")
   data = re.sub(r'<[^>]+>','',data)
   d = get_freqct(data.split(' '))
   sol = sorted(d.items(), key=itemgetter(1))
   for word,count in sol:
      print word, ":", count

if __name__ == "__main__":

The following is a snippet of what the script would yield:

language : 24
code : 24
which : 24
by : 27
Retrieved : 32
with : 32
are : 33
as : 38
on : 50
for : 51
in : 64
is : 80
to : 92
a : 98
Python : 103
and : 122
of : 125
the : 144

, , , , , , , , ,

No Comments