Commit 8b687e4f authored by Martinez-Carvajal German's avatar Martinez-Carvajal German
Browse files

Not very important modifications

some prints went back

AND

surface voxels file must be in the path_read input
(if computed, flag_SV = True) it will be saved in
path_input instead of path_save
parent 7d6c4caf
......@@ -57,7 +57,7 @@ def SurfaceCouchyCrofton_2(Image, Resolution, p2, Surface_of_p1):
ROI_surface[1:-1,1:-1,1:-1] = Surface_of_p1
# Saving coordinates of every element in phase 1
print('Saving Coordinates')
print('Getting Coordinates with numpy.where')
Coordinates = np.where(ROI_surface == 255)
# Retrieving memory
......@@ -70,7 +70,7 @@ def SurfaceCouchyCrofton_2(Image, Resolution, p2, Surface_of_p1):
Max = len(FrameCoord)
assert num_sur_voxels != 0 , 'No surface pixels'
print('# Evaluations to perform = ', Max, num_sur_voxels )
#print('# Evaluations to perform = ', Max, num_sur_voxels )
# Some counters are needed
# Connectivity = root(1) neighbors
......@@ -85,7 +85,7 @@ def SurfaceCouchyCrofton_2(Image, Resolution, p2, Surface_of_p1):
print('Computing contributions')
print('Computing contributions...')
for index in FrameCoord.index :
z = FrameCoord.loc[index,'z']
x = FrameCoord.loc[index,'x']
......@@ -145,7 +145,7 @@ def SurfaceCouchyCrofton_2(Image, Resolution, p2, Surface_of_p1):
# Computing the surface
Surface = 4*(CC1 + CC2 + CC3)
#print('function executed')
print('Computation of contributions finished')
# check
#assert Family1 + Family2 + Family3 !=0, 'No contribution computed'
......@@ -187,7 +187,7 @@ def check_paths_and_files(path, path_save, file, file_SV, flag_SV ):
assert (os.path.isdir(path_save)) , "Folder: " + path_save + " IS NOT A FOLDER!"
chdir(path_save)
chdir(path)
if flag_SV == False:
assert (os.path.exists(file_SV)), "SV_file {} DOES NOT EXIST!".format(file_SV)
......@@ -219,7 +219,7 @@ def extract_surface_voxels(image, phase1, file_name):
# saving
surface = np.array(surface, dtype = np.uint8)*255
chdir(path_save)
chdir(path_input)
tifffile.imsave('surface_pixels_of_{}.tif'.format(sample_name),surface)
# saving last message
......@@ -299,9 +299,11 @@ def compute_specific_surface_profile(start_VS, path_input, path_save, file_name,
else:
print("Reading surface voxels...")
SurfaceVoxels = tifffile.imread(file_SV)
assert SurfaceVoxels.shape == image.shape
# Relabel (to avoid pixels outside the cylinder)
if flag_relabel == True:
chdir(path_input)
image = relabel_the_outside(image, label_outside, rw)
# computing indexes for each vertical section
......@@ -344,8 +346,8 @@ def compute_specific_surface_profile(start_VS, path_input, path_save, file_name,
# Volume of Fouling Material in the section
VolumeOrM = np.count_nonzero(Selection1 == p2)
VolumeOrM = VolumeOrM*resolution**3 # in mm3
print('FM Volume of section =', VolumeOrM)
#print('FM Volume of section =', VolumeOrM)
# Volume of air in the section
VolumeAir = np.count_nonzero(Selection1 == p1)
VolumeAir = VolumeAir*resolution**3 # in mm3
......@@ -356,7 +358,7 @@ def compute_specific_surface_profile(start_VS, path_input, path_save, file_name,
assert Volume == Volume1
Surface, num_sur_vox, (F1, F2, F3) = SurfaceCouchyCrofton_2(Selection1, resolution, p2, Selection2)
print('Surface of section (mm2)=', Surface)
#print('Surface of section (mm2)=', Surface)
# Storing data
# Volumes
......@@ -382,27 +384,21 @@ def compute_specific_surface_profile(start_VS, path_input, path_save, file_name,
# Save and plot (little by little)
chdir(path_save)
Frame = pd.DataFrame()
Frame['Depth(mm)'] = Depth
Frame['Surf Voids/OrM (mm^2)']= SurfAir_OrM
Frame['Volumes FM (mm^3)'] = VolumesOrM
Frame['Volumes Voids (mm^3)'] = VolumesAir
print(VolumesAir, VolumesOrM)
Frame['Volumes Voids + FM (mm^3)'] = np.array(VolumesAir) + np.array(VolumesOrM)
Frame['Volumes Bulk (mm^3)'] = Volumes
Frame['SS (mm-1) / FM'] = SpcSrfcs_1
Frame['SS (mm-1) / Voids'] = SpcSrfcs_2
Frame['SS (mm-1) / Voids + FM'] = SpcSrfcs_3
Frame['SS (mm-1) / Bulk'] = SpcSrfcs_4
Frame['Count_Sur_Vox'] = num_sur_voxs
Frame['F1'] = F1s
Frame['F2'] = F2s
Frame['F3'] = F3s
Name = 'SS_Profile_of_{}_rw_{}.csv'.format(sample_name, rw)
Frame.to_csv(Name, sep = ';')
plot_ssp(path_save, Name)
......@@ -413,7 +409,7 @@ def compute_specific_surface_profile(start_VS, path_input, path_save, file_name,
print('FINISHED')
def main():
global path_save, size_VS, start_VS, sample_name
global path_input, path_save, size_VS, start_VS, sample_name
# Directory input
path_input ='/home/german.martinez-carvajal/Desktop/These/Hashemi_segmentation/Tests/Test9_Rapide/Results/heavy_results'
......@@ -423,7 +419,7 @@ def main():
# Image Name
file_name = "Hash_Segm_of_Image_Filtered_PVE_50_Tol_0.75_NumVS_1.tif"
sample_name = "MONxx"
sample_name = "MONxx_part2"
# flag to reag SV file (surface voxels file) if already identified
# Important : surface pixels are labeled 255
flag_SV = True # True - Compute surface voxels /// False - read existing image with surface voxels
......@@ -443,11 +439,11 @@ def main():
rw = 1.0
# size_VS
size_VS = 3 # pixels (the same lenght of the smoothing for volume fraction profiles)
size_VS = 2 # pixels (the same lenght of the smoothing for volume fraction profiles)
# start at vertical section #...
# useful if you want to resume the computation from a certain point
start_VS = 0
start_VS = 0
# cheking
check_paths_and_files(path_input, path_save, file_name, file_SV, flag_SV)
......
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