Category Archives: Photography

Turn off VR when using a tripod

I have found that (when using my Nikon Coolpix P7000) pictures get sharper when I turn off VR (Vibration Reduction), for long exposure times and when using a tripod.

orchide-2

orchide-1

Both pictures are 10 seconds, f/5.6, ISO 100, 200mm with my Nikon P7000. The orchide is lit up only by a candle. The left one is the sharpest of three attempts, with VR turned on. The right one is the first attempt with VR turned off. Obviously a tripod was used.

Photographing a model backdrop

I decided my model train layout (Märklin Z) needed proper background image (a backdrop). If you google for it, you find many nice backdrops for sale. Those are probably fantastic, but I did not find one that works for me.

I will start with the result.

Backdrop

This is a panorama that is 180×15 cm, and most standard backdrops I found were not so extreme panoramas as I wanted. Also, when making it myself I could get the landscape I wanted.

Photographing
This is what you need:

  1. A location with unobstructed view over the horizon
  2. Good weather conditions, preferably the sun in your back
  3. A tripod

And of course, you need a camera. I made use of the following features of my Nikon P7000 when photographing my panorama.

  1. RAW mode (to ensure white balance etc are identical for all pictures)
  2. Delayed shutter or remote shutter (to keep camera absolutely still)
  3. Manual mode (you want the same shutter speed and aperture for each picture
  4. Grid 3×3 (to help with proper overlap
  5. Horizontal indicator (to help getting the horizon straight
  6. 200 mm equivalent zoom (to be able to take several pictures at a limited horizon stretch)

I only rotated the camera using the tripod between each picture, keeping the horizon exactly in the middle of the pictures, and I let the pictures overlap 1/3.

Essentially, the math goes like this. I wanted at least about 150-200 dpi for my final print of 180 cm. This requires a picture that is about 15000 pixels wide. Ideally I would use a camera with 15000×10000 pixel sensor (that is 150MPixels) and just crop the picture. I have no such camera, but my Nikon P7000 is about 3600 pixels wide. With an overlap of 1/3, it means each picture contributes with only 2400 pixels, so I need a series of about 6 pictures to get a 15000 pixels wide result. Now this is where telezoom comes into play. At 200mm, each picture is about 10 degrees. The more telezoom you can get, the shorter horizon you can work with.

Dont overexpose! You want the sky blue – not white. If you have UV filters and stuff – great. But I suggest you underexpose a bit.

Panorama stiching
I used Ubuntu and tools that come with it to create my panorama.

First I imported all my series into Shotwell. That means, I let Shotwell do the RAW developing, which turned out ok (all pictures had the same white balance, etc) – perhaps I was just lucky. I picked my best series, and exported all pictures from that series at highest quality.

Second, I used Hugin Panorama Creator to create the actual panorama. I choose Lens Type = Panoramic (Cylindrical). This is a lie (and at 200mm it is a small lie), but it created the completely straight horizon I wanted.

Finally, I did some cropping and color adjustments in Gimp.

Printing
How to print something that is 180×15 cm? My first idea was to print several standard 15×10 cm photos and just display them next to each other. Problem is, you never know if the crop your pictures a little bit, and in this case it would destroy the result completely.

I ended up (in Gimp), cutting my 15000 pixel panorama into 3 pieces (each 60x15cm), and pasting the 3 pieces to a 5600×4000 image. I left white margins around each piece.

I then sent my single big picture to print on standard photo paper in 70x50cm. I cut out the 3 pieces with a razor and mounted them next to each other.

Conclusions
I did not have so high expectations. My plan was to learn from my first attempt and do everything over again a few times. But my first result was really above expectations – and very much good enough for my purpose.

You do not need higher DPI than I had (15000 pixels for 180 cm). You can probably do with less.

I am very happy with my sky (~RGB=135,166,186) and the sea colors (~RGB=32,63,97).

Printing on normal photo paper was good – the result is nice. The edges between them are not perfect though.

Nikon P7000 now supported

The Nikon P7000 camera is now supported by iPhoto. It also works in Shotwell 0.9.0 in Ubuntu 10.10. The NRW Raw files I mean.

Finding a Color Matrix for dcraw (and libraw)

Read this post first for a little background, if you need it.

So, a color matrix in the dcraw code looks like:

   { "NIKON COOLPIX P6000", 0, 0,
        { 9698,-3367,-914,-4706,12584,2368,-837,968,5801 } },

Some cameras have four colors instead of three, and those cameras have a color matrix with twelve elements instead of nine.

As you can read on the homepage of dcraw under “Why does dcraw output have a green tint and weak color?”, the color matrix can be determined (with some procedure) if you (under correct conditions) photograph a sheet with reference colors. Obviously, we have to leave the digital world to do this. As I live in a part of the world where daylight is not very likely to occur for a few months, I decided to try to find my color matrix in another way.

My Strategy
Since I do have a computer with Nikons ViewNX program, I decided to try this strategy:

  1. Take a suitable photograph in RAW
  2. Export it to 16-bit TIFF using ViewNX
  3. Find a color matrix, that makes dcraw output a TIFF file equivalent to that from View NX

There were some challenges to overcome…

Little disclaimer
More things than the color matrix decide the result of dcraw. In particular, white balance (-a -A) and brightness (-W -b) matters a lot to the output. Thus, I have accepted that my color matrix does not produce exactly the same result as Nikons ViewNX.

Picture dimensions
ViewNX (and the camera) says full size is 3648×2736 pixels. But dcraw gives you 3664×2742 pixels. ImageMagick solves this with

  $ convert -crop 3648x2736+8+3 orig.tiff cropped.tiff

Choosing a good picture
I dont know, but I guess a good picture has many different colors in a fair distribution. If one color is missing the color matrix might fail to handle it well. I also (after initial tests) decided I wanted a slighly unsharp picture to avoid high contrasts between adjacent pixels. Pictures are noisy if you look closely at pixel level, and if that noise is the result of the Bayer filter (or something I dont know about) I dont want it to disturb my tests. I even decided to blur my picture (both reference and target of course) using ImageMagick again:

  $ convert -blur 12x4 pic-in.tiff pic-out.tiff

Here is the picture I used (feel free to tell me why it is unsuitable):

It was shot outdoors in something that some people would call daylight.

Deciding if a solution is good
I found a little program that could measure the difference/error between two images:

  $ imgcmp -f pict1.jpg -F pict2.jpg -m pae

If does not support tiff so I had to live with uncompressed 8-bit jpegs.

The mathematical solution
In the end I did what I tried to avoid first – I did the math of calculating a matrix instead of trying to search for it.

This mathematical solution requires a lot more understanding, so I couldnt start there anyway. First two sources: wikipedia on sRGB and a thread from someone who tried the same thing before me.

Now some bad news. RAW file uses 12-14 bits color depth. My NRW-files from my camera are about 15-20Mb. When converted to 16-bit TIFF, they turn 60Mb ( 3 colors X 2 bytes/color X 10Mpix ). Why is the RAW file much smaller? Because each pixel is EITHER red OR green OR blue! In fact 50% are green, 25% red and 25% blue. It is called Bayer Filter, and some cameras use different but similar methods. This line in the dcraw patch fixes this:

    filters = 0x94949494;

This is bad for two reasons:

  1. It feels like marketing bluff that a 10MPix-camera has just 2.5M sensors that read the color blue
  2. The first step dcraw has to perform is interpolation to fix this Bayer Filter, and it is possible (likely) that dcraw doesnt do it exacly the same way Nikon does, and the pictures will never be identical (yet equally good)

Next steps for dcraw are:

  1. apply our Color Matrix
  2. convert from RGB to sRGB
  3. apply gamma

I wanted dcraw to output right after interpolation. So, I invoked dcraw (a version without a color matrix for my camera) like:

  ./dcraw -T -o 0 -W -g 1 1 -c MYFILE.RAW > source.tiff

I cropped the file, and wrote a little c-program (using libtiff) that extracted a few hundred pixel values, from both this file and the values for the same pixels from the Nikon ViewNX tiff. (Sorry, I gave up on 16-bit tiff… libtiff doesnt support it).

Now some linear algebra (skip to the code below if you dont get this). I have those matrices:

  • V: pixel values from the Vendor file
  • R: pixel values from the Raw file (from dcraw)
  • S: the sRGB-to-RGB-matrix
  • C: My unknown color matrix

The values in V and R needs to be divided by 255.0 to move from [0-255] to [0.0-1.0] ranges. The values in V has to be fixed for gamma, so we get linear colors. Now we have

  C x S x V = R

Mathematically, in order to decide C, only three pixel are needed. I want more pixles. I tried with 9 selected and 200 “random”, and I got exactly the same answer. If we remember some linear algrebra from school and solve the equation for C, we get:

  C = ( inv( (SV)*(SV)' ) * SV * R' )'

Maybe it can be simplified, and the inverse does not need to be calculated… but I dont care now. I put everything into a little script for Scilab (Matlab for the poor – available as a package in all linux distros I have tried).

VENDOR=[
 215 230 254 ;
 223 176 101 ;
 236 140  98 ;
 247  68 107 ;
 168  87 156 ;
 106  94 165 ;
 100 200 254 ;
  63 171 140 ;
 124 188 126 ];

SOURCE=[
 88 168 98 ;
 70  78 19 ;
 68  57 16 ;
 63  35 13 ;
 31  29 20 ;
 15  26 20 ;
 26  95 74 ;
 14  54 21 ;
 28  69 22 ];


// Maybe change this one
gammaval=2.2;


// Dont edit below

// sRGB-to-RGB-matrix 
S=[
 0.412453 0.357580 0.180423 ; 
 0.212671 0.715160 0.072169;
 0.019334 0.119193 0.950227 ];

function x=srgb_gamma(y)
  rc=size(y)
  for r = 1:rc(1)
    for c = 1:rc(2)
      z = y(r,c)
      if z <= 0.04045
        x(r,c) = z / 12.92
      else
        x(r,c) = ( ( z + 0.055 ) / 1.055 ) ^ gammaval
      end
    end
  end
endfunction

function CM=find_color_matrix()
  // first move from 0-255 to 0.0-1.0 ranges, and transpose
  Vtmp=(VENDOR./255.0)'
  R=(SOURCE./255.0)'

  // second, undo gamma in vendor colors
  V=srgb_gamma(Vtmp)

  SV=S*V

  // Solve for CM, in  CM*S*N=R
  CMtmp=( inv( (SV)*(SV)' ) * SV * R' )'
  // dont talk to me about costs of inverting 3x3 matrices

  // fix output for dcraw
  CM=round(10000 .* CMtmp)
endfunction

Now, just update VENDOR and SOURCE with your values, and call find_color_matrix(). In Scilab!

Search!
My first idea was to search for a matrix. Basically:

  1. Set a start matrix, calculate fitness
  2. Take a "step", obtain a new matrix, calculate new fitness
  3. If new is better, update best
  4. Goto 2

My plan was to iterate until the error was small (like Peak Absolute Error < 2 for each color). That didnt happen. No really close solutions. I tried linear combinations of the 200+ matrices already in dcraw. I tried random steps, steps in one or several directions.

Issue at ISO400+ with my dcraw-patch for Nikon Coolpix P7000

As I wrote earlier I patched dcraw to work with my Nikon Coolpix P7000. However, there seems to be some problems at ISO400 and above.

I made the same shot twice from a tripod, with the same settings (f/4.0, 1/30s). In the first case I used ISO100 and flash=1/4. In the second shot I used ISO400 and flash=1/16.

How to read it:

  • to the left: ISO100, developed from dcraw
  • to the right: ISO400, developed from dcraw
  • middle column: JPG from the camera ; if you look closely ISO100 in the left half and ISO400 in the right part
  • top row: dcraw with no processing switches activated
  • bottom row: dcraw called with -W, will not auto-bright the picture

So, after first concluding that brightness is tricky (but can be fixed/adjusted with the -b switch), lets look in the right column at those ISO400 pictures. Obviously they are too pink, and they also have a kind of foggy layer over them (I think).

Now, dcraw has a switch for “darkness” (-k). Have a look at the pictures below. I shot six raw pictures at ISO 100, 200, 400, 800, 1600 and 3200 (from top to bottom). I developed each picture four times with dcraw at darkness values 0, 128, 256 and 512 (from left to right).

As I see it, the right darkness value depends on the ISO value as in:

  ISO   Darkness
  100   0
  200   0
  400   256
  800   256
 1600   256
 3200   256

I need to think about an elegant patch for dcraw.
My patch for dcraw now fixes this problem as well.

Add Camera Support (Nikon P7000) to dcraw (and libraw)

I bought a Nikon Coolpix P7000 a while ago. One reason for choosing that model was that it can produce RAW images. Well, only Nikons ViewNX software supports it. No luck with iPhoto, no luck under Linux. So I decided to see what I could do myself and started checking out the source of dcraw. The author was very helpful but couldnt provide a “color matrix” (without the camera, or a particular picture taken with the camera). Now I have calculated a reasonably good color matrix myself.

A few notes:

  1. Determining a color matrix is tricky, and not a completely objective business. Please see this separate post about finding the color matrix, in case you dont trust it or like it.
  2. A little trick was needed for ISO400 and above, please see separate post
  3. The patch is not written for libraw, but with little skills you will be able to apply it to the file interal/dcraw_common.cpp in libraw sources

The effect of the patch is displayed by these pictures:

  • Upper left: no patch applied
  • Upper right: patch with no color matrix
  • Lower left: full patch, with my color matrix
  • Lower right: picture as camera exports it to JPG

Well, some brightness and auto-white-balance (-b 1.4 -a) and we have:

Maybe an even better color matrix can be found, but right now I feel that the ISO400 problem mentioned above is more important.

Now the dcraw patch (for version 9.04):

*** dcraw.c	2010-11-09 17:17:22.162772794 +0100
--- dcraw-new2.c	2010-11-14 18:41:24.802772823 +0100
***************
*** 6367,6372 ****
--- 6367,6374 ----
  	{ 7971,-2314,-913,-8451,15762,2894,-1442,1520,7610 } },
      { "NIKON COOLPIX P6000", 0, 0,
  	{ 9698,-3367,-914,-4706,12584,2368,-837,968,5801 } },
+     { "NIKON COOLPIX P7000", 0, 0,
+ 	{ 7177, -1363, -1257, -1529, 7422, 839, -795, 1563, 2398 } },
      { "OLYMPUS C5050", 0, 0,
  	{ 10508,-3124,-1273,-6079,14294,1901,-1653,2306,6237 } },
      { "OLYMPUS C5060", 0, 0,
***************
*** 7248,7253 ****
--- 7250,7261 ----
    } else if (!strcmp(model,"COOLPIX P6000")) {
      load_flags = 24;
      filters = 0x94949494;
+   } else if (!strcmp(model,"COOLPIX P7000")) {
+     load_flags = 24;
+     filters = 0x94949494;
+     if (iso_speed >= 400) {
+       black = 256;
+     }
    } else if (fsize == 1581060) {
      height = 963;
      width = 1287;

Testing Macro capacity of Nikon P7000

I bought a Nikon P7000 compact camera a little while ago (the Canon 450D belongs to my girlfriend, and sometimes I cant borrow it). I was a little curious how it performs in macro photography. So, again, I photographed my little train. First the full shot:

Nikon P7000@6mm, 5s, f/5.6

Not so bad. The barrel distortion is clearly visible. This picture is taken from about 2cm distance from the object, with the lens at its widest setting. As I zoom in, minimum focus distance quickly increases, and the widest mode gives the largest magnification of the object.

Now the crop of the details (the object is about 6.5 mm wide in real life):

Nikon P7000@6mm, 5s, f/5.6, crop

So, it is very possible to read those little characters on the train. Comparing with the other two Macro tests I have made in the past, I draw the following conclusions:

  1. Nikon P7000 beats Canon 450D with 18-55mm kit lens
  2. If Macro Effect filter is applied to the 18-55mm lens, its a draw
  3. The SLR camera wins when equipped with a Macro Extension Tube

Testing a 25mm Extension Tube

A few weeks ago I tested a Macro Effect filter. The results were not that impressive. I decided to spend some more money on an original Canon EF-25 II Extension Tube (the “II” is critical if you have EF-S lenses).

The Extension Tube is simply a 25 mm long piece of metal pipe, that fits perfectly between your camera and your lens. You can get cheap ones (that doesn’t have electrical connectors) or expensive ones. They have no glass anyway.

Moving the lens away from the camera (sensor) has two effects:

  1. it crops the picture, making objects larger
  2. it changes the shortest possible distance usable for the lens

It is the second effect is the crazy cool one. For my two EF-S lenses, and my fixed 50mm EF lens, this is the effect:

   Lens        Original Range               New Range (roughly)
   18-55 mm     25 cm - infinity             0 cm - 20 cm
   55-250 mm   110 cm - infinity            15 cm - 400 cm
   50 mm        45 cm - infinity            10 cm - 15 cm

So, I can get really close to the object. However, it is now impossible to focus on anything far away. There is of course some math, some science, and some theory about this, but I dont really know much about it.

With the extension tube on, zooming does not really work as expected. Instead, the zoom decides the rough focus distance. So, for the tele lens, at 55 mm I can focus on things roughly 15 cm away. As I zoom in towards 250 mm, the focus distance increases to 4 meters. The size of the object in the lens is somewhat constant, since I move away from the target at the same time as I zoom in more and more. The focus ring can be used to fine-adjust focus, but if the zoom is not fairly correct, you can never get focus. With some luck, auto focus works.

Train revisited
Of course I started photographing the same train as I did with the Macro Effect filter. RAW mode used, picture exported to JPEG with iPhoto.

18-55@44, 2.5 sec (ISO800), ~15 cm from object

As I see it, the picture is much better than what was achieved with the cheap Macro Effect lens. Especially, the picture is sharp not just in the middle. Lets look at a crop:

Crop of text details

As I see it, this crop of the center of the picture is slightly sharper than with the Macro Effect filter.

Finally, something more artistic.

18-55@36, f/9.0, 1.6s, ISO100

Even if this is at 36 mm, I cant get much closer, because the object hits the lens. Not possible to go all the way down to 18 mm.

18-55@53, f/9.0, 5s, ISO100

Would I recommend anyone to pay almost EUR 150 for this thing? Well, it is small, and it turns your 18-55 kit lens into a macro lens. The result is much better than a cheap filter. Perhaps for the 18-55 lens it is better to get the 12 mm extension tube…

For more nice macro photos, try this page.

Testing a Macro-Effect lens filter

Cheap stuff that works is always cool! I ordered a “Macro Effect” lens filter from DealExtreme. What kind of Macro Photography can you do for $8.99?

I decided I wanted to photograph one of my Z-scale (1:220) Märklin steam engines. My objective: to find out what the printing on the side of the train is. When you look at the pictures below, remember that the whole train is about 80mm long.

Equipment:

All pictures are taken with Aperture F=10, ISO 100. Exposure times decided by the camera. RAW format was used but the pictures below are made JPEG-crappy with iPhoto.

Without Macro Effect filter
First are two pictures taken without the Macro Effect lens filter. These pictures are taken at roughly the shortest possible distance, using a suitable focal length.

55-250@163, 2 sec, ~110 cm from object



18-55@45, 2 sec, ~25 cm from object



I decided the pictures to be of roughly the same quality and I made a crop of the second one that shows the center part of the picture in native resolution (one RAW pixel corresponds to one JPEG pixel):

18-55@45, 2s, crop of details



This is the “macro capability” of the standard kit-lens. Not that crappy. However, I cant read those printings on the train. Note that the DB-logotype is 2 mm long, so the letters are really really tiny.

With Macro Effect filter
Now follows four pictures using the Macro Effect lens filter. Note that these pictures are taken from 10-20 cm away from the lens. Focal depth is extremely short (a few millimeters). If possible, it is easier to focus by moving the object rather than moving the focus wheel. Now the pictures:

55-250@250, 2.5 sec



55-250@135, 6 sec



55-250@70, 6 sec



18-55@55, 4 sec



At 250 mm there is no combination of focus and distance to object that creates a sharp picture. At 135mm there is some sharpness in the middle of the picture. At 70mm it does not look so bad and 55mm is sharp almost to the sides. Not however, that the focal depth is just a few millimeters. I decided to make a crop of the text details of the 55mm picture though:

18-55@55, 4 sec, crop of details



Now the characters are clearly readable! Other people can judge the artistic value of this ;)

Conclusions
The $8.99 Macro-Effect 10x lens filter does have some effect. It does amplify your object, giving you better Macro capability. You can use it with a 18-55mm EFS lens. However, with a 55-250mm lens things do not get sharp in most of the range. The macro limit of your camera gets much shorter with the Macro-Effect lens attached. Photographing without a tripod is very hard. Focal depths get close to 0.

For many purposes, a tripod, a good flash, and digital zoom will probably give you a better result than this Macro-Effect lens filter does.

It would be interesting to try a Macro Extension tube as well to see how it compares.