load('Cell_Info.mat')
load('CampusMap.mat')
load('IndoorMask.mat')
% figure
% image(CampusMap.cdata)
% colormap(CampusMap.colormap)
% axis equal;
% axis xy;
% axis([450,1200,200,800])
% colorbar
%
% imagesc(Cell_Info_A.ReceivedPowerMap);
% axis equal;
% axis xy;
% colorbar;

BinaryMask=zeros(size(IndoorMask.cdata));
BinaryMask(find(IndoorMask.cdata~=0))=30;

ChangeCoordsAy=[];
ChangeCoordsAx=[];
ChangeCoordsBy=[];
ChangeCoordsBx=[];
ChangeCoordsCy=[];
ChangeCoordsCx=[];
ChangeCoordsDy=[];
ChangeCoordsDx=[];

for x=1:203
    y=x;
        newcoords=ChangeCoords(Cell_Info_A,y,x);
        ChangeCoordsAy(y)=newcoords(1)+12;
        ChangeCoordsAx(x)=newcoords(2)-12;

        newcoords=ChangeCoords(Cell_Info_B,y,x);
        ChangeCoordsBy(y)=newcoords(1);
        ChangeCoordsBx(x)=newcoords(2);  
         
        newcoords=ChangeCoords(Cell_Info_C,y,x);
        ChangeCoordsCy(y)=newcoords(1)+12;
        ChangeCoordsCx(x)=newcoords(2)-12;
        
        newcoords=ChangeCoords(Cell_Info_D,y,x);
        ChangeCoordsDy(y)=newcoords(1)+12;
        ChangeCoordsDx(x)=newcoords(2)-12;
end


fitReceivedMap=BinaryMask;
for x=1:203
    for y=1:203
        if Cell_Info_E.ReceivedPowerMap(y,x)~=0
            for dx=-2:2
                for dy=-2:2
                    fitReceivedMap(ChangeCoordsAy(y)+dy,ChangeCoordsAx(x)+dx)=Cell_Info_E.ReceivedPowerMap(y,x);
                end
            end
        end
    end
end
for dx=-4:4
    for dy=-4:4
        fitReceivedMap(ChangeCoordsAy(101)+dy,ChangeCoordsAx(101)+dx)=40;
    end
end
figure
imagesc(fitReceivedMap)
axis xy
axis equal
colorbar

title('Received Power from Antenna E')
xlabel(['East/West direction (1 pixel=',num2str(ScaleHor/10),' m)'])
ylabel(['North/South direction (1 pixel=',num2str(ScaleVer/10),' m)'])
axis([450,1200,200,800])
%colormap(CampusMap.colormap)