From f3a1a9ed7ed278508d6ba1b0d492310b114cd534 Mon Sep 17 00:00:00 2001 From: Neeraj Gangwar Date: Sat, 15 Mar 2014 10:42:50 +0530 Subject: [PATCH 1/2] corrected the formula to calculate the location of offset pixel in _texture.pyx --- skimage/feature/_texture.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/skimage/feature/_texture.pyx b/skimage/feature/_texture.pyx index ec83fa65..8937afd8 100644 --- a/skimage/feature/_texture.pyx +++ b/skimage/feature/_texture.pyx @@ -4,7 +4,7 @@ #cython: wraparound=False import numpy as np cimport numpy as cnp -from libc.math cimport sin, cos, abs +from libc.math cimport sin, cos, abs, floor from skimage._shared.interpolation cimport bilinear_interpolation @@ -48,8 +48,8 @@ def _glcm_loop(cnp.uint8_t[:, ::1] image, double[:] distances, i = image[r, c] # compute the location of the offset pixel - row = r + (sin(angle) * distance + 0.5) - col = c + (cos(angle) * distance + 0.5) + row = r + floor(sin(angle) * distance + 0.5) + col = c + floor(cos(angle) * distance + 0.5) # make sure the offset is within bounds if row >= 0 and row < rows and \ From 7a164d274d47a15c381ed191c093b9694c66d4e9 Mon Sep 17 00:00:00 2001 From: Neeraj Gangwar Date: Mon, 17 Mar 2014 09:53:09 +0530 Subject: [PATCH 2/2] minor changes in syntax in _glcm_loop method. Using round in place of floor in _texture.pyx to calculate the pixel offset. --- skimage/feature/_texture.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skimage/feature/_texture.pyx b/skimage/feature/_texture.pyx index 8937afd8..67f425f7 100644 --- a/skimage/feature/_texture.pyx +++ b/skimage/feature/_texture.pyx @@ -4,8 +4,8 @@ #cython: wraparound=False import numpy as np cimport numpy as cnp -from libc.math cimport sin, cos, abs, floor -from skimage._shared.interpolation cimport bilinear_interpolation +from libc.math cimport sin, cos, abs +from skimage._shared.interpolation cimport bilinear_interpolation, round def _glcm_loop(cnp.uint8_t[:, ::1] image, double[:] distances, @@ -48,8 +48,8 @@ def _glcm_loop(cnp.uint8_t[:, ::1] image, double[:] distances, i = image[r, c] # compute the location of the offset pixel - row = r + floor(sin(angle) * distance + 0.5) - col = c + floor(cos(angle) * distance + 0.5) + row = r + round(sin(angle) * distance) + col = c + round(cos(angle) * distance) # make sure the offset is within bounds if row >= 0 and row < rows and \