# How do I apply an image filter row by row

I'm new to Mathematica and I'm probably not using the right keywords to seek for help on this topic.

I would like to filter an image row by row, and I'm trying to work this out using ImageData but I can't figure how I can call a MeanFilter for each row and put the result back into an image.

Any help will be much appreciated!

• Use the second argument of MeanFilter: MeanFilter[image, {0, r}] – C. E. Jan 16 '17 at 9:26
• Thanks a lot, however I want my radius to be a function of the row indice (I have a polar image for which I want to blur more when being far from the center) – Julien M Jan 16 '17 at 9:34
• you can also do this with ImageFilter making your filter function operate only on the center row. Not sure how that will compare performamce-wise.. – george2079 Jan 16 '17 at 15:26
• actually the ImageFilter form is just this: ImageFilter[Mean@First@# &, image, {0, r}] – george2079 Jan 20 '17 at 21:14

## 1 Answer

Thanks to Kuba I came up with this:

polar = ExampleData[{"TestImage", "Lena"}];
parts = ImagePartition[polar, {ImageDimensions[polar][[1]], 1}];
f[p_, {x_, y_}] := MedianFilter[p, {1, 5 + IntegerPart[x/5]}]
medPolar = ImageAssemble[MapIndexed[f, parts, {2}]]