Commit dc889d7b authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Moved skimage import to functional level to avoid static TLS import error.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent ea8efd7a
...@@ -27,7 +27,6 @@ from six import PY3 ...@@ -27,7 +27,6 @@ from six import PY3
from shapely.wkb import loads from shapely.wkb import loads
import numpy as np import numpy as np
from skimage.transform import rescale
try: try:
import gdal import gdal
...@@ -67,6 +66,7 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None, ...@@ -67,6 +66,7 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None,
zoom_factor = 0.5 zoom_factor = 0.5
# downsample to half size, nearest neighbour # downsample to half size, nearest neighbour
from skimage.transform import rescale # import here to avoid static TLS import error
array = rescale(array, zoom_factor, order=0, preserve_range=True, mode='edge').astype(np.bool) array = rescale(array, zoom_factor, order=0, preserve_range=True, mode='edge').astype(np.bool)
# update pixel sizes within gt # update pixel sizes within gt
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
import numpy as np import numpy as np
from skimage.measure import compare_ssim as ssim
__author__ = "Daniel Scheffler" __author__ = "Daniel Scheffler"
...@@ -37,6 +36,8 @@ def calc_ssim(image0, image1, dynamic_range=None, win_size=None, gaussian_weight ...@@ -37,6 +36,8 @@ def calc_ssim(image0, image1, dynamic_range=None, win_size=None, gaussian_weight
:param gaussian_weights: :param gaussian_weights:
:return: :return:
""" """
from skimage.measure import compare_ssim as ssim # import here to avoid static TLS import error
if image0.dtype != image1.dtype: if image0.dtype != image1.dtype:
image0 = image0.astype(np.int16) image0 = image0.astype(np.int16)
image1 = image1.astype(np.int16) image1 = image1.astype(np.int16)
......
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