mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-21 12:50:27 +08:00
Merge branch 'threadingio' of git://github.com/sccolbert/scikits.image into io
This commit is contained in:
@@ -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] = <np.uint8_t>(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
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user