Commit 827a2cb8 authored by Martinez-Carvajal German's avatar Martinez-Carvajal German
Browse files

18_06_06

In the program PoreSizeDistriution_(ErosionDiltation)_Python.py
I realized I ccould eliminate the loop for the erosion
Time of the execution was reduced to a little more of 50% of the last
version

In Segmentation_Hashemi.py
I just added some coments on how to produce the inputs of the function
bu using some commands in ImageJ
No related merge requests found
Showing with 21 additions and 10 deletions
+21 -10
......@@ -9,7 +9,7 @@ def Pore_Size_Distribution(Dir, FileName):
from os import path, chdir
assert (path.isdir(Dir)) , "Folder IS NOT A FOLDER: " + folder
assert (path.exists(FileName)) , "FILE DOES NOT EXIST: " + File_Top_Image
assert (path.exists(FileName)) , "FILE DOES NOT EXIST: " + FileName
# Reading Segmented Image
# Imp is the air-phase (this is the result of the Hashemi's segmentation, by Hashemi's method normally)
......@@ -37,18 +37,15 @@ def Pore_Size_Distribution(Dir, FileName):
print('Max Radius:', Max_radius)
from ij import ImagePlus
Erosion = ImagePlus('Erosion', Imp_Air.getImageStack())
Erosion.show()
for Radius in range(1,Max_radius):
print('Step: Radius of erosion (in pixels) = ', Radius)
# Computing erosions
Erosion = ImagePlus('Erosion', Imp_Air.getImageStack())
Erosion.show()
for repeat in range(Radius):
IJ.run(Erosion, "Erode (3D)", "iso=255")
IJ.run(Erosion, "Erode (3D)", "iso=255") # IJ.run("Erode 3D") is a change in place method (there is no need to reasign the result of the Erosion)
# Computing dilations
Dilation = ImagePlus('Dilation', Erosion.getImageStack())
Dilation.show()
for repeat in range(Radius):
IJ.run(Dilation, "Dilate (3D)", "iso=255")
......@@ -62,7 +59,6 @@ def Pore_Size_Distribution(Dir, FileName):
Volume = Initial - Remaining
Cum_Volumes.append(Volume)
# Breaking if procedure completed
Erosion.close()
Dilation.close()
if Remaining == 0:
break
......@@ -75,8 +71,13 @@ def Pore_Size_Distribution(Dir, FileName):
File.write(str(Radii[i]) + ',' + str(Cum_Volumes[i]) + '\n')
File.close()
print("Finished !")
# MAIN
# Report start-time of the execution
import datetime
Start = datetime.datetime.today()
# Directory and File Name
Dir = '/home/german.martinez-carvajal/Desktop/2018/Pore_Size_Distribution/Test'
#Dir = '/home/german.martinez-carvajal/Desktop/2017/Tomographie/170411COP/Segmentation(Hashemi)'
......@@ -84,4 +85,12 @@ FileName = Dir + "/" + "Binary.tif"
#FileName = Dir + "/" + "Air.tif"
# Calling the function
Pore_Size_Distribution(Dir, FileName)
\ No newline at end of file
# Report end-time of the execution
End = datetime.datetime.today()
# Saving report
from os import chdir
chdir (Dir)
File = open('Time_Report.txt', mode = 'w')
File.write('Start time: ' + str(Start) + '\n')
File.write('End time: ' + str(End ) + '\n')
File.close()
\ No newline at end of file
......@@ -9,6 +9,8 @@ def Segmentation_Hashemi(Dir, Scan_File,PVE_File, Mu = None):
Dir : The directory were the files are read and written
Scan_File : .tif 3D-image in 8-bit or 16-bit. It should be filtered before (Use 3D median filter in ImageJ)
PVE_File : .tif 3D-image in 8-bit (same size as Scan_File). It is binary, white pixels (255 in 8-bit) represent pixels of the Partial Volume Effect
In imageJ Use the command: Process-Find Edges (Warning, this is a 2D operation)
Then binarize using the defalut ImageJ thresholding method
Mu : a list with three integers values that will be the initialisation in the fitting of gaussians of the gray value histogram , if None, they
will be initialised by some values depending our experience
......
Supports Markdown
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