Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c7b23f47 authored by NADAL Morgane's avatar NADAL Morgane
Browse files

solved hysteresis bug - still in dvpt

parent 4a5d39df
No related branches found
No related tags found
No related merge requests found
......@@ -241,6 +241,7 @@ def __HysterisisImage__(image: array_t, low: float, high: float) -> array_t:
low = low * nonzero_values.min()
high = high * image.max()
print("low=", low, " high=", high)
# lowt = low*(x_image_f-min_image_f)+max_image_f
# hight = high*(max_image_f- min_image_f)+min_image_f
# lowt = (image_f >lowt).astype(int)
......
......@@ -60,6 +60,7 @@ import skimage.io as io_
# from skimage.segmentation import relabel_sequential
import skimage.morphology as mp_
import skimage.measure as ms_
import skimage.exposure as ex_
# import skimage.graph as gr_
# import networkx as nx_
# import math as mt_
......@@ -132,12 +133,8 @@ image = in_.ImageVerification(image, channel)
# iv_.image_verification(image, channel) # -> PySide2 user interface # TODO: must return the modified image!
# /!\ conflicts between some versions of PySide2 and Python3
image = image[:, 512:, 512:] # 512 # 562 # Just for development
# image = image[:, 512:, 512:] # 512 # 562 # Just for development
img_shape = image.shape
# for i in range(min(img_shape)):
# pl_.imshow(image[i,:,:])
# pl_.savefig(f"D:\\MorganeNadal\\M2 report\\for the slides\\img_ini_slide{i}.png")
# pl_.close()
#
print(f"IMAGE: s.{img_shape} t.{image.dtype} m.{image.min()} M.{image.max()}")
......@@ -194,9 +191,10 @@ if with_plot:
#
# -- Extentions
print("\n--- Extension Detection")
# Set to zeros the pixels belonging to the somas
del_soma = (som_nfo["lmp"] > 0).nonzero()
image_for_ext[del_soma] = 0
po_.MaximumIntensityProjectionZ(image_for_ext)
# Change the extensions parameters from micron to pixel dimensions
ext_min_area_c = in_.ToPixel(ext_min_area_c, size_voxel_in_micron, dimension=(0, 1))
......@@ -214,12 +212,8 @@ for value in scale_range:
scale_range = tuple(scale_range_pixel)
#
scale_step = in_.ToPixel(scale_step, size_voxel_in_micron, decimals=1)
# alpha = in_.ToPixel(alpha, size_voxel_in_micron, decimals=1)
# beta = in_.ToPixel(beta, size_voxel_in_micron, decimals=1)
# frangi_c = in_.ToPixel(frangi_c, size_voxel_in_micron)
# Perform frangi feature enhancement (via python or c - faster - implementation)
enhanced_ext, ext_scales = extension_t.EnhancedForDetection(
image_for_ext,
scale_range,
......@@ -234,12 +228,20 @@ enhanced_ext, ext_scales = extension_t.EnhancedForDetection(
elapsed_time = tm_.gmtime(tm_.time() - start_time)
print(f"Elapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}\n")
# enhanced_ext = in_.IntensityNormalizedImage(enhanced_ext)
# po_.MaximumIntensityProjectionZ(enhanced_ext, cmap="OrRd")
# Creation of the enhanced maps
enhanced_ext = ex_.adjust_log(enhanced_ext, 1) # Not necessary but better, log contrast adjustment
enhanced_ext = ex_.equalize_hist(enhanced_ext) # necessary, histogram equalisation (global)
# po_.MaximumIntensityProjectionZ(enhanced_ext, cmap="OrRd")
enhanced_ext = ex_.rescale_intensity(enhanced_ext, out_range=(0, 255)) # necessary, rescaling by stretching the values btw 0 and 255
# po_.MaximumIntensityProjectionZ(enhanced_ext, cmap="OrRd")
ext_nfo["coarse_map"] = extension_t.CoarseMap(enhanced_ext, ext_low_c, ext_high_c, ext_selem_pixel_c) # seuillage
# po_.MaximumIntensityProjectionZ(ext_nfo["coarse_map"])
ext_nfo["coarse_map"], ext_lmp = extension_t.FilteredCoarseMap(ext_nfo["coarse_map"], ext_min_area_c) # min
# po_.MaximumIntensityProjectionZ(ext_nfo["coarse_map"])
ext_nfo["map"] = extension_t.FineMapFromCoarseMap(ext_nfo["coarse_map"]) # skeleton
# po_.MaximumIntensityProjectionZ(ext_nfo["map"])
ext_nfo["map"][som_nfo["map"] > 0] = 0
ext_nfo["lmp"], n_extensions = ms_.label(ext_nfo["map"], return_num=True)
# Use relabel instead of label to optimize the algorithm. BUT PROBLEM WITH THE NUMBER OF EXTENSIONS DETECTED !
......@@ -388,7 +390,7 @@ if with_plot:
pl_.show()
# np_.save("D:\\MorganeNadal\\M2 report\\kmeansCHOvsDIO\\CHO_1H_2.npy", som_nfo['soma_w_ext_lmp'])
po_.MaximumIntensityProjectionZ(som_nfo['soma_w_ext_lmp'])
po_.MaximumIntensityProjectionZ(som_nfo['soma_w_ext_lmp'],output_image_file_name=f"D:\\MorganeNadal\\M2 report\\hysteresisCHOvsDIO\\MIP CHODIO\\DIO_3H\\{name_file}(2).png")
# --- Extract all the extensions of all somas as a graph
print('\n--- Graph extraction')
......
......@@ -49,8 +49,8 @@ parameter3 : None
; then your parameter has the value string: 'None', and not None
[Input]
data_path : ./data/DIO_6H_6_1.70bis_2.2_3.tif
#D:\\MorganeNadal\\IBA1-Microglies\\DIO_1H_16_1.58_2.1\\DIO_1H_16_1.58_2.1_9.tif
data_path : D:\\MorganeNadal\\IBA1-Microglies\\DIO_3H_F_1.82_3.1\\DIO_3H_F_1.82_3.1_1.tif
#D:\\MorganeNadal\\IBA1-Microglies\\DIO_1H_16_1.58_2.1\\DIO_1H_16_1.58_2.1_4.tif
#./data/DIO_6H_6_1.70bis_2.2_3.tif
channel : G
; Can take the values R, G or B.
......@@ -71,7 +71,7 @@ soma_min_area_c : (0.24050024 ** 2) * 1000
[Extensions]
; for hysteresis
ext_low_c : 0.2
ext_low_c : 10
#7.5e-8
#1e-20
ext_high_c : 0.6
......@@ -92,13 +92,10 @@ scale_range : (0.024,0.745)
scale_step : 0.24
# 1.0
alpha : 0.8
##0.19 if converted into pixels
# 0.8
beta : 0.5
##0.12 if converted into pixels
# 0.5
frangi_c : 500
## 3 if normalized btw 0 and 1 and converted to pixel
frangi_c : 30
## 12.5 if normalized btw 0 and 1
# 60.12506 # 500.0
bright_on_dark : True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment