Monday, December 2, 2013

So you think you want a DSLR...

When you're looking at a picture and think it's an SLR, it's just the effect of a good lens and sensor. It's not necessarily an SLR. It can be a rangefinder, a mirrorless interchangeable lens camera even a large sensor compact.


In this post, I will explain:
  • What makes a DSLR different from simple compacts (size, mirror)
  • Usability differences (viewfinder and specific AF points)
  • CDAF and PDAF focusing methods (CAF, specific points vs full sensor)
  • DSLR Alternatives (MILC/large sensor compact)
  • Large Sensor Compacts (a few options)


I've seen several people say they want a DSLR after viewing another person's pictures. The problem is there are several cameras out there that can give the effect they want, but they only recognize the almighty DSLR as the means to it.

Don't get me wrong - for the most part, a good DSLR is a superior option, but think of the average person using their camera to take a picture of their family. Be it a phone or compact camera, they're not bothering with how they're focusing, ISO, Aperture etc. They're also not taking the picture with their eye up to the camera, as there's most likely no viewfinder.

What makes it a DSLR...
So right off the bat, there's a usability difference. The "R" in DSLR is reflex. It refers to the action of the mirror that the user looks through when taking pictures. 
 
In the above left diagram, the ray of light coming in hits the angled mirror and focuses on the blue line. This line contains the focusing screen, and auto focus sensors. Light passes through here to a prism or mirror then through the viewfinder. The "problem" with this is focusing is done at fixed points (see diagram on the right). Some of these points are more sensitive than others (usually center point) meaning in tough conditions, only those points will focus. This leads to the common act of focusing with the best point(s) -AF sensors at the center- and recomposing the shot.

This type of focusing is called Phase Detect. Now you need to be concerned with which points are active. Otherwise you wont focus on what you're taking a picture of! When the shutter button is pressed, the mirror flips upwards, and light hits the sensor.

NB: credit Anandtech for AF points diagram.

The other aspect is the sensor size - but this isn't exclusive to DSLRs. It's just that no DSLRs use the tiny sensors found in phones and common compact cameras.

What makes simple cameras easier?
There's more work involved in simply focusing with a DSLR. Why? Well to be fair, you can get the similar "problems" with higher end compacts that let you select focus. I'm calling it "problems" because it's really control.
A good compact/phone camera generally autodetects faces removing the need to worry about how to focus. With small sensors, scenic shots generally have so much depth of field it doesn't matter if they're a little off. i.e. most everything is in focus. 

Focusing of these cameras is done directly on the sensor. In phase detect (DSLR), the light from the lens is directed to a focusing screen with AF sensors. The sensors manage focus. In small compacts, phones, and mirrorless interchangeable lens cameras, the focusing is done by the same sensor taking the picture. The advantages are the entire area of the sensor can be used to focus. Think of it as having AF points everywhere, all with the same maximum sensitivity.
Also, since the entire sensor is active, image processing can be used to detect stuff like faces, or smiles, so it can automatically focus on people's faces, and autosnap if they smile.

This type of focusing is called Contrast Detect.

Why use one or the other?
It sounds like Contrast Detect (CDAF) has some advantages over Phase Detect (PDAF) by using the sensor. It does, but that's not the entire story. There's some disadvantages too.

CDAF uses the entire sensor, PDAF is restricted.
CDAF gets the full image, so it can detect faces, objects etc.
CDAF uses the sensor itself where PDAF can have alignment issues and focus a little infront or behind the sensor.

PDAF can determine if an object is infront or behind the current focus plane, and will focus faster generally.
PDAF can perform Continuous Autofocus - i.e. focusing on moving objects for multiple shots currently much better than CDAF.
Using the reflex mirror means there's ZERO latency tracking moving subjects. A CDAF LCD can lag behind the actual movement.

In general, DSLRs will use PDAF. Their CDAF implementations are quite slow. When using a DSLR, you will be restricted to using the viewfinder. The advantage is this actually helps keep camera shake down. the disadvantage is you need to be MUCH more mobile. Especially with little kids.

DSLR alternatives
There are alternatives of course that can give equal image quality to DSLRs, but provide CDAF (there's also rangefinders, but lets not go there...) focusing for ease of use. These cameras are large sensor compacts and mirrorless interchangeable lens cameras.

If you're buying a DSLR but only use the kit lens, get your money back. You're wasting your money. The kit lens is a dark and generally not very sharp lens. The entire point of getting a DSLR or any interchangeable lens camera, is to change the lens to your need.

Mirrorless Interchangeable Lens Cameras (MILC) have the same size image sensor as a DSLR. Micro Four Thirds sensors is slightly smaller, but still comparable in image quality. MILC cameras are smaller - as they don't need the space for the mirror or prism. As a result, there are also less constraints on the lens. i.e. the designer can start putting lenses closer to the sensor.

As with most CDAF based cameras, the rear screen can be used to compose and select focus point(s). This makes it easy to just stand normally when holding the camera at an angle to shoot. Being electronically coupled, these screens can even come on hinges to make it even easier to shoot below, and of course, there are options for regular viewfinders. A camera like the Panasonic GX7 or Olympus OMD-EM5 give both options - a viewfinder and rear viewscreen.

Large sensor compacts do not have a sensor as big as these. Their sensor is small in comparison - however many of them have fast lenses. If you don't want to spend money on lenses, this is probably a better option. The difference between a lens listed as F1.8 and a lens listed as F3.5 is you get 4 times as much light in the same area covered by the lenses. 4 times the light means a faster shutter for less shake, and better freezing of motion. It means lower ISO for less noise - less grainy pictures in low light. It also means more depth of field control, which is subject isolation. Don't expect a lot from compacts though.

My perspective
I've used several cameras, and currently have a Canon 5D and Olympus EP3 as my main cameras. The 5D is full frame, having a much bigger sensor (almost 4x the area).

As far as usability goes, the EP3 wins hands down. CDAF is generally slower - but that's comparing it against the best really - do you have $$$$ for the best?
Focus is lightning quick, and because it can focus an snap the picture based on where I touch the viewscreen, composition is much easier. Taking pictures of my kid running about is much easier.

For quality though, there's no contest. The 5D's pictures take on a whole new meaning to bokeh comparing against the EP3. This is due to the larger sensor really. If I could get the same quality in a mirrorless body, I would no longer have a need for the SLR.

Some solid mirrorless cameras:
  • Olympus - any 16MP cameras (12MP use an older sensor). EPL5, EM5, EM1 etc.
    These cameras are of the Micro Four Thirds standard.
  • Panasonic - their 16MP cameras - again, the older 12MP cameras have an older sensor which is noticeably worse in low light.(G6, GX7, GX1, GM1). These cameras are of the Micro Four Thirds standard.
  • Sony - Sony's NEX system uses APS-C sensors. The same sensor gets used by Nikon and Pentax in their DSLRs and Leica's M8. Lens options include NEX, and sony'd DSLR mount lenses via an adapter.
  • Fuji - The fuji EX series is a capable low light system. AF historically lagged behind NEX and MFT. Lens range is somewhat limited, but they have decent options. Fuji has the right lenses needed to round out your range, but options less than NEX and MFT.
  • Samsung - The NX series uses Samsung's own sensor. It's good, but RAW files are huge, and take a long time to process after shooting. Lens range is limited.
Olympus and Panasonic have clear advantages in lens availability as both are using the same Micro Four Thirds (MFT) advantage. The main lens on my Olympus camera is a Panasonic 25mm f1.4. So not only can you use either brand on any MFT camera, but they've been doing mirrorless the longest, resulting in a much bigger list of available lenses in the mirrorless category.


Some solid large sensor compacts:
  • Panasonic LX7 - excellent low light capability, due to the larger than average sensor (1/1.7") and brightest lens in this category (F1.4-2.3).
  • Olympus XZ-1 - Good low light from 1/1.7" sensor, and F1.8-2.5 lens.
  • Canon powershot G15 - Large compact, but good quality. 1/1.7" sensor and F1.8-2.8 lens. Loads of options, especially with CHDK - canon hack development kit.
  • Sony RX100 - doesn't get much better. 1" sensor and F1.8-4.9 lens great image quality, but this is a pricey option, easily costing as much as a cheap older DSLR + lens.
  • Pentax MX-1 - decent camera, fast lens, large sensor - you get the gist.




So in summary!
  • If you're not going to buy a better lens, go with Large Sensor compact cameras.
  • Looking through a viewfinder to compose shots can be restrictive on movement.
  • Mirrorless cameras use the rear LCD normally to compose and can be quite comfortable to use this way.
  • DSLR advantages over mirrorless are mostly in how they track moving subjects. No lag, AF sensors provide better Continuous AF (usually).
  • Most of what you notice with good pictures is the result of a bigger better sensor and good lens (faster aperture, sharper).


Hope this helps!

Saturday, October 26, 2013

Cheap awesome camera - the EPL1 with manual lens.

The EPL1 was the first cheap micro four-thirds camera from Olympus. At the time, the sensor wasn't new - It was in the e620 DSLR before it, however it was in a much smaller form factor, and decently priced (~$550). I sold my 25mm Leica for the e620 to buy this camera and the 20mm F1.7. While the 25mm four-thirds Leica was a better lens, the e620 did not focus with it that well. I ended up using CDAF focusing in low light, since while slow, it would still focus when regular PDAF would give up.

What the EPL1 gave me, wasn't just a smaller formfactor - but a camera mount that because of the low flange distance, would be able to adapt nearly any other camera's lenses. As a result I've a stash of canon-fd, Nikon-F, Contax Yashica, Konica and c-mount lenses.

Today, the EPL1 can be found for $100 in decent condition. In addition to being able to take cheap old lenses, it can also project it's flash upwards for a nice soft bounce effect. The result is a cheap camera, capable of using cheap manual lenses, and adding light to a subject through bounce.

This isn't going to be an ISO test - there's too many done. Every major EPL1 review would have done that, so instead, here's how you can get nicely lit pictures with a very cheap camera, using the "free" indirect flash bounce. Note the color, the Exposure, and the details - the lens was used at F2, so pretty wide. The toughest part of using a manual lens, is focusing. Learning to focus is crucial, but not too difficult.




Here's a closeup showing details. You can see the hair's around the horse's eye, the stiches around the zipper and the grain of the wood on the car. Note, the wheel is behind focus, the bumper is in the plane.





Here's how the camera looks with the Canon 50mm F1.4 FD. Looks are subjective, but I think it's pretty decent looking ;)

Here's the spring loaded flash being pulled back. This is all that's needed to bounce the flash off the ceiling and get a nice soft diffused lighting on the subject.


EPL1 - $100 used (keh, ebay)
50mm F1.4 - $50 (keh, ebay)
adapter FD-m43 - $20 (Amazon.com)
---------------------
$170 - make it $200 in case you can't find a good deal on the camera, or need batteries/charger after.

Of course you're also getting fair ISO 1600 capability with F1.4 so it's also decent without the flash, and shoots 720p Video. This camera was used in the Coke commercial "One bottle for all" chosen for it's weight, and "good enough" HD video. Link below.
http://vimeo.com/20834329

Friday, October 4, 2013

Going cheap with interchangable lens cameras

We're all spoiled today. These days we want the newest fastest and best - but if you're not using features that make the "best" what it is, then it's possible a better option (your personal 'best') was not taken.

Looking at cameras - and by cameras, I'm referring to interchangeable lens cameras - There's a myriad of options old and new, and quite often we neglect other choices because of brand ignorance, plain ignorance, ageism, and a complete misunderstanding of what the hell our needs are.

First off - buying used cameras will generally give you a better return on your investment. Camera tech isn't jumping by leaps and bounds normally each generation. Also, old higher end stuff is pretty damn robust still.

Lets say you want a camera with great quality, and can take a brutal amount of punishment. most start looking at the pro range, and would focus on the Canon 1DX, or Nikon D4 which are current flagships of the professional DSLR duopoly. Whoa, now we're at $5k-$6k and no lenses yet - slow down! What's the purpose? A Pentax K30 can handle crap weather and take a fair beating, and the Olympus E-5 is a tank that would survive a dunking and their EM5 is also weather resistant. Now granted, their image quality chops to compare against a D4 and 1DX would pale, but I'd imagine saving several thousand dollars is important if the level of image quality they deliver meets your needs. Even then, older cameras may suffice - e.g. 1Ds III.


Lots of people want to take pictures of their kids. What they don't understand is they want the impossible. They'll buy the newest general consumer level DSLR, not invest time to learn anything or in any lenses and expect to be called a photographer. I have news for you buddy. http://youarenotaphotographer.com/
There's little point to an Interchangeable lens camera if you don't change from the dinky, dark kit lenses that come standard, and don't take the time to learn even the basics.


If you're shooting indoors, even F2.8 zooms can be slow. You're going to want to move to primes (generally) if you need speed. Olympus SLR users have had some F2.0 zooms available to them (which still won be fast enough for the weak old 12MP sensor they're stuck with at the moment) and Sigma just released the a-bomb of lenses, a F1.8 zoom for APS-C. For the most part though, going with cheap primes can get you better quality photos, cost less and be lighter. It may require you moving around and adjusting your position more, but there's a bit of truth to the statement that primes make you think about your composition more.

If you're indoors, you should be using a flash. $60 can get you a Yongnuo yn-560 ii manual flash. That's a hell of a lot cheaper than buying a higher end camera and lenses. Also the bright burst of light is far more likely to give you a sharp freeze of the kid you're trying to shoot. Manual flash settings of the Yongnuo means you select the power manually - but this is a good thing as well. the consistent output leads to the same brightness of pictures. Bouncing the flash off a wall or ceiling with give wonderful soft lighting.

So how cheap can we get here? Keh.com has a Canon T1i (15mp) body for $275. It's not new, but that sensor is still decent. A Nikon D90 can be had for about $400 and will deliver better high iso and is also rather sturdy. For lenses, the canon nifty 50 - the 50mm F1.8 can be bought (used) for under $100. That's about as good as it gets for lens deals. For crop sensors, team it with the 28mm F1.8 (~$350 used). Add the $60 flash, and you've spent $785, have two lenses delivering decent quality, better depth of field control than the F2.8 zoom guys, and much much better low light shots.

Ok, how cheap can we go for a fair indoor studio-ish looking pictures setup? REALLY...
- $110 : used epl1
- $50 : 50mm f1.4 (FD, F, M42 mount - manual focus)
- $20 : adapter for above lens
- $40 : Neewer 560 (Yongnuo ODM?)
- $120 : C22525KP - pentax 25mm f1.4 C mount
- $20 : adapter for the c mount

The 50 becomes an effective 100mm lens in this, setup. The 25mm a 50, and a poor one - but use it for it's character. Total spent $360. If all you're doing is portraits, you can just with with the 50mm (100mm effective) and that's just $220 for the setup.

Cheap wide lens for Micro fourthirds cameras would be the kit lens (14-42mm) + wide angle adapter (WCON-P01). I had the kit lens, and got a used adapter for $60. It generally sells for $100, but look for used or combo deals. First hit on ebay right now is a kit lens with this wide angle adapter and a macro adapter for $130. Getting this instead of the 25mm lens above would have you spending $330.

While the epl1 sensor is weak, and past ISO800 can lead to noise, it is workable. It responds very well to flash input and can produce gorgeous pictures.

My favorite bargain is the old 5D classic. it's $500-$600 used, built like a tank, and full frame. You will be able to swap out the focusing screen to better use manual focus lenses, and since it's full frame, it will give amazing depth of field. It's usable all the way up to ISO 3200, though it's better to stick to 1600 and under.

I bought a 55mm F1.2 FD lens and replaced the back with an ED Mika brass adapter to let me mount it. Because the mirror will hit the lens on swinging up, I had to grind down the mirror a bit on the 5d. My favorite pics have been taken with this camera. Of note is I get sharper pics with the micro four thirds when I'm shooting wide open, but saving (i.e. fixing) poorly exposed pictures from the 5d is much easier. The sensor just has way more headroom than my EP3.

More to come later - sample pics and doctoring lenses...

Update:
Option 1 : EPL1 + manual 50mm

Friday, September 6, 2013

Euler 3 continued:

Here's the code for Euler 3 in Python (written in 2.7)

Runs quicker than i was expecting. For a large prime like "600851475143987", it completes it's run in under 10 seconds on my ancient core 2 duo work machine.

Since the number is prime, the list of prime factors is just itself.
[600851475143987L]
9.84399986267 seconds...


An unoptimized version that doesn't employ that bit of array arithmetic (2*index+1=possible prime factor) takes about 15 seconds, so it looks quirky, but these optimizations count!


unoptimized prime factor was:

def lowestprimefactor_bysieve(number):
    sieve=[0]*int(round(1+pow(number,0.5)))
    init=2
    k=2
    sieve[k]=2
    while (k < len(sieve)):
        if (sieve[k]!=1):
            sieve[k]=2 #number is prime
            if ((number%k==0)):
                return int(k)
            for idx in xrange(k,len(sieve),k):
                sieve[idx]=1 #mark as a being a factor
        if k>2:
            k+=2
        else:
            k+=1
    return int(number)



Here's the full code:


import sys
import time

def lowestprimefactor_bysieve(number):
    sieve=[0]*int(round(1+pow(number,0.5)/2))
    init=2
    if (number%2==0):
        return 2
    k=1
    sieve[k]=2
    while (k < len(sieve)):
        if (sieve[k]!=1):
            realvalue=k*2+1
            sieve[k]=2 #number is prime
            if ((number%realvalue==0)):
                return int(realvalue)
            for idx in xrange(k,len(sieve),realvalue):
                sieve[idx]=1 #mark as a being a factor
        k+=1
    return int(number)

def primefactorlist_sieve(number):
    lfac=lowestprimefactor_bysieve(number)
    if lfac==number:
        return [lfac]
    return [lfac]+primefactorlist_sieve(number//lfac)


def main():
    #What is the largest prime factor of the number 600851475143 ?
    number=600851475143
    start = time.time()
    print(primefactorlist_sieve(number))
    print(time.time() - start)

if __name__ == '__main__':
    main()

Euler 3 - prime numbers

http://projecteuler.net/problem=3

Hi all, here's where the projects start requiring some thought, and often some research.

What is the largest prime factor of the number 600851475143?



Here's the gist.
it's easier to find the lowest prime factor, divide the number by it, and repeat.

e.g. if a number X is the product of prime factors A x B x C
Then, if the lowest prime factor is A, you now have X/A = B x C
Repeat finding the lowest prime factor of X/A and you'll get B.
Now you have to find the lowest prime factor is (X/A)/B.

X=AxBxC
X/A=(A/A)xBxC
(X/A)/B=(A/A)x(B/B)xC
(X/A)/B =C <= the largest prime factor.

So, how do you find a prime factor? well, for starters, it's a prime number.
We start by looking through a list of numbers - 2, 3, 5, 7, 11, 13, 17 etc.. to see if X is divisible by any.

Lets start by setting boundaries - how high should we count?

If we want the prime factors of 91 (i.e. 7x13).
We wont get past 7 before dividing.  i.e. we'll count up to the lowest prime factor. 

AxB=C. 

If A gets bigger, B must get smaller. So we'll iterate up to B and then divide according to the algorithm. The maximum iterations will then be when A=B and this is the square root of C.

The largest prime factor will be the number itself - i.e. it is prime. Well, how do we know? Once again, we only need to count up to the square root.
e.g. what's the prime factors of 31?
we'll check, 2, 3, 5, 7- we've went past the square root and stop here. Why? Well, since we've past the square root, the other number must be smaller - and if prime would have been counted already! 31/7 ~ 4.43. We've already checked smaller primes, so we know they aren't going to divide it.

The checks look like this:
AxB=C
2x31/2=31...2x15.50=31...A=2, B=15.5
3x31/3=31...3x10.33=31...A=3, B=10.33
5x31/5=31...5x 6.20=31...A=5, B=6.2
7x31/5=31...7x 4.43=31...A=7, B=4.43

So stop checking. Increasing A just makes B cover the number range we already went through, so the number is prime.

So - iterate over primes to find the first prime factor, range of primes from 2 to the square root of the number.

Great - how do you know what IS prime anyway? You're testing primes only right? why not test 4 or 9 and see if out number is divisible by that?

Well, here's where we create an array to keep in mind what's prime or not.
e.g. 
Lets say we wanted to know the prime factors of 221. The Square root is ~14.9, so we only need to check up to there.

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Prime numbers and the number 2, are odd. So do a check for 2, then iterate over the odds. no point spending half your time checking even numbers. if it's not divisible by 2, then it's not divisible by any even number.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
00 xx 00 00 00 00 00 00 00 00 00 00 00 00 00

Now check 3. It's not divisible by 3, so mark off every multiple of 3 as not a factor.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
00 xx xx 00 00 xx 00 00 xx 00 00 xx 00 00 xx
See what happened? Now I didn't mark off evens before since there's no point of bothering to check

Last check was 3. Add 2, and check 5 - was 5 marked? No? ok! 5 is not a factor, we lose 5 and 10.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
00 xx xx 00 xx xx 00 00 xx xx 00 xx 00 00 xx

7 Isn't a factor, so we mark out 7 and 14.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
00 xx xx 00 xx xx xx 00 xx xx 00 xx 00 xx xx


Next odd number is 9 but that's marked. so skip it. next odd number is 11.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
00 xx xx 00 xx xx xx 00 xx xx xx xx 00 xx xx


Not a factor.  Next is 13 - that's a factor!

Factors are 13 + the factors of 221/13 - which means it's 13 and factors of 17. We'd do the same check on 17 as illustrated above and return no prime factor found (meaning the number itself is prime).


Now optimizations. We can check 2 initially, and there's no need to store even number flags if they're not being checked.

So our array can be half the size.
00 01 02 03 04 05 06 07 08 ==>N
03 05 07 09 11 13 15 17 19 ==>2N+3

If we're looking at a possible prime factor in the array - say 11, it corresponds to (11-3)/2 = 4 in the index for the flag.

So we're only counting up to the square root of a number, and we're skipping every even number to look for a factor.

Wednesday, August 21, 2013

Euler #1 and #2

This is a simple solution to the first Euler problem
http://projecteuler.net/problem=1


import sys
import time
sum=0
for a in range (3,10):
    if ((a%3==0) or (a%5==0)):
        sum+=a



This is a simple script that should be simple to understand.
import is python's means of accessing functions in external files.

The for loop structure in python is a bit different compared to Basic or C/Java. Range(0,n) makes a list of numbers from 0 to n-1. i.e. n is not included.
For a in <list> will iterate through the list, and the variable "a" will represent each element in that iteration.

Here's my solution to Euler 2:
http://projecteuler.net/problem=2



#By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
import sys
import time

num1=1
num2=2
sum=0

while num1<4000000:
    if (not num1%2) and num1 < 4000000:
        sum+=num1
    if (not num2%2) and num2 < 4000000:
        sum+=num2
    num1+=num2
    num2+=num1
print sum


This is another fairly basic algorithm. No need to worry about memory and fairly simple checks. Fibonacci explodes fairly quickly so the number of iterations here is low - under 20.

That's all for now. Both quite simple. Problem 3 gets much more interesting.