diff --git a/scikits/image/io/_plugins/_colormixer.pyx b/scikits/image/io/_plugins/_colormixer.pyx index 48450473..25767f66 100644 --- a/scikits/image/io/_plugins/_colormixer.pyx +++ b/scikits/image/io/_plugins/_colormixer.pyx @@ -185,6 +185,8 @@ def gamma(np.ndarray[np.uint8_t, ndim=3] img, cdef int i, j + if gamma == 0: + gamma = 0.00000000000000000001 gamma = 1./gamma with nogil: @@ -199,7 +201,7 @@ def gamma(np.ndarray[np.uint8_t, ndim=3] img, img[i,j,2] = (pow(b, gamma) * 255) - +@cython.cdivision(True) cdef void rgb_2_hsv(float* RGB, float* HSV) nogil: cdef float R, G, B, H, S, V, MAX, MIN R = RGB[0] @@ -261,7 +263,7 @@ cdef void rgb_2_hsv(float* RGB, float* HSV) nogil: HSV[1] = S HSV[2] = V - +@cython.cdivision(True) cdef void hsv_2_rgb(float* HSV, float* RGB) nogil: cdef float H, S, V cdef float f, p, q, t, r, g, b diff --git a/scikits/image/io/_plugins/util.py b/scikits/image/io/_plugins/util.py index 40f6e92b..a9936bdc 100644 --- a/scikits/image/io/_plugins/util.py +++ b/scikits/image/io/_plugins/util.py @@ -202,21 +202,21 @@ class ThreadDispatch(object): self.chunks.append((img, stateimg)) elif self.cores >= 4: - self.chunks.append((img[:(height/2), :(width/2), :], - stateimg[:(height/2), :(width/2), :])) - self.chunks.append((img[:(height/2), (width/2):, :], - stateimg[:(height/2), (width/2):, :])) - self.chunks.append((img[(height/2):, :(width/2), :], - stateimg[(height/2):, :(width/2), :])) - self.chunks.append((img[(height/2):, (width/2):, :], - stateimg[(height/2):, (width/2):, :])) + self.chunks.append((img[:(height/4), :, :], + stateimg[:(height/4), :, :])) + self.chunks.append((img[(height/4):(height/2), :, :], + stateimg[(height/4):(height/2), :, :])) + self.chunks.append((img[(height/2):(3*height/4), :, :], + stateimg[(height/2):(3*height/4), :, :])) + self.chunks.append((img[(3*height/4):, :, :], + stateimg[(3*height/4):, :, :])) # if they dont have 1, or 4 or more, 2 is good. else: - self.chunks.append((img[:, :(width/2), :], - stateimg[:, :(width/2), :])) - self.chunks.append((img[:, (width/2):, :], - stateimg[:, (width/2):, :])) + self.chunks.append((img[:(height/2), :, :], + stateimg[:(height/2), :, :])) + self.chunks.append((img[(height/2):, :, :], + stateimg[(height/2):, :, :])) for i in range(self.cores): self.threads.append(ImgThread(func, self.chunks[i][0],