% videoColorMap.m This function plot a colormap for video superimposed to a black/white background image

function [ ] = ambisonicsVideoColorMap( picture, imageWidth, imageHeight, azi, elev, ZI, lowerLimit, upperLimit, ...
                                        plotBG, v, alpha, contourEnable, valueTickEnable, cmap, aziMat, elevMat, ...
                                        tickSize, tickBold, colorbarEnable )

% background image is grey-scale with three channels so it will not be affected by the colormap later on
image( picture, 'XData', [-imageWidth/2, imageWidth/2], 'YData', [-imageHeight/2, +imageHeight/2] ); 
axis off
set( plotBG, 'YDir', 'normal' )                                             % correct image axis
hold on

% compute color map                                                    
fig         = pcolor( azi, elev, ZI );
colormap( cmap )                                                             % define color set
shading interp                                                              % better quality setting for colormap
set( fig, 'facealpha', alpha );                                             % set transparency

caxis( [ lowerLimit upperLimit ] )                                      % set relative limits to Z-axis [dB]

if contourEnable && valueTickEnable
    [ C, ~ ] = contour( aziMat, elevMat, ZI, v , 'k' );                             % compute iso-lines
    if tickBold == 1
        clabel( C, 'FontSize', tickSize, 'FontWeight', 'bold' );
    else
        clabel( C, 'FontSize', tickSize );
    end
elseif contourEnable
    contour( aziMat, elevMat, ZI, v , 'k' );                                        % compute iso-lines
end

if colorbarEnable
    c           = colorbar;
    if tickBold == 1
       c.FontWeight = 'Bold'; 
    end
end

hold off
