Create empty image with arbitrary dimensions

java

#1

Hey guys,

yes, I have read the examples, but if you examine them, you’ll notice that actually all new images are created upon existing ones. As every possibly fitting method I found expects the type “Dimension” which I do not know how to create, here is my question:

I want to have space reserved for an 3D image (e.g. Img or RandomAccessibleInterval) with dimensions of:

X=2048
Y=2048
Z=100

How would I do that without any other image given in the first place? By the way, god knows I tried a lot of things before asking this question (so feel free to explain to me what e.g. the CellImgFactory Type cellsize actually does). Thank you in advance.


#2

Good day,

you may use the ImageJ recoder with “Record:” set to Java.

This gives me for the desired stack with 8bit gray level:

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;

public class My_Plugin implements PlugIn {

	public void run(String arg) {
		ImagePlus imp = IJ.createImage("KansasCityShuffle", "8-bit black", 2048, 2048, 100);
		imp.show();
	}

}

Regards

Herbie


#3

Thanks again Herbie,

to avoid a premature answer I tried the last 30min to apply your example. My last try was to just copy your minimal example into an empty fresh file. Neither the type ImagePlus nor IJ is recognized. I also tried to create an Instance IJ (of Type ImageJ) but no luck. I guess my whole setup differs quite a lot as my class did not import any of your libraries to this point.

Would be glad if there is another option with Img<T> (as practically everything in my code is either an Img<T> or RandomAccessibleInterval<T>)


#4

Well, of course my suggestion is plain ImageJ plugin style but it is easy to implement and works like a charm!

Please download the following ZIP-archive, un-zip it and install the plugin in your ImageJ-installation. If you are using Fiji, go to “Plugins >> Install Plugin…” to install.
My_Plugin.zip (507 Bytes)

Run the plugin “My_Plugin” from the “Plugins”-menu.

If you need more information on “plain ImageJ plugin style”-coding, study this tutorial:
https://imagingbook.files.wordpress.com/2013/06/tutorial171.pdf

Regards

Herbie


Regular Discrete Fourier Transform (DFT)
#5

Thanks for the hint. Instead of downloading it, I have added some of the ImageJ 1.x libraries via pom.xml as the only dependency in the example-imagej-command-pom was net.imagej >> imagej

Now your example works like a charm, Herbie. :v:

Dependencies in my pom are now as follows (for others who may come along):

<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej</artifactId>
</dependency>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij</artifactId>
</dependency>
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2-ij</artifactId>
</dependency>
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2-algorithm</artifactId>
<version>0.10.0</version>
</dependency>


#6

Good day,

coding the ImageJ-1 style doesn’t require such overhead as POM etc. Just compile the provided code snippet by “Plugins >> Compile and Run…” in plain ImageJ (doesn’t work with FIJI for whatever reasons). The required libraries were already called in the snippet.

Regards

Herbie