[Image-SIG] ImageFilter.MaxFilter and MedianFilter
Dominik Royko
droyko at uottawa.ca
Fri Jan 23 16:07:52 EST 2004
I noticed that images filtered with ImageFilter.MedianFilter(3)
differed from those filtered with ImageFilter.RankFilter(3,4).
(Rank values seem to go from 0 to (size*2)-1).
Further inspection reveals:
>>> ImageFilter.MaxFilter(3).rank
2
>>> ImageFilter.MaxFilter(5).rank
4
>>> ImageFilter.MedianFilter(3).rank
1
>>> ImageFilter.MedianFilter(5).rank
2
Should these not be 4, 12, & 8, 24? Am I missing something?
Suggested patch follows.
Dominik Royko.
--- PIL/ImageFilter.py 2002-11-17 13:55:42.000000000 -0500
+++ PIL-patch/ImageFilter.py 2004-01-23 15:27:16.000000000 -0500
@@ -92,7 +92,7 @@ class MedianFilter(RankFilter):
def __init__(self, size=3):
self.size = size
- self.rank = size/2
+ self.rank = (size*size)/2
##
# Min filter. Picks the lowest pixel value in a window with the given
@@ -124,7 +124,7 @@ class MaxFilter(RankFilter):
def __init__(self, size=3):
self.size = size
- self.rank = size-1
+ self.rank = (size*size)-1
##
# Mode filter. Picks the most frequent pixel value in a box with the
More information about the Image-SIG
mailing list