Commit df9a08ea authored by sarthou's avatar sarthou
Browse files

Implementation of clamp of DispZ in upsampling succesful, but divergence...

Implementation of clamp of DispZ in upsampling succesful, but divergence problem still not corrected
parent 0de904ee
......@@ -136,10 +136,18 @@ void IDSDDownsampling::MatlabUpsampleShiftMatrix(){
fromYDispData[fromDim->DeterminePosition(GridX->GetData()[nextVolIt.GetPosition()],\
GridY->GetData()[nextVolIt.GetPosition()],GridZ->GetData()[nextVolIt.GetPosition()])];
// On garde les mêmes valeurs car il n'y a pas de downsampling sur Z
// On garde les mêmes valeurs car il n'y a pas de downsampling sur Z et on "clamp" les valeurs
int tempDispZ = fromZDispData[fromDim->DeterminePosition(GridX->GetData()[nextVolIt.GetPosition()],\
GridY->GetData()[nextVolIt.GetPosition()],GridZ->GetData()[nextVolIt.GetPosition()])];
// TODO Here the 2 (half patch size is hardcoded, have to change it later)
int minBarrier = 2;
int maxBarrier = toDim->GetSizeZ() - 2;
toZDispData[nextVolIt.GetPosition()] =\
fromZDispData[fromDim->DeterminePosition(GridX->GetData()[nextVolIt.GetPosition()],\
GridY->GetData()[nextVolIt.GetPosition()],GridZ->GetData()[nextVolIt.GetPosition()])];
std::max(std::min(tempDispZ,maxBarrier-GridZ->GetData()[nextVolIt.GetPosition()]),minBarrier-GridZ->GetData()[nextVolIt.GetPosition()]);
// toZDispData[nextVolIt.GetPosition()] = tempDispZ;
toADispData[nextVolIt.GetPosition()] =\
fromADispData[fromDim->DeterminePosition(GridX->GetData()[nextVolIt.GetPosition()],\
......
......@@ -104,7 +104,7 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC,lev
# Load matrices from the first path
if(inputMorC=='Matlab'):
temp_matlab = np.genfromtxt(Mpath+XYZ+endPath+str(i-1)+".csv",delimiter=',')
temp_matlab = np.genfromtxt(Mpath+XYZ+endPath+str(i)+".csv",delimiter=',')
else:
temp_matlab = np.genfromtxt(Mpath+XYZ+endPath+str(i)+".csv",delimiter=';')
end_m = np.shape(temp_matlab)[1]
......@@ -117,9 +117,9 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC,lev
diff = temp_matlab-temp_cpp[:,0:end-1]
if(np.sum(diff)!=0):
print("i:",i)
print(100*diff)
# if(np.sum(diff)!=0):
# print("i:",i)
# print(100*diff)
plt.imsave(outPath+XYZ+"_F"+str(i)+".png",diff,cmap="seismic")
......@@ -227,9 +227,14 @@ if __name__=="__main__":
# plt.imsave("Data/upsample_ant/coord/Diff_UA_CoordZ_F"+str(i)+".png",im1-im2[:,0:end-1])
# # Result: Don't seem to have a difference in the coord matrices between matlab and C++, maybe during clamp ?
# Comparing before and after clamp matrices in Matlab algorithm
im1 = np.genfromtxt("Data/upsample_ant/M_DispZ_BeforeClamp_F68.csv",delimiter=',')
im2 = np.genfromtxt("Data/upsample_ant/M_DispZ_AfterClamp_F68.csv",delimiter=',')
# # Comparing before and after clamp matrices in Matlab algorithm
# im1 = np.genfromtxt("Data/upsample_ant/M_DispZ_BeforeClamp_F68.csv",delimiter=',')
# im2 = np.genfromtxt("Data/upsample_ant/M_DispZ_AfterClamp_F68.csv",delimiter=',')
#
# plt.imsave("Data/upsample_ant/M_DispZ_DiffClamp_F68.png",im1-im2)
# # Result: On Z, there is a difference, so clamp might be useful
plt.imsave("Data/upsample_ant/M_DispZ_DiffClamp_F68.png",im1-im2)
# Result: On Z, there is a difference, so clamp might be useful
#Compare the output of data out of C++ algo, after and before on DispZ to see if clamp is effective
upsample_compare("Data/upsample_ant/M_UA_Post_","Data/upsample_ant/Cpp_UA_",\
98,"DispZ",3,OccMediumMask,"Data/upsample_ant/DiffOut_UA_",'Matlab',False)
# Result: Implementation succesful but the difference is still here ... WTF
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