Commit e25e0890 authored by sarthou's avatar sarthou
Browse files

End working on the new upsample method, no conclusive results, moving to...

End working on the new upsample method, no conclusive results, moving to search/reconstruct divergence
parent b7b038ba
......@@ -39,15 +39,9 @@ void InpaintingConverger::Inpaint(InpaintingDataSource * const iDataSource, Inpa
OnionPeelInitialisation(&downsampledDataSource, iProfiler);
// LoadingInitialisation(&downsampledDataSource,iProfiler);
}
else{
iSearcher->Search(&detailedOcclusionDataSource, false);
// openCVIO.GeneralIOForRGB(downsampledDataSource.GetRed(), \
// downsampledDataSource.GetGreen(), downsampledDataSource.GetBlue(),\
// 32, InpaintingIO::IH_DBG_SAVE,\
// "Data/divergence/CppOutDiv_F32_L" + std::to_string(curLevel)+"_I"+std::to_string(iteration));
residual = iReconstructor->Reconstruct(&detailedOcclusionDataSource, false);
}
iProfiler->AfterInpaintingIteration(curLevel, iteration);
......@@ -56,13 +50,6 @@ void InpaintingConverger::Inpaint(InpaintingDataSource * const iDataSource, Inpa
if(curLevel != 0)
downsampledDataSource.UpsampleShiftMatrices();
for(int i = 0; i < downsampledDataSource.GetDim()->GetSizeZ(); ++i)
openCVIO.GeneralIOForRGB(downsampledDataSource.GetRed(), \
downsampledDataSource.GetGreen(), downsampledDataSource.GetBlue(), i,\
InpaintingIO::IH_DBG_SAVE, "Data/divergence/cpp_divergence/CppOutDiv_L" \
+ std::to_string(curLevel)+"_F"+std::to_string(i));
iProfiler->AfterInpaintingIterations(curLevel);
iProfiler->AfterInpaintLevel(curLevel);
}
......
......@@ -117,7 +117,13 @@ void IDSDDownsampling::MatlabUpsampleShiftMatrix(){
}
}
}
// std::cout << "GridX"<<std::endl;
// GridX->Mprint();
// std::cout << "GridY"<<std::endl;
// GridY->Mprint();
// std::cout << "GridZ"<<std::endl;
// GridZ->Mprint();
PaddedMatrixIt nextVolIt = PaddedMatrixIt(toDim);
do {
toXDispData[nextVolIt.GetPosition()] = downsamplingRate * \
......
......@@ -77,24 +77,25 @@ int main(){
+std::to_string(nbFrame)+".csv",frame_a,1);
downsampledDataSource.GetDispA()->SetFrame(frame_a,nbFrame);
}
downsampledDataSource.GetDispX()->GetFrame(70)->Mprint();
//downsampledDataSource.GetDispX()->GetFrame(70)->Mprint();
downsampledDataSource.MatlabUpsampleShiftMatrix();
// downsampledDataSource.UpsampleShiftMatrices();
downsampledDataSource.SetCurLevel(1);
downsampledDataSource.GetDispX()->GetFrame(70)->Mprint();
/*
//downsampledDataSource.GetDispX()->GetFrame(70)->Mprint();
for(int nbFrame=0;nbFrame < downsampledDataSource.GetDim()->GetSizeZ();nbFrame++)
{
downsampledDataSource.GetDispX()->GetFrame(nbFrame)->MprintToCSV("Data/upsample/test_methodCpp/CppOut_DispX_L1_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispX()->GetFrame(nbFrame)->MprintToCSV("Data/upsample/test_methodCpp/Out_DispX_L1_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispY()->GetFrame(nbFrame)->MprintToCSV("Data/upsample/test_methodCpp/CppOut_DispY_L1_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispY()->GetFrame(nbFrame)->MprintToCSV("Data/upsample/test_methodCpp/Out_DispY_L1_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispZ()->GetFrame(nbFrame)->MprintToCSV("Data/upsample/test_methodCpp/CppOut_DispZ_L1_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispZ()->GetFrame(nbFrame)->MprintToCSV("Data/upsample/test_methodCpp/Out_DispZ_L1_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispA()->GetFrame(nbFrame)->MprintToCSV("Data/upsample/test_methodCpp/CppOut_DispA_L1_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispA()->GetFrame(nbFrame)->MprintToCSV("Data/upsample/test_methodCpp/Out_DispA_L1_F"+std::to_string(nbFrame));
}
*/
std::cout << "End of upsample test"<< std::endl;
// Execute the work
......
......@@ -109,6 +109,25 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin)
%
% cd ../..
write_image_volume(imgVol,strcat('matlab_debug/search_reconstruct/M_SR_Ante_Im_L',int2str(ii)));
cd matlab_debug/search_reconstruct/
[~,w,l,maxFrame] = size(shiftVol);
for nbframe=1:maxFrame
csvwrite(strcat('M_SR_Ante_DispX_',int2str(nbframe-1),'.csv'),reshape(shiftVol(1,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SR_Ante_DispY_',int2str(nbframe-1),'.csv'),reshape(shiftVol(2,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SR_Ante_DispZ_',int2str(nbframe-1),'.csv'),reshape(shiftVol(3,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SR_Ante_DispA_',int2str(nbframe-1),'.csv'),reshape(shiftVol(4,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SR_Ante_GradX_',int2str(nbframe-1),'.csv'),normGradX(:,:,nbframe));
csvwrite(strcat('M_SR_Ante_GradY_',int2str(nbframe-1),'.csv'),normGradY(:,:,nbframe));
end
cd ../..
% ... and recreate image volume.
if (exist('featurePyramid','var'))
[imgVol,gradX,gradY,normGradX,normGradY] = ...
......@@ -135,6 +154,22 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin)
useAllPatches,...
reconstructionType);
end
write_image_volume(imgVol,strcat('matlab_debug/search_reconstruct/M_SR_Post_Im_L',int2str(ii),'_F'));
cd matlab_debug/search_reconstruct/
[~,w,l,maxFrame] = size(shiftVol);
for nbframe=1:maxFrame
csvwrite(strcat('M_SR_Post_DispX_',int2str(nbframe-1),'.csv'),reshape(shiftVol(1,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SR_Post_DispY_',int2str(nbframe-1),'.csv'),reshape(shiftVol(2,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SR_Post_DispZ_',int2str(nbframe-1),'.csv'),reshape(shiftVol(3,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SR_Post_DispA_',int2str(nbframe-1),'.csv'),reshape(shiftVol(4,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SR_Post_GradX_',int2str(nbframe-1),'.csv'),normGradX(:,:,nbframe));
csvwrite(strcat('M_SR_Post_GradY_',int2str(nbframe-1),'.csv'),normGradY(:,:,nbframe));
end
cd ../../
end
% Dilate the occlusion
......@@ -168,14 +203,6 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin)
imgVolCopy = permute(imgVol,[2 3 4 1]);
%size(imgVolCopy(:,:,32,:))
% cd matlab_debug/divergence/full_div
%
% imwrite(uint8(squeeze(imgVolCopy(:,:,32,:))),strcat('M_FullDiv_F32_L',int2str(ii),'_I_',int2str(pp),'.png'));
% imwrite(uint8(squeeze(occVolDilate(:,:,32))),strcat('M_OccMask_F32_L',int2str(ii),'_I_',int2str(pp),'.png'))
%
% cd ../../..
% Carry out the reconstruction
if (exist('featurePyramid','var'))
......@@ -309,26 +336,6 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin)
debug_iter = debug_iter +1;
end
% end of initialisation branch
%write_image_volume(imgVol,'matlab_debug/peel/M_EndPeel_F');
% cd matlab_debug/peel/end_peel_disp/
%
% [~,w,l,maxFrame] = size(shiftVol);
%
% for nbframe=1:maxFrame
% csvwrite(strcat('M_EndPeel_DispX_',int2str(nbframe-1),'.csv'),reshape(shiftVol(1,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_EndPeel_DispY_',int2str(nbframe-1),'.csv'),reshape(shiftVol(2,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_EndPeel_DispZ_',int2str(nbframe-1),'.csv'),reshape(shiftVol(3,:,:,nbframe),[w,l]));
%
% csvwrite(strcat('M_EndPeel_DispA_',int2str(nbframe-1),'.csv'),reshape(shiftVol(4,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_EndPeel_GradX_',int2str(nbframe-1),'.csv'),normGradX(:,:,nbframe));
% csvwrite(strcat('M_EndPeel_GradY_',int2str(nbframe-1),'.csv'),normGradY(:,:,nbframe));
%
%
% end
%
% cd ../../..
end
pp=pp+1;
%we have finished the initialisation : make sure that both
......@@ -360,7 +367,7 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin)
return;
end
write_image_volume(imgVol,strcat('matlab_debug/divergence/M_L',int2str(ii)));
%write_image_volume(imgVol,strcat('matlab_debug/divergence/M_L',int2str(ii)));
%erase some of the video structures
clearvars imgVol occVolDilate occVolPatchMatch;
......
......@@ -92,11 +92,17 @@ def evolution(path,MorC,nbFrame,XYZ,idIter):
return 0
def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask, outPath):
def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC):
results=[]
for i in range(nbFrame):
temp_matlab = np.genfromtxt(Mpath+"Disp"+XYZ+"_L"+str(level+1)+"_F"+str(i+1)+".csv",delimiter=',')
if(inputMorC==0):
temp_matlab = np.genfromtxt(Mpath+"Disp"+XYZ+"_L"+str(level+1)+"_F"+str(i+1)+".csv",delimiter=',')
else:
temp_matlab = np.genfromtxt(Mpath+"Disp"+XYZ+"_L"+str(level)+"_F"+str(i)+".csv",delimiter=';')
end_m = np.shape(temp_matlab)[1]
temp_matlab = temp_matlab[:,0:end_m-1]
temp_cpp = np.genfromtxt(Cpath+"Disp"+XYZ+"_L"+str(level)+"_F"+str(i)+".csv",delimiter=';')
end = np.shape(temp_cpp)[1]
......@@ -122,7 +128,7 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask, outPath):
plt.axhline(np.mean(results[3:97]),color='red')
plt.xlabel("Frames")
plt.ylabel("Pourcentage de différence sur le masque")
plt.title("Evolution de la différence entre les cartes de déplacement établis par les algorithmes d'augmentation \n \
plt.title("Evolution de la différence entre les cartes de déplacement établis par les algorithmes d'augmentation -Nouvelle implémentation \n \
Direction: "+XYZ+" Avg:"+str(np.mean(results[3:97]))+" Ecart-type: "+str(np.std(results[3:97])))
plt.show()
return results
......@@ -156,8 +162,11 @@ if __name__=="__main__":
# plt.show()
# upsample_compare("Data/upsample/matlab_upsample/M_upsampleAfter_",\
# "Data/upsample/test_methodCpp/CppOut_",98,"Z",1,OccMediumMask,"Data/upsample/results/DiffNewFunc_")
# "Data/upsample/test_methodCpp/CppOut_",98,"Z",1,OccMediumMask,"Data/upsample/results/DiffNewFunc_",0)
upsample_compare("Data/upsample/CppOut_",\
"Data/upsample/test_methodCpp/CppOut_",98,"X",1,OccMediumMask,"Data/upsample/results/DiffMethod_",1)
for i in range(98):
img = np.genfromtxt("Data/upsample/test_methodCpp/CppOut_DispX_L1_F"+str(i)+".csv",delimiter=";")
plt.imsave("Data/upsample/test_methodCpp/test_DispX_L1_F"+str(i)+".png",img,cmap='seismic')
# for i in range(98):
# img = np.genfromtxt("Data/upsample/test_methodCpp/CppOut_DispX_L1_F"+str(i)+".csv",delimiter=";")
# plt.imsave("Data/upsample/test_methodCpp/test_DispX_L1_F"+str(i)+".png",img,cmap='seismic')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment