clc;
clear all;
close all;
    
fileID_Fusion_location_Algorithm = fopen('/media/Novo volume/bags_tese_results/bag_2_possible_pedestrian_positions.txt', 'r');

A_bag_location = fscanf(fileID_Fusion_location_Algorithm,'%f');

fclose('all');


A_bag_location_reshape = reshape(A_bag_location,[3 size(A_bag_location,1)/3])';

x_y_plot = A_bag_location_reshape(:,1:2);
% y_plot = A_bag_location_reshape(:,2)';

map = colormap('jet');

% N = 230000;
N_cor = 100;

map_f = interp1(linspace(0,1,64),map,linspace(0,1,N_cor));

id = A_bag_location_reshape(:,3);
cor = mod(id,N_cor);
% colors = zeros(size(A_bag_location_reshape,1),3);

% pontos = rand(2,N)*10;

figure('Position',[80 80 800 500]);
plot(NaN,NaN);
hold on

% poolobj = parpool;
for i = 1:N_cor
    
    mask = cor == i-1;

    [l] = find(mask);

    pontos_cor = x_y_plot(l,:);

    cor_f = map_f(i,:);

    plot(pontos_cor(:,2),pontos_cor(:,1),'.','color',cor_f,'MarkerSize',4);

end

xlabel('x') % x-axis label
ylabel('y') % y-axis label
axis([-8,8,0,14])
set(gcf, 'color', [1 1 1])
export_fig Atlascar.pdf;

hold off

% for i=1:size(A_bag_location_reshape,1),
% %     hold on
%     id_plot = A_bag_location_reshape(i,3);
% 
%     if mod(id_plot,200)==0
%         id_plot_1 = id_plot + 1;
%     else
%         id_plot_1 = id_plot;
%     end
% 
%     colors(i,:) = map200(mod(id_plot_1,200),:);
%     
%     plot(y_plot(i),x_plot(i),'.','Color', colors(i,:),'MarkerSize',4);
% %     scatter(y_plot(i),x_plot(i),4,colors(i,:));
% %     pause(0.01);
% end

% delete(poolobj)

% show(g)

% plot(y_plot,x_plot,'.','Color', colors,'MarkerSize',3);

