add comment

This commit is contained in:
Olivier Debeir
2012-10-10 14:30:29 +02:00
parent 86449613e4
commit a07d0f64bb
3 changed files with 30 additions and 7 deletions
+14 -1
View File
@@ -1,4 +1,17 @@
"""
"""percentile_rank.py - inferior and superior ranks, provided by the user, are passed to the kernel function
to provide a softer version of the rank filters. E.g. percentile_autolevel will stretch image levels between
percentile [p0,p1] instead of using [min,max]. It means that isolate bright or dark pixels will not produce halos.
The local histogram is computed using a sliding window similar to the method described in
Reference: Huang, T. ,Yang, G. ; Tang, G.. "A fast two-dimensional median filtering algorithm",
IEEE Transactions on Acoustics, Speech and Signal Processing, Feb 1979. Volume: 27 , Issue: 1, Page(s): 13 - 18.
input image can be 8 bit or 16 bit with a value < 4096 (i.e. 12 bit),
for 16 bit input images, the number of histogram bins is determined from the maximum value present in the image
result image is 8 or 16 bit with respect to the input image
:author: Olivier Debeir, 2012
:license: modified BSD
"""
+6 -1
View File
@@ -1,10 +1,15 @@
"""rank.py - rankfilter for local (custom kernel) maximum, minimum, median, mean, auto-level, egalize, etc
"""rank.py - rankfilter for local (custom kernel) maximum, minimum, median, mean, auto-level, equalization, etc
The local histogram is computed using a sliding window similar to the method described in
Reference: Huang, T. ,Yang, G. ; Tang, G.. "A fast two-dimensional median filtering algorithm",
IEEE Transactions on Acoustics, Speech and Signal Processing, Feb 1979. Volume: 27 , Issue: 1, Page(s): 13 - 18.
input image can be 8 bit or 16 bit with a value < 4096 (i.e. 12 bit),
for 16 bit input images, the number of histogram bins is determined from the maximum value present in the image
result image is 8 or 16 bit with respect to the input image
:author: Olivier Debeir, 2012
:license: modified BSD
"""
+10 -5
View File
@@ -25,7 +25,7 @@ def ctmf_med(image,radius):
return median_filter(image=image,radius=radius)
def compare():
def compare_dilate():
"""comparison between
- crank.maximum rankfilter implementation
- cmorph.dilate cython implementation
@@ -88,9 +88,9 @@ def compare_median():
a = data.camera()
rec = []
e_range = range(2,40,2)
e_range = range(2,40,4)
for r in e_range:
elem = np.ones((2*r,2*r),dtype='uint8')
elem = np.ones((2*r+1,2*r+1),dtype='uint8')
# elem = (np.random.random((r,r))>.5).astype('uint8')
rc,ms_rc = cr_med(a,elem)
rctmf,ms_rctmf = ctmf_med(a,r)
@@ -106,9 +106,11 @@ def compare_median():
plt.legend(['rank.median','ctmf.median_filter'])
plt.figure()
plt.imshow(np.hstack((rc,rctmf)))
plt.show()
plt.ylabel('time (ms)')
plt.xlabel('element radius')
r = 9
elem = np.ones((r,r),dtype='uint8')
elem = np.ones((r*2+1,r*2+1),dtype='uint8')
rec = []
s_range = range(100,1000,100)
@@ -127,7 +129,10 @@ def compare_median():
plt.legend(['rank.median','ctmf.median_filter'])
plt.figure()
plt.imshow(np.hstack((rc,rctmf)))
plt.ylabel('time (ms)')
plt.xlabel('image size')
plt.show()
if __name__ == '__main__':
# compare_dilate()
compare_median()