mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-05 10:16:52 +08:00
fix error in autolevel and percentile autolevel (16bit)
This commit is contained in:
@@ -33,7 +33,7 @@ cdef inline np.uint16_t kernel_autolevel(Py_ssize_t* histo, float pop, np.uint16
|
||||
|
||||
delta = imax-imin
|
||||
if delta>0:
|
||||
return <np.uint16_t>(255*(int_min(int_max(imin,g),imax)-imin)/delta)
|
||||
return <np.uint16_t>(1.0*(maxbin-1)*(int_min(int_max(imin,g),imax)-imin)/delta)
|
||||
else:
|
||||
return <np.uint16_t>(imax-imin)
|
||||
else:
|
||||
|
||||
@@ -16,15 +16,22 @@ if __name__ == '__main__':
|
||||
f16= rank.autolevel(a16,selem)
|
||||
f16p= rank.percentile_autolevel(a16,selem,p0=.0,p1=1.)
|
||||
|
||||
print f8==f16
|
||||
print f16==f16p
|
||||
|
||||
plt.figure()
|
||||
plt.subplot(1,2,1)
|
||||
plt.subplot(1,3,1)
|
||||
plt.imshow(f16)
|
||||
plt.subplot(1,2,2)
|
||||
plt.colorbar()
|
||||
plt.subplot(1,3,2)
|
||||
plt.imshow(f16p)
|
||||
plt.colorbar()
|
||||
plt.subplot(1,3,3)
|
||||
plt.imshow(f16p-f16)
|
||||
plt.colorbar()
|
||||
plt.show()
|
||||
|
||||
print f16
|
||||
print f16p
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user