2
$\begingroup$

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!

$\endgroup$
4
  • 1
    $\begingroup$ Use the second argument of MeanFilter: MeanFilter[image, {0, r}] $\endgroup$
    – C. E.
    Commented Jan 16, 2017 at 9:26
  • $\begingroup$ 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) $\endgroup$
    – Julien M
    Commented Jan 16, 2017 at 9:34
  • $\begingroup$ 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.. $\endgroup$
    – george2079
    Commented Jan 16, 2017 at 15:26
  • $\begingroup$ actually the ImageFilter form is just this: ImageFilter[Mean@First@# &, image, {0, r}] $\endgroup$
    – george2079
    Commented Jan 20, 2017 at 21:14

1 Answer 1

2
$\begingroup$

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}]]

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.