Git Product home page Git Product logo

example-imagej2-command's Introduction

ImageJ

ImageJ is public domain software for processing and analyzing scientific images.

It is written in Java, which allows it to run on many different platforms.

For further information, see:

Using ImageJ as a dependency

To use ImageJ as a library in your Maven project, add the dependency:

<dependency>
  <groupId>net.imagej</groupId>
  <artifactId>ij</artifactId>
  <version>1.53j</version>
</dependency>

Where 1.53j is the version of ImageJ you would like to use:

Building from source

With Ant

The Apache Ant utility will compile and run ImageJ using the build.xml file in this directory. There is a version of Ant at

https://imagej.nih.gov/ij/download/tools/ant/ant.zip

set up to use the JVM distributed with the Windows version of ImageJ. The README included in the ZIP archive has more information.

With Maven

You can compile and run ImageJ using the Maven build tool:

Command Action
mvn Compile and package ImageJ into a JAR file in the target directory.
mvn -Pexec Compile and then run ImageJ.
mvn javadoc:javadoc Generate the project Javadoc in the target/apidocs directory.

example-imagej2-command's People

Contributors

ctrueden avatar imagejan avatar laulauthom avatar panovr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

example-imagej2-command's Issues

The Img<T> to array

Hi, I'm developing a very simple plug-in. I'm not very familiar with Java or ImageJ, so there is a problem in my code:
I have writter a median filterting function, however, the type of data cannot be recognized (Img ).

Here is my code:

package com.HIT.Weisong;
import net.imagej.Dataset;
import net.imagej.ImageJ;
import net.imagej.ops.OpService;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.Img;
import net.imglib2.type.numeric.RealType;
import org.scijava.command.Command;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
import org.scijava.ui.UIService;

import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This example illustrates how to create an ImageJ {@link Command} plugin.
 * <p>
 * The code here is a simple Gaussian blur using ImageJ Ops.
 * </p>
 * <p>
 * You should replace the parameter fields with your own inputs and outputs,
 * and replace the {@link run} method implementation with your own logic.
 * </p>
 */
@Plugin(type = Command.class, menuPath = "Plugins>Gauss Filtering")
public class SparseHessianReconstruction<T extends RealType<T>> implements Command {
	//
	// Feel free to add more parameters here...
	//

	@Parameter
	private Dataset currentData;

	@Parameter
	private UIService uiService;

	@Parameter
	private OpService opService;

	@Override
	public void run() {

		final Img<T> image = (Img<T>)currentData.getImgPlus();

		//
		// Enter image processing code here ...
		// The following is just a Gauss filtering example
		//

		List<RandomAccessibleInterval<T>> results = new ArrayList<>();
                 results.add(medianFiltering(image,3,3)); 


	// display result
	for (RandomAccessibleInterval<T> elem : results)
	{
		uiService.show(elem);
	}
}

public static int[] medianFiltering(int pix[], int w, int h) {  
	int newpix[] = new int[w*h];  
	int[] temp = new int[9];  
	ColorModel cm = ColorModel.getRGBdefault();  
	int r=0;  
	for(int y=0; y<h; y++) {  
		for(int x=0; x<w; x++) {  
			if(x!=0 && x!=w-1 && y!=0 && y!=h-1) {  
				//g = median[(x-1,y-1) + f(x,y-1)+ f(x+1,y-1)  
				//  + f(x-1,y) + f(x,y) + f(x+1,y)  
				//  + f(x-1,y+1) + f(x,y+1) + f(x+1,y+1)]                     
				temp[0] = cm.getRed(pix[x-1+(y-1)*w]);   
				temp[1] = cm.getRed(pix[x+(y-1)*w]);  
				temp[2] = cm.getRed(pix[x+1+(y-1)*w]);  
				temp[3] = cm.getRed(pix[x-1+(y)*w]);  
				temp[4] = cm.getRed(pix[x+(y)*w]);  
				temp[5] = cm.getRed(pix[x+1+(y)*w]);  
				temp[6] = cm.getRed(pix[x-1+(y+1)*w]);  
				temp[7] = cm.getRed(pix[x+(y+1)*w]);  
				temp[8] = cm.getRed(pix[x+1+(y+1)*w]);  
				Arrays.sort(temp);  
				r = temp[4];  
				newpix[y*w+x] = 255<<24 | r<<16 | r<<8 |r;  
			} else {  
				newpix[y*w+x] = pix[y*w+x];  
			}  
		}  
	}  
	return newpix;  
}   


/**
 * This main function serves for development purposes.
 * It allows you to run the plugin immediately out of
 * your integrated development environment (IDE).
 *
 * @param args whatever, it's ignored
 * @throws Exception
 */
public static void main(final String... args) throws Exception {
	// create the ImageJ application context with all available services
	final ImageJ ij = new ImageJ();
	ij.ui().showUI();

	// ask the user for a file to open
	final File file = ij.ui().chooseFile(null, "open");

	if (file != null) {
		// load the dataset
		final Dataset dataset = ij.scifio().datasetIO().open(file.getPath());

		// show the image
		ij.ui().show(dataset);

		// invoke the plugin
		ij.command().run(SparseHessianReconstruction.class, true);
	}
}

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.