A median filter replaces each pixel with the median value of its neighboring pixels, while a mean filter replaces it with the average. Median filters are often better at preserving edges.