Commit a24b73a8 authored by sarthou's avatar sarthou
Browse files

Working on ant debugging on interpolation, ready to dive

parent e25e0890
......@@ -52,6 +52,8 @@ int main(){
openCVIO.LoadOcclusionMatrixFromImage(occFileName, occMatrix);
IDSConcrete baseIPS = IDSConcrete(dim, redMatrix, greenMatrix, blueMatrix, occMatrix);
// Work for testing upsampe algorithm
IDSDDownsampling downsampledDataSource = IDSDDownsampling(&baseIPS, 3, 2);
PaddedMatrix<int> * const frame_x = new PaddedMatrix<int>(downsampledDataSource.GetDim());
......@@ -88,16 +90,75 @@ int main(){
for(int nbFrame=0;nbFrame < downsampledDataSource.GetDim()->GetSizeZ();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/Out_DispY_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/Out_DispA_L1_F"+std::to_string(nbFrame));
}
std::cout << "End of upsample test"<< std::endl;
std::cout << "End of upsample test"<< std::endl;
/*
int level = 2;
IDSDDownsampling downsampledDataSource = IDSDDownsampling(&baseIPS, 3, 2);
downsampledDataSource.SetCurLevel(level);
openCVIO.LoadRGBMatrixFromVideo("Data/search_reconstruct/SR_matlab/M_SR_Ante_L3.avi",\
downsampledDataSource.GetRed(), downsampledDataSource.GetGreen(), downsampledDataSource.GetBlue());
PaddedMatrix<int> * const frame_x = new PaddedMatrix<int>(downsampledDataSource.GetDim());
PaddedMatrix<int> * const frame_y = new PaddedMatrix<int>(downsampledDataSource.GetDim());
PaddedMatrix<int> * const frame_z = new PaddedMatrix<int>(downsampledDataSource.GetDim());
PaddedMatrix<float> * const frame_a = new PaddedMatrix<float>(downsampledDataSource.GetDim());
PaddedMatrix<float> * const frame_gx = new PaddedMatrix<float>(downsampledDataSource.GetDim());
PaddedMatrix<float> * const frame_gy = new PaddedMatrix<float>(downsampledDataSource.GetDim());
for(int nbFrame=0;nbFrame<downsampledDataSource.GetDim()->GetSizeZ();nbFrame++)
{
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_DispX_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_x,1);
downsampledDataSource.GetDispX()->SetFrame(frame_x,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_DispY_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_y,1);
downsampledDataSource.GetDispY()->SetFrame(frame_y,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_DispZ_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_z,1);
downsampledDataSource.GetDispZ()->SetFrame(frame_z,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_DispA_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_a,1);
downsampledDataSource.GetDispA()->SetFrame(frame_a,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_GradX_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_gx,1);
downsampledDataSource.GetGradX()->SetFrame(frame_gx,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_GradY_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_gy,1);
downsampledDataSource.GetGradY()->SetFrame(frame_gy,nbFrame);
}
searchAlgo.Search(&downsampledDataSource, false);
reconstructAlgo.Reconstruct(&downsampledDataSource, false);
for(int nbFrame=0;nbFrame < downsampledDataSource.GetDim()->GetSizeZ();nbFrame++)
{
openCVIO.GeneralIOForRGB(downsampledDataSource.GetRed(), downsampledDataSource.GetGreen(),\
downsampledDataSource.GetBlue(),nbFrame,InpaintingIO::IH_DBG_SAVE,\
"Data/search_reconstruct/CppOut_SR_L"+std::to_string(level+1)+"_F"+ std::to_string(nbFrame));
downsampledDataSource.GetDispX()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_DispX_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispY()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_DispY_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispZ()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_DispZ_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispA()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_DispA_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame));
downsampledDataSource.GetGradX()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_GradX_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame));
downsampledDataSource.GetGradY()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_GradY_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame));
}
std::cout << "End of search/reconstruct test" << std::endl;
*/
// Execute the work
inpainter.Inpaint(&baseIPS, &profiler);
......
......@@ -80,53 +80,8 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin)
% If we are not at the coarsest level...
if (ii~=maxLevel)
% ... upsample the previous shift map...
% cd matlab_debug/test_upsample
%
% [~,w,l,maxFrame] = size(shiftVol);
% for nbframe=1:maxFrame
% csvwrite(strcat(strcat('M_upsampleBefore_DispX_L',int2str(ii),'_F',int2str(nbframe),'.csv')),reshape(shiftVol(1,:,:,nbframe),[w,l]));
% csvwrite(strcat(strcat('M_upsampleBefore_DispY_L',int2str(ii),'_F',int2str(nbframe),'.csv')),reshape(shiftVol(2,:,:,nbframe),[w,l]));
% csvwrite(strcat(strcat('M_upsampleBefore_DispZ_L',int2str(ii),'_F',int2str(nbframe),'.csv')),reshape(shiftVol(3,:,:,nbframe),[w,l]));
% csvwrite(strcat(strcat('M_upsampleBefore_DispA_L',int2str(ii),'_F',int2str(nbframe),'.csv')),reshape(shiftVol(4,:,:,nbframe),[w,l]));
% end
%
% cd ../..
%
%
shiftVol = single(interpolate_disp_field(shiftVol,imgVol,1/scaleStep, patchSize,'nearest'));
%
% cd matlab_debug/test_upsample
%
% [~,w,l,maxFrame] = size(shiftVol);
% for nbframe=1:maxFrame
% csvwrite(strcat(strcat('M_upsampleAfter_DispX_L',int2str(ii),'_F',int2str(nbframe),'.csv')),reshape(shiftVol(1,:,:,nbframe),[w,l]));
% csvwrite(strcat(strcat('M_upsampleAfter_DispY_L',int2str(ii),'_F',int2str(nbframe),'.csv')),reshape(shiftVol(2,:,:,nbframe),[w,l]));
% csvwrite(strcat(strcat('M_upsampleAfter_DispZ_L',int2str(ii),'_F',int2str(nbframe),'.csv')),reshape(shiftVol(3,:,:,nbframe),[w,l]));
% csvwrite(strcat(strcat('M_upsampleAfter_DispA_L',int2str(ii),'_F',int2str(nbframe),'.csv')),reshape(shiftVol(4,:,:,nbframe),[w,l]));
% end
%
% 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'))
......@@ -154,22 +109,6 @@ 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
......@@ -192,6 +131,23 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin)
% Copy last shiftVol
firstGuess = shiftVol+1-1;
% 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_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(1,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Ante_DispY_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(2,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Ante_DispZ_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(3,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Ante_DispA_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(4,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Ante_GradX_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),normGradX(:,:,nbframe));
% csvwrite(strcat('M_SR_Ante_GradY_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),normGradY(:,:,nbframe));
% end
%
% cd ../..
% Carry out the 3D PatchMatch
shiftVol = spatio_temporal_patch_match_mex(...
imgVol,...
......@@ -229,6 +185,23 @@ 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)));
% cd matlab_debug/search_reconstruct/
%
% [~,w,l,maxFrame] = size(shiftVol);
%
% for nbframe=1:maxFrame
% csvwrite(strcat('M_SR_Post_DispX_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(1,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Post_DispY_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(2,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Post_DispZ_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(3,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Post_DispA_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(4,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Post_GradX_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),normGradX(:,:,nbframe));
% csvwrite(strcat('M_SR_Post_GradY_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),normGradY(:,:,nbframe));
% end
%
% cd ../../
else
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% INITIALISATION %
......
......@@ -57,7 +57,7 @@ function[dispFieldOut] = interpolate_disp_field(dispFieldIn,imgVolFine,scaleStep
yCoordsInterp = max(min(round(yCoordsFine/2),sizeDispField(2)),1);
tCoordsInterp = max(min(round(tCoordsFine/2),sizeDispField(4)),1);
end
dispFieldOut = zeros([4 sizeImgVolFine(2:4)]);
sizeDispFieldOut = size(dispFieldOut);
......
......@@ -28,6 +28,9 @@ PeelCpp = "Data/onion_debug/peel_compare/Cpp_EndPeel_F"
CppLoadingPath = "Data/onion_debug/CppOut_WithMatlabInput_F"
DivCpp = "Data/divergence/cpp_divergence/CppOutDiv_L"
DivMatlab = "Data/divergence/matlab_divergence/M_L"
Cpp_SR_Path = "Data/search_reconstruct/CppOut_SR_L3_F"
M_SR_Path = "Data/search_reconstruct/SR_matlab/M_SR_Post_Im_L3_frame_"
# print(OccMask)
threshold_nbPixDiff = 0.1
......@@ -70,6 +73,29 @@ def PixCompare(im1,im2,occMask,threshold):
Bcount = Bcount + 1
return [Rcount/MaskCount,Gcount/MaskCount,Bcount/MaskCount]
def FullPixCompare(Vol1Path,Vol2Path,sizeVol,OccMaskPath,threshold):
Vol1 = np.zeros((sizeVol[0],sizeVol[1],sizeVol[2],sizeVol[3]))
Vol2 = np.zeros(np.shape(Vol1))
VolOutput = np.zeros(np.shape(Vol1))
# Loading of data in matrices
for i in range(np.shape(Vol1)[0]):
Vol1[i,:,:,:] = io.imread(Vol1Path+str(i)+".png")
Vol2[i,:,:,:] = io.imread(Vol2Path+str(i)+".png")
OccMask = io.imread(OccMaskPath,as_grey=True)
OccMask[OccMask<0.1]=0
OccMask[OccMask>=0.1]=255
pixCount = np.zeros((sizeVol[3],sizeVol[0]))
for i in range(sizeVol[0]):
pixCount[:,i]=PixCompare(Vol1[i,:,:,:],Vol2[i,:,:,:],OccMask,threshold)
return pixCount
def PSNR(im1,im2,occMask):
n,m=im1.shape[0],im1.shape[1]
......@@ -157,15 +183,22 @@ def MSSIM(VolX,VolY,C1,C2,WinNb):
plt.show()
return 0
def visual_compare(Vol1,Vol2,OutputPath):
VolOutput = np.zeros(np.shape(Vol1))
def visual_compare(Vol1Path,Vol2Path,sizeVol,OutputPath):
for i in range(98):
Vol1 = np.zeros((sizeVol[0],sizeVol[1],sizeVol[2],sizeVol[3]))
Vol2 = np.zeros(np.shape(Vol1))
VolOutput = np.zeros(np.shape(Vol1))
# Loading of data in matrices
for i in range(np.shape(Vol1)[0]):
Vol1[i,:,:,:] = io.imread(Vol1Path+str(i)+".png")
Vol2[i,:,:,:] = io.imread(Vol2Path+str(i)+".png")
#Comparison
for i in range(np.shape(Vol1)[0]):
VolOutput[i,:,:,0] = np.absolute(Vol1[i,:,:,0] - Vol2[i,:,:,0])
VolOutput[i,:,:,1] = np.absolute(Vol1[i,:,:,1] - Vol2[i,:,:,1])
VolOutput[i,:,:,2] = np.absolute(Vol1[i,:,:,2] - Vol2[i,:,:,2])
plt.imsave(OutputPath+str(i),rgb2gray(VolOutput[i,:,:,:]),cmap="binary")
plt.imsave(OutputPath+str(i),rgb2gray(VolOutput[i,:,:,:]),cmap="gray")
return VolOutput
......@@ -201,6 +234,9 @@ if __name__ == '__main__':
VolMatlabDiv2 = np.zeros((98,34,132,3))
VolMatlabDiv3 = np.zeros((98,17,66,3))
VolSRM = np.zeros((98,17,66,3))
VolSRC = np.zeros((98,17,66,3))
# Chargement des images dans un volume
for i in range(98):
if(i<9):
......@@ -420,27 +456,45 @@ if __name__ == '__main__':
# VolOutComp = visual_compare(VolRand1,VolRand2,"Data/random_compare/RComp")
# visual_compare(VolCpp,VolCppLoad,"Data/onion_debug/peel_compare/visual_comp_cpp_matlab_loading/CompLoadF")
# Evolution de la différence de pixel au fil des iterations entre Matlab et C++
Cpath = "Data/divergence/CppOutDiv_F32_L"
Mpath = "Data/divergence/full_div/M_FullDiv_F32_L"
values = []
for i in range(1,8):
im1 = io.imread(Cpath+str(3)+"_I"+str(i)+".png")
im2 = io.imread(Mpath+str(3)+"_I_"+str(i+1)+".png")
values.append(np.sum(PixCompare(im1,im2,OccSmallMask,0.1)))
for i in range(1,9):
im1 = io.imread(Cpath+str(2)+"_I"+str(i)+".png")
im2 = io.imread(Mpath+str(2)+"_I_"+str(i+1)+".png")
values.append(np.sum(PixCompare(im1,im2,OccMediumMask,0.1)))
for i in range(1,13):
im1 = io.imread(Cpath+str(1)+"_I"+str(i)+".png")
im2 = io.imread(Mpath+str(1)+"_I_"+str(i+1)+".png")
values.append(np.sum(PixCompare(im1,im2,OccMask,0.1)))
plt.plot(values)
plt.axvline(x=6.5,color='r')
plt.axvline(x=14.5,color='r')
plt.xlabel("Iterations")
plt.ylabel("Pourcentage de pixels différents sur le masque d'occlusion")
plt.title("Evolution de la différence de pixels au fil des iterations entre Matlab et C++")
# # Evolution de la différence de pixel au fil des iterations entre Matlab et C++
# Cpath = "Data/divergence/CppOutDiv_F32_L"
# Mpath = "Data/divergence/full_div/M_FullDiv_F32_L"
# values = []
# for i in range(1,8):
# im1 = io.imread(Cpath+str(3)+"_I"+str(i)+".png")
# im2 = io.imread(Mpath+str(3)+"_I_"+str(i+1)+".png")
# values.append(np.sum(PixCompare(im1,im2,OccSmallMask,0.1)))
# for i in range(1,9):
# im1 = io.imread(Cpath+str(2)+"_I"+str(i)+".png")
# im2 = io.imread(Mpath+str(2)+"_I_"+str(i+1)+".png")
# values.append(np.sum(PixCompare(im1,im2,OccMediumMask,0.1)))
# for i in range(1,13):
# im1 = io.imread(Cpath+str(1)+"_I"+str(i)+".png")
# im2 = io.imread(Mpath+str(1)+"_I_"+str(i+1)+".png")
# values.append(np.sum(PixCompare(im1,im2,OccMask,0.1)))
#
# plt.plot(values)
# plt.axvline(x=6.5,color='r')
# plt.axvline(x=14.5,color='r')
# plt.xlabel("Iterations")
# plt.ylabel("Pourcentage de pixels différents sur le masque d'occlusion")
# plt.title("Evolution de la différence de pixels au fil des iterations entre Matlab et C++")
# plt.show()
############## Working on Search/reconstruct
# visual_compare(Cpp_SR_Path,M_SR_Path,[98,17,66,3],"Data/search_reconstruct/SR_result/SR_OutComp_L3_F")
pixCountSR = FullPixCompare(Cpp_SR_Path,M_SR_Path,[98,17,66,3],OccSmallPath,0.1)
plt.plot((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3,'black')
plt.axhline(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3),color='red')
plt.xlabel("number of frame (time)")
plt.ylabel("Percentage of pixels different in each image on the mask")
plt.legend()
plt.title("Evolution de la différence de pixel entre les images Matlab et C++\
sur une itération Recherche/Reconstruction \n \
Avg:"+str(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3))+\
" Ecart-type: "+str(np.std((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3)))
plt.show()
......@@ -97,14 +97,14 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC):
results=[]
for i in range(nbFrame):
if(inputMorC==0):
temp_matlab = np.genfromtxt(Mpath+"Disp"+XYZ+"_L"+str(level+1)+"_F"+str(i+1)+".csv",delimiter=',')
temp_matlab = np.genfromtxt(Mpath+XYZ+"_L"+str(level)+"_F"+str(i)+".csv",delimiter=',')
else:
temp_matlab = np.genfromtxt(Mpath+"Disp"+XYZ+"_L"+str(level)+"_F"+str(i)+".csv",delimiter=';')
temp_matlab = np.genfromtxt(Mpath+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=';')
temp_cpp = np.genfromtxt(Cpath+XYZ+"_L"+str(level)+"_F"+str(i)+".csv",delimiter=';')
end = np.shape(temp_cpp)[1]
diff = temp_matlab-temp_cpp[:,0:end-1]
......@@ -128,7 +128,8 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC):
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 -Nouvelle implémentation \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
......@@ -164,9 +165,14 @@ if __name__=="__main__":
# upsample_compare("Data/upsample/matlab_upsample/M_upsampleAfter_",\
# "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)
# upsample_compare("Data/upsample/CppOut_",\
# "Data/upsample/test_methodCpp/CppOut_",98,"DispX",1,OccMediumMask,"Data/upsample/results/DiffMethod_",1)
# # Transformer .csv en image
# 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')
# Displaying Disp and Grad differences for a SR iteration
upsample_compare("Data/search_reconstruct/SR_matlab/M_SR_Post_",\
"Data/search_reconstruct/CppOut_SR_",98,"GradY",3,OccMediumMask,"Data/search_reconstruct/SR_result/Diff_SR_",0)
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