### adding the same parameter rw to

```perform computations in cylinders smaller
than total diameter```
parent db8df380
 ... ... @@ -41,7 +41,7 @@ def sector_mask(shape,centre,radius,angle_range): return circmask*anglemask def relabel_the_outside(image,labels): def relabel_the_outside(image,labels, rw): """ if pixels outside the cylinder that contains the sample have the same value for air they will be relabeled with the value label so, if you follow the conventions for label values ... ... @@ -57,7 +57,7 @@ def relabel_the_outside(image,labels): # The cylinder is supposed to be the biggest "circle" inscribed in a squared image z,x,y = np.shape(image), np.shape(image), np.shape(image) center = int(x/2), int(y/2) radius = int((x/2)) radius = int((x/2))*rw #Selecting circular ROI (region of interest) mask_2D = sector_mask((x,y),center,radius,(0,360 )) mask_3D = np.zeros(image.shape, dtype = np.bool) ... ... @@ -67,7 +67,7 @@ def relabel_the_outside(image,labels): print("{} pixels have been attributed to tha phase : outside the cylinder".format(np.count_nonzero(image == 1))) return image def compute_global_fractions_volumes_depths(r, image, sample_name, start_dl, end_dl, end_gl, path_save): def compute_global_fractions_volumes_depths(r, image, sample_name, start_dl, end_dl, end_gl, path_save, rw): """ r = resolution in mm/vox start_dl = int, starting slice of the deposit layer end_dl = int, ending slice of the deposit layer, start of the gravel layer ... ... @@ -131,7 +131,7 @@ def compute_global_fractions_volumes_depths(r, image, sample_name, start_dl, end chdir(path_save) print("Fractions for sample {}\n".format(sample_name), df) df.to_csv('Global_Volume_Fractions_of_sample_{}.csv'.format(sample_name), sep = ';' ) df.to_csv('Global_Volume_Fractions_of_sample_{}_rw_{}.csv'.format(sample_name, rw), sep = ';' ) return (df) ... ... @@ -149,14 +149,15 @@ def main(): slice_start_deposit_layer = 1 slice_end_deposit_layer = 5 r = 0.035 # mm/vox rw = 1 # Computing global fractions chdir(path_read) print('Reading...', path_read, file_name) image = tifffile.imread(file_name) print('Relabeling the outside') labels = [1,0,128,255] # 1 = outside the cylinder, 0 = voids, 128 = fouling material, 255 = gravel image = relabel_the_outside(image, labels) compute_global_fractions_volumes_depths(r, image, sample_name, slice_start_deposit_layer, slice_end_deposit_layer, len(image), path_save) image = relabel_the_outside(image, labels, rw) compute_global_fractions_volumes_depths(r, image, sample_name, slice_start_deposit_layer, slice_end_deposit_layer, len(image), path_save, rw) main() print('ok global fractions')
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