1x3 "column binning" vs 3x1 "line skipping" vs 3x3 binning/skipping

Let's try a simulation of these LiveView binning modes.

In [1]:
%%shell
wget -c -q http://a1ex.magiclantern.fm/bleeding-edge/lv-binning/stedda-1080p/19020007.DNG
In [2]:
# read the image and crop some interesting area
pkg load image
a = read_raw('19020007.DNG');
a = a(end/2:end, end/2:end);
a = a(:, round(end/4):round(end*3/4));
In [3]:
% showing the red Bayer channel only, to keep things simple
imshow(a(1:2:end, 1:2:end),[])
In [4]:
# 1x3 column binning simulation
# (showing the red Bayer channel only)
bin1x3 = imfilter(a, [1 0 1 0 1] / 3)(:, 3:3:end);
imshow(bin1x3(1:2:end,1:2:end), [])
In [5]:
# 3x1 line skipping simulation
# (showing the red Bayer channel only)
skip3x1 = a(3:3:end, :);
imshow(skip3x1(1:2:end,1:2:end), [])
In [6]:
# 3x3 line skipping simulation, i.e. what most Canon DIGIC 4/5 DSLRs do
# (showing the red Bayer channel only)
lineskip3x3 = imfilter(a, [1 0 1 0 1] / 3)(3:3:end, 3:3:end);
imshow(lineskip3x3(1:2:end,1:2:end), [])
In [7]:
# 3x3 binning simulation, i.e. what what 5D3 does
# (showing the red Bayer channel only)
bin3x3 = imfilter(a, [1 0 1 0 1;
                      0 0 0 0 0;
                      1 0 1 0 1;
                      0 0 0 0 0;
                      1 0 1 0 1] / 9)(3:3:end, 3:3:end);
imshow(bin3x3(1:2:end,1:2:end), [])
In [8]:
# function to render the above Bayer images with dcraw
function im = render(bayer)
  imwrite(uint16(bayer), "test.pgm");
  # pgm2dng: http://a1ex.magiclantern.fm/bleeding-edge/pgm2dng.c
  # note: pgm2dng hardcodes a black level of 2048 and a white level of 16382
  system("pgm2dng test.pgm > /dev/null");
  system("dcraw -a test.DNG");
  im = im2double(imread('test.ppm'));
end
In [9]:
# render our test images
a_r = render(a);
bin1x3_r = render(bin1x3);
skip3x1_r = render(skip3x1);
lineskip3x3_r = render(lineskip3x3);
bin3x3_r = render(bin3x3);
In [10]:
# original (1:1 readout)
imshow(a_r)