Mentions légales du service

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

wrote fct for relative intensity image normalization + refractoring

parent 3ff4cecf
No related branches found
No related tags found
No related merge requests found
...@@ -57,10 +57,10 @@ def PlotSomas(somas: Sequence[soma_t], som_nfo: dict, axes: dict) -> None: ...@@ -57,10 +57,10 @@ def PlotSomas(somas: Sequence[soma_t], som_nfo: dict, axes: dict) -> None:
for soma in somas: for soma in somas:
axes[soma.uid] = ot_.PlotLMap(som_nfo["lmp"], labels=soma.uid) axes[soma.uid] = ot_.PlotLMap(som_nfo["lmp"], labels=soma.uid)
pl_.title(f"Soma.{soma.uid}") pl_.title(f"Soma.{soma.uid}")
pl_.matshow(som_nfo["influence_map"].max(axis=0)), pl_.title("Soma Influencess") # pl_.matshow(som_nfo["influence_map"].max(axis=0)), pl_.title("Soma Influencess")
pl_.show(block=True) # pl_.show(block=True)
pl_.matshow(som_nfo["dist_to_closest"].max(axis=0)), pl_.title("Soma Distances") # pl_.matshow(som_nfo["dist_to_closest"].max(axis=0)), pl_.title("Soma Distances")
pl_.show(block=True) # pl_.show(block=True)
def PlotExtensions( def PlotExtensions(
......
...@@ -68,21 +68,33 @@ def ImageVerification(image, channel): ...@@ -68,21 +68,33 @@ def ImageVerification(image, channel):
# print('WARNING. The 3 RGB color channels were selected in the parameters but the image has only one channel.') # print('WARNING. The 3 RGB color channels were selected in the parameters but the image has only one channel.')
def NormalizedImage(image: array_t) -> array_t: def IntensityNormalizedImage(image: array_t) -> array_t:
# #
print( print('Relative Intensity Normalization between 0 and 1 (Not a standardization). Need to reevaluate the parameters !!!')
"This normalization does not bring anything; left as is for now to avoid the need for changing prms"
)
nonextreme_values = image[np_.logical_and(image > 0.0, image < image.max())]
if nonextreme_values.size > 0: value_max = image.astype(np_.float32).max()
nonextreme_avg = nonextreme_values.mean() value_min = image.astype(np_.float32).min()
result = image.astype(np_.float32) / nonextreme_avg
else: result = (image.astype(np_.float32) - value_min)/(value_max - value_min)
result = image.astype(np_.float32)
return result return result
# print(
# "This normalization does not bring anything; left as is for now to avoid the need for changing prms"
# )
# nonextreme_values = image[np_.logical_and(image > 0.0, image < image.max())]
#
# if nonextreme_values.size > 0:
# nonextreme_avg = nonextreme_values.mean()
# result = image.astype(np_.float32) / nonextreme_avg
# else:
# result = image.astype(np_.float32)
#
# return result
def MetricNormalizedImage(image: array_t) -> array_t: # TODO
#
print('Image metric in converted to micrometers.')
def DijkstraCosts(image: array_t, som_map: array_t, ext_map: array_t) -> array_t: def DijkstraCosts(image: array_t, som_map: array_t, ext_map: array_t) -> array_t:
# #
......
...@@ -106,8 +106,8 @@ img_shape = image.shape ...@@ -106,8 +106,8 @@ img_shape = image.shape
# #
print(f"IMAGE: s.{img_shape} t.{image.dtype} m.{image.min()} M.{image.max()}") print(f"IMAGE: s.{img_shape} t.{image.dtype} m.{image.min()} M.{image.max()}")
image_for_soma = in_.NormalizedImage(image) image_for_soma = in_.IntensityNormalizedImage(image)
image_for_ext = in_.NormalizedImage(image) image_for_ext = in_.IntensityNormalizedImage(image)
print(f"NRM-IMG: t.{image_for_soma.dtype} m.{image_for_soma.min():.2f} M.{image_for_soma.max():.2f}") print(f"NRM-IMG: t.{image_for_soma.dtype} m.{image_for_soma.min():.2f} M.{image_for_soma.max():.2f}")
# --- Initialization # --- Initialization
......
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