Median resize
Posted: 2017-03-22T14:26:00-07:00
I've been reading the examples but can't make head or tails of this thing, which is probably simple for someone much smarter than me..
The end result I seek is to coalesce each 5x5 pixel square into 1 pixel that's the median of those 25 pixels. (The median of input pixels {0,0}-{4,4} become output pixel {0,0}, the median of input pixels {5,0}-{9,4} become output pixel {1,0}, etc.) The resulting image will be 1/5 width and 1/5 height of the input image.
My first idea was to use -fx with Median on all pixels and then a Point resize, but I can't figure out how to use Median on an area.
My second idea was to duplicate the image 24 times, shifting it a bit each time, and then running a Median on the sequence, but I can't wrap my head around how that works. (And this also might be quite inefficient?)
If nothing else I could just use the API to extract raw pixels using one of the programming language bindings and do it manually, but I would prefer to do the operation as efficiently as possible, and in a "magick way" if possible.
(I could use any version, but currently using 6.8.9-9 Q16 x86_64 2017-03-14.)
The end result I seek is to coalesce each 5x5 pixel square into 1 pixel that's the median of those 25 pixels. (The median of input pixels {0,0}-{4,4} become output pixel {0,0}, the median of input pixels {5,0}-{9,4} become output pixel {1,0}, etc.) The resulting image will be 1/5 width and 1/5 height of the input image.
My first idea was to use -fx with Median on all pixels and then a Point resize, but I can't figure out how to use Median on an area.
My second idea was to duplicate the image 24 times, shifting it a bit each time, and then running a Median on the sequence, but I can't wrap my head around how that works. (And this also might be quite inefficient?)
If nothing else I could just use the API to extract raw pixels using one of the programming language bindings and do it manually, but I would prefer to do the operation as efficiently as possible, and in a "magick way" if possible.
(I could use any version, but currently using 6.8.9-9 Q16 x86_64 2017-03-14.)