Doesn't exist on ImageMagick 7 - write equivalant median_image=StatisticImage(image,MedianStatistic,(size_t) radius,(size_t) radius,exception);
function medianFilterImage($radius, $image_path)
{
    $imagick = new \Imagick(realpath($image_path));
    @$imagick->medianFilterImage($radius);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}