Skip to content
Snippets Groups Projects
Commit 2acd50de authored by Olivier Bertrand's avatar Olivier Bertrand
Browse files

Handle infinite value in blender and a scene checker

parent 5f67fbe1
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ import pandas as pd ...@@ -8,7 +8,7 @@ import pandas as pd
import sqlite3 import sqlite3
import io import io
import warnings import warnings
from navipy.scene import is_numeric_array from navipy.scene import is_numeric_array, check_scene
def adapt_array(arr): def adapt_array(arr):
...@@ -291,6 +291,16 @@ database ...@@ -291,6 +291,16 @@ database
posorient.set_index('id', inplace=True) posorient.set_index('id', inplace=True)
return posorient return posorient
@property
def normalisations(self):
"""Return the position orientations of all points in the \
database
"""
posorient = pd.read_sql_query(
"select * from normalisation;", self.db)
posorient.set_index('id', inplace=True)
return posorient
def read_posorient(self, posorient=None, rowid=None): def read_posorient(self, posorient=None, rowid=None):
if posorient is not None: if posorient is not None:
if not isinstance(posorient, pd.Series): if not isinstance(posorient, pd.Series):
...@@ -406,6 +416,7 @@ database ...@@ -406,6 +416,7 @@ database
cmaxminrange = cmaxminrange.astype(float) cmaxminrange = cmaxminrange.astype(float)
toreturn = self.denormalise_image(image, cmaxminrange) toreturn = self.denormalise_image(image, cmaxminrange)
toreturn = toreturn[..., np.newaxis] toreturn = toreturn[..., np.newaxis]
check_scene(toreturn)
return toreturn return toreturn
def denormalise_image(self, image, cmaxminrange): def denormalise_image(self, image, cmaxminrange):
...@@ -557,4 +568,5 @@ class DataBaseSave(DataBase): ...@@ -557,4 +568,5 @@ class DataBaseSave(DataBase):
cmaxminrange.loc[str(chan_n) + '_max'] = cmax cmaxminrange.loc[str(chan_n) + '_max'] = cmax
cmaxminrange.loc[str(chan_n) + '_min'] = cmin cmaxminrange.loc[str(chan_n) + '_min'] = cmin
cmaxminrange.loc[str(chan_n) + '_range'] = crange cmaxminrange.loc[str(chan_n) + '_range'] = crange
check_scene(normed_im[...,np.newaxis])
return normed_im, cmaxminrange return normed_im, cmaxminrange
...@@ -12,7 +12,7 @@ import os ...@@ -12,7 +12,7 @@ import os
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from navipy.database import DataBaseSave from navipy.database import DataBaseSave
from navipy.scene import check_scene
class BeeSampling(): class BeeSampling():
""" """
...@@ -163,6 +163,7 @@ so that they are not rendered ...@@ -163,6 +163,7 @@ so that they are not rendered
# and the cmaxminrange has not already been assigned # and the cmaxminrange has not already been assigned
# so the image need to be rendered # so the image need to be rendered
scene = self.renderer.scene(posorient) scene = self.renderer.scene(posorient)
check_scene(scene)
scene = scene[..., 0] scene = scene[..., 0]
distance = scene[..., -1] distance = scene[..., -1]
distance[distance > self.world_dim] = self.world_dim distance[distance > self.world_dim] = self.world_dim
......
...@@ -324,4 +324,15 @@ is the distance. ...@@ -324,4 +324,15 @@ is the distance.
self.update(posorient) self.update(posorient)
toreturn = np.concatenate((self.image, toreturn = np.concatenate((self.image,
self.distance), axis=2) self.distance), axis=2)
ninffound=0
for chan_i in range(4):
cim = toreturn[...,chan_i]
cmax=cim.max()
if np.isinf(cmax):
ninffound += np.sum(np.isinf(cim))
cmax=cim[np.isinf(cim)==0].max()
toreturn[np.isinf(cim)==1]=cmax
if ninffound > 0:
warnings.warn('{} Inf found in image'.format(ninffound))
return toreturn[..., np.newaxis] return toreturn[..., np.newaxis]
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