%% Wish 4: Test script for BatchFaceColorGrad
function OffScreenTest(interactive)
if (~exist('interactive'))
interactive = false;
end
%load('TestData/Buddha1Data.mat');
%load('TestData/buddha_nice.mat');
cd('TestData');
load('buddha11hull022.mat');
loadbuddhaimagecam;
cd('..');
channelModFactor = 4;
zoomFactor = 2;
[FaceColorT, FaceVisibleM] = BatchFaceColorGrad(FM, VM, CamParamStructA, [480; 640], zoomFactor, TestImageA, ImageMaskA, channelModFactor, [10;20]);
%LabeledImageA = BatchFaceColorGrad(FM, VM, CamParamStructA, [480; 640], zoomFactor, TestImageA, ImageMaskA, channelModFactor, [10;20]);
%LabeledImageA = ProjectMesh2Image(FM, VM, CamParamStructA, channelModFactor, [480; 640], zoomFactor, [10;20]);
%keyboard;
%% try to draw the vertex with colors
figure;
pat = patch('faces', FM, 'vertices', VM, 'FaceVertexCData', FaceColorT(:, :, 1), 'FaceColor', 'flat', 'EdgeColor', 'none');
colormap(gray);
view(3);
title('Color image projected onto the mesh');
cameratoolbar('show')
cameratoolbar('SetMode', 'orbit', 'SetCoordSys', 'z');
axis equal;
%% try to draw the vertex with colors
figure;
pat = patch('faces', FM, 'vertices', VM, 'FaceVertexCData', FaceVisibleM(:, 1), 'FaceColor', 'flat', 'EdgeColor', 'none');
colormap(gray);
view(3);
title('Visibility map projected onto the mesh');
cameratoolbar('show')
cameratoolbar('SetMode', 'orbit', 'SetCoordSys', 'z');
axis equal;
%% test for rendering an image
ColorImageT = RenderColorMesh(FM, VM, repmat([1 1 1], [size(FM,1), 1]), CamParamStructA{3}, [480; 640], [10; 20], zoomFactor);
%ColorImageT = RenderColorMesh(FM, VM, repmat(FaceColorT(:, :, 1), [1 1 3]), CamParamStructA{3}, [480; 640], [10; 20], zoomFactor);
figure;
imshow(ColorImageT);
if (interactive)
disp('Please check the variables and type continue to exit the program');
keyboard;
end