Flat frame experiment

Long version - for very dark spots in H.264 clips

Noticed some artifacts in a few H.264 clips recorded with 5D Mark III and 50/1.8 at f/22, crop_rec set to 1:1. Apparently these are caused by dust on the sensor and made obvious at narrow apertures. Here's one frame:

In [1]:
%%shell
ffmpeg -loglevel quiet -hide_banner -i sample.mov -vframes 1 -y sample.ppm
convert sample.ppm sample.jpg # for preview

sample

Luckily, the spot was large enough to be noticed on the camera screen, so I've recorded a short clip with just the blank sky, moving the camera around to average out the clouds.

In [2]:
%%shell
ffmpeg -loglevel quiet -hide_banner -i sky.mov -f image2pipe -vcodec ppm - | convert - -evaluate-sequence mean sky.ppm
convert sky.ppm sky.jpg # for preview

sky

Let's get a flat frame out of this!

In [3]:
sky = double(imread('sky.ppm'));
sr = sky(:,:,1);
sg = sky(:,:,2);
sb = sky(:,:,3);
ref = sky * 0;
ref(:,:,1) = mean(sr(:));
ref(:,:,2) = mean(sg(:));
ref(:,:,3) = mean(sb(:));
flat = sky ./ ref;
imshow(flat / 2)