Hi Alison,
there are two possibilities.
The easiest is the one you get from the macro recorder in 'PlugIn' mode:
IJ.run(imp, "Variance...", "radius=1 stack");
(radius=1 gives you a 3x3 kernel. "stack" is needed only if you want
to process the full image stack, in case imp is one).
The other way of doing it also works if the image is locked (e.g., if
you write a PlugInFilter) and it does not need an extra undo buffer:
RankFilters rf = new RankFilters();
rf.rank(imp.getProcessor(), 1.0, RankFilters.VARIANCE, 0, 0.);
If it is a stack, you have to execute rf.rank in a loop over all slices.
Please make sure you upgrade ImageJ to 1.45k or the latest daily
build, there was a bug (caused by me) in the RankFilters.rank()
method of 1.45j.
Michael
________________________________________________________________
On 21 Jul 2011, at 02:09, Alison Payne wrote:
> Hi,
>
> I am trying to call the standard variance filter from within an
> ImageJ plugin.
>
> I have found the RankFilters class, but don't seem to be able to
> form a valid call to it from my plugin.
>
> I have an image of type ImagePlus, and I want to perform a 3x3
> variance filter on it.
>
> How do I do this?
>
> Alison