img_bg = im2double(imread('hud_off.png'));

for i = 1:30
    [img, ~, a] = imread(sprintf('hud_%d.png', i));
    img = im2double(img);
    a = im2double(a);
    
    fprintf('Blending image %d\n', i);
    for y = 1:size(img, 1)
        for x = 1:size(img, 2)
            %img_bg(y, x, :) = img(y, x, :) + (1 - a(y, x)) * img_bg(y, x, :);
            img_bg(y, x, :) = img(y, x, :) + img_bg(y, x, :);
        end
    end
end

imshow(img_bg);
imwrite(img_bg, 'bg.png');