Standard Deviation of a Image

maven
fiji
imagej
plugin

#1

Hi all,

Sorry to disturb you all with a same kind of question again. I want to find the Standard deviation of a image in matlab it can perform with command stdfilt . And the same thing can be perform in Fiji also.

To be very clear now I need to use this in my own java project. So I tried typical methods as follows

IJ.run(Imgage, "StandardDeviation", "block_radius_x=3 block_radius_y=3");

ij.IJ.runPlugIn(Imgage, "StandardDeviation", "block_radius_x=3 block_radius_y=3");

IJ.doCommand(ImgMutiplied, "StandardDeviation");

Finally…!

mpicbg.ij.plugin.StandardDeviation SD = new mpicbg.ij.plugin.StandardDeviation();
SD(Imgage);

mpicbg.ij.plugin.StandardDeviation SD = new mpicbg.ij.plugin.StandardDeviation();
SD.Image;

When I use following methods no errors can be seen in the programme but the required action wont perform on the image.

IJ.run(Imgage, "StandardDeviation", "block_radius_x=3 block_radius_y=3");

ij.IJ.runPlugIn(Imgage, "StandardDeviation", "block_radius_x=3 block_radius_y=3");

IJ.doCommand(ImgMutiplied, "StandardDeviation");

But

> Unrecognized command: “StandardDeviation” message can be seen in the screen. Further I have set up the maven correctly and here is the .jar file which contain this class. Is there other ways of performing this task???

Further this action works very well in the Fiji . When we use following steps.
**

Plugins › Integral Image Filters › Standard Deviation

**

Hope some one can solve this matter.

Best regards.


#2

Good day,

sorry but I can’t follow your many posted lines but here is what should work:

std = imp.getProcessor().getStatistics().stdDev;

HTh

Herbie


#3

Hey @Denuwan

I just recorded this call in Java using the Recorder

and I think there is just a minor ‘mistake’ in yours…
IJ.run(imp, "Standard Deviation", "block_radius_x=40 block_radius_y=40"); Make sure there is a space in the "Standard Deviation" call.

See if that fixes things for you??

eta


#4

Sorry to say I have tried this also. It will give following error.

**

Unrecognized command: “Standard Deviation”

**

For imagej core plugins (which are in the ij.jar file) above recording method work perfectly. Further the following command will call the plugin and will pop up in the run time and in the run time user have to enter the parameters in my case all the steps should be perform automatically therefore parameters should give in the programming phase.

`

ij.IJ.runPlugIn(ImgMutiplied, “mpicbg.ij.plugin.StandardDeviation”, “block_radius_x=3 block_radius_y=3”);

`
anyway thank you for the reply


#5

Thank you very much. But I want to get a result as follows. I thing your function returns a value??


#6

My bad,

because the thread title says “Standard Deviation of an Image” I thought you want exactly that which is a number.

However, you are interested in a filter process that is directly related to the Variance-filtering available in ImageJ. ImageJ-1 doesn’t provide a “STD”-filter.

So perhaps have a look at:
https://imagej.nih.gov/ij/developer/api/ij/plugin/Filters3D.html

I guess the 3D-filters work in 2D as well.

HTH

Herbie


#7

Thank you very much I will look in to it…!


#8

I don’t know if it can help you with this kind of problems you are having…
but a solution that I have had usually adopted it’s to setup the plugins directory

Like explained more in details in this post:

I think that in that way you will be able to launch it via
IJ.run(imp, “Standard Deviation”, “block_radius_x=40 block_radius_y=40”);

hoping to being helpful,
have a nice day
Emanuele


#9

You mean I need to set the path for the external library ? I am afraid I have done that. :slightly_frowning_face::slightly_frowning_face:


#10

I mean you have to do that
String pluginsDir = “/Applications/Fiji.app/plugins”; //!!! THIS IS THE SETTING PART !!!
System.setProperty(“plugins.dir”, pluginsDir);

putting in the pluginsdir the path to your plugins Fiji directory.

it’s of course different respect to import the module and use it directly in your code.
but for this second approach I really think you have to search a lot in the java sources of mpicbg to find the correct implementation and methods to get your standard deviation image.

using the approach I’ve suggested you will call obtain it simply using the
IJ.run(… ) way


#11

@Denuwan

FYI, I’m pretty sure you want the mpicbg.ij.integral.BlockStatistics class (see below).

this contructor:
public BlockStatistics( final FloatProcessor fp )

and this method:
final public void std( final int blockRadiusX, final int blockRadiusY )

At first glance, it seems that it works only on FloatProcessors and the imageJ plugin version will convert images to float (or make a copy).


#12

Ah I am sorry I have misunderstand your previous answer. thank you very much for the answer. If you have time can you please give me the complete code to do that. I tried with replacing the path to my plugin folder. lot of errors were there. I haven’t done this before. thank you for your valuable time.


#13

Thank you very much for spending your time to find a solution. I’m sure this is what I wanted. I am sure it will not be a big deal to create the Float Processor of the image (I haven’t try it yet). Thank you again.


#14

If you have played with FloatProcessor . Can you tell me, whether is there a direct way to convert a ImageProcessor to a FloatProcessor?


#15

Please be sure to:

  1. have the Standard Deviation filter plugin in your Fiji installation (I mean it has to work if you launch it in Fiji application)


  2. NOW IN ECLIPSE!
    You have of course to setup your code accordingly to the fact that now you are launching
    IJ.run(Imgage, “StandardDeviation”, “block_radius_x=3 block_radius_y=3”);
    and no more the “Sigma Filter Plus” as in the example I’ve posted.
    so first of all
    change that line (in my case the number 20) to your plugin “Standard Deviation” with its arguments


    Secondly in the main part be sure you have called with the same name the plugin on the code (the right part of the picture, line 36) and the one in the Projects tree (Package Explorer) on the left of the Eclipse Environment.

Now it will work, I hope :wink:
I’ve just tried it and it has worked fine.

As I wrote in the link posted this project was built using the maven way, I don’t think it’s necessary for a simple example like that but please refer to:


It will give you some tricks and a good way to setup a Project in Eclipse.

  1. please be sure you are getting what you are doing using this way to call your plugin:
    You will need to know where it’s the Fiji application and in the Fiji application the Standard Deviation plugin has to be installed.
    The elegant and more nice way (moreover if you need to call it from a standalone program, and not from Fiji itself) it’s to browse and try to understand which is/are the class/classes that do that in the mpicbg Java sources and @bogovicj helped you a lot on this :wink: and then import directly that.
    I usually use the way I am suggesting you when I will need to debug my code (using Eclipse) to develop a plugin to be used in Fiji.

I hope that now it’s clearer and it is helpful,
Emanuele


#16

My two cents before I give a tip.

In general, I think it’s “safer” to go with the method @emartini is helping you with, namely by calling the plugin with IJ.run(...). Safer in the sense that you can be sure that you’re calling a plugin in the way the developer intended and without skipping any steps. Will there be benefits to calling the “fundamental” function? Sure. (e.g. possibly fewer dependencies). I happen to know the mpicbg library and could dig through the code quickly and find the above. but…

When calling a plugin, I would lean toward using IJ.run(...)


imageProcessor.convertToFloat
See here:


#17

Dear @emartini and @bogovicj thank you very much for wasting your valuable time on this matter. I also like @emartini method since it is easy. and I am not much in to this coding thing But when I try that thing the drawback I saw in my point of view is opening the imagej window. In my programme there is a small GUI designed by me and to make this project success I need to stick in to it. In that case I will try @bogovicj method. Another advantage of @emartini method is it can use to any other plugin also. But when it come to other way I have to spend more time on developers code and understand it 1st. which I failed to do last time. and @bogovicj gave me a great help on solving that. To be honest I love this community when I start this project I had 0 knowledge on imagej and small knowledge on java (my major is Physics) with the help of this community and the detailed documents published on the imagej site I learnt a lot. Thank you I really appreciate the help any beginner gain form this community.


#18

try to remove the line 40
new ImageJ();
this is the line that launch the imageJ GUI.
I think it will do the trick!

and I really appreciate when helped people are thankful :wink:

I also learnt a lot from this community
have a nice day
Emanuele


#19

Ah that is a excellent trick. I will clarify one last thing. lets say after develop the whole thing we are going to give the programme to another person (lets say the research supervisor :wink: ) So then the path will be changed in his or her computer. So if we place this plugin in a sub folder where all the codes are, can we overcome the above problem. I didnt try yet. asking because I hope you have experiance…:blush::blush:


#20

Unfortunately I haven’t experience on that.
But now I am really curious to see how this will end up :wink: