Skip to content

Commit

Permalink
first modification
Browse files Browse the repository at this point in the history
  • Loading branch information
trinhtuananh committed May 24, 2016
1 parent 01bc3c2 commit ed7beee
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 30 deletions.
84 changes: 54 additions & 30 deletions src/main/java/ijfx/plugins/UnwarpJ/UnwarpJ_.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import ij.process.ImageConverter;
import ij.process.ImageProcessor;
import ij.process.ShortProcessor;
import ijfx.plugins.AbstractImageJ1PluginAdapter;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Canvas;
Expand Down Expand Up @@ -128,6 +129,12 @@
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.Vector;
import net.imagej.Dataset;
import org.scijava.ItemIO;
import org.scijava.command.Command;
import org.scijava.plugin.Attr;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

/*====================================================================
| UnwarpJ_
Expand All @@ -136,20 +143,28 @@
This is the one called by ImageJ */

/*------------------------------------------------------------------*/
public class UnwarpJ_
implements
PlugIn

{ /* begin class UnwarpJ_ */
@Plugin(type = Command.class, menuPath = "Plugins>UnwarpJ")
public class UnwarpJ_ extends AbstractImageJ1PluginAdapter {
@Parameter
protected Dataset dataset;
@Parameter(label = "Source")
Dataset source;

@Parameter(label = "Target")
Dataset target;
/* begin class UnwarpJ_ */

/*....................................................................
Public methods
....................................................................*/

/*------------------------------------------------------------------*/
public void run (
final String commandLine
) {
@Override
public void run()
{
setWholeWrap(true);
final String commandLine ="";
String options = Macro.getOptions();
if (!commandLine.equals("")) options = commandLine;
if (options == null) {
Expand All @@ -175,10 +190,12 @@ public void run (
}
return;
}
} /* end run */
//} /* end run */
//
///*------------------------------------------------------------------*/
//public static void main(String args[]) {
String []args= new String("unwarpj -align target.jpg NULL source.jpg NULL 0 2 1 1 0 output.tif 1 landmarks.txt").split(" ");

/*------------------------------------------------------------------*/
public static void main(String args[]) {
if (args.length<1) {
dumpSyntax();
System.exit(1);
Expand All @@ -195,7 +212,7 @@ public static void main(String args[]) {
....................................................................*/

/*------------------------------------------------------------------*/
private static void alignImagesMacro(String args[]) {
private void alignImagesMacro(String args[]) {

if(args.length < 11)
{
Expand All @@ -210,9 +227,9 @@ private static void alignImagesMacro(String args[]) {
if (jpeg_output) args_len--;

// Read input parameters
String fn_target=args[1];
// String fn_target=args[1];
String fn_target_mask=args[2];
String fn_source=args[3];
// String fn_source=args[3];
String fn_source_mask=args[4];
int min_scale_deformation=((Integer) new Integer(args[5])).intValue();
int max_scale_deformation=((Integer) new Integer(args[6])).intValue();
Expand All @@ -231,19 +248,19 @@ private static void alignImagesMacro(String args[]) {
stopThreshold=((Double) new Double(args[13])).doubleValue();

// Show parameters
IJ.write("Target image : "+fn_target);
IJ.write("Target mask : "+fn_target_mask);
IJ.write("Source image : "+fn_source);
IJ.write("Source mask : "+fn_source_mask);
IJ.write("Min. Scale Deformation : "+min_scale_deformation);
IJ.write("Max. Scale Deformation : "+max_scale_deformation);
IJ.write("Div. Weight : "+divWeight);
IJ.write("Curl Weight : "+curlWeight);
IJ.write("Image Weight : "+imageWeight);
IJ.write("Output: : "+fn_out);
IJ.write("Landmark Weight : "+landmarkWeight);
IJ.write("Landmark file : "+fn_landmark);
IJ.write("JPEG Output : "+jpeg_output);
// IJ.write("Target image : "+fn_target);
// IJ.write("Target mask : "+fn_target_mask);
// IJ.write("Source image : "+fn_source);
// IJ.write("Source mask : "+fn_source_mask);
// IJ.write("Min. Scale Deformation : "+min_scale_deformation);
// IJ.write("Max. Scale Deformation : "+max_scale_deformation);
// IJ.write("Div. Weight : "+divWeight);
// IJ.write("Curl Weight : "+curlWeight);
// IJ.write("Image Weight : "+imageWeight);
// IJ.write("Output: : "+fn_out);
// IJ.write("Landmark Weight : "+landmarkWeight);
// IJ.write("Landmark file : "+fn_landmark);
// IJ.write("JPEG Output : "+jpeg_output);

// Produce side information
int imagePyramidDepth=max_scale_deformation-min_scale_deformation+1;
Expand All @@ -260,8 +277,8 @@ private static void alignImagesMacro(String args[]) {

// Open target
Opener opener=new Opener();
ImagePlus targetImp;
targetImp=opener.openImage(fn_target);
ImagePlus targetImp = this.getInput(this.dataset);
// targetImp=opener.openImage(fn_target);
unwarpJImageModel target =
new unwarpJImageModel(targetImp.getProcessor(), true);
target.setPyramidDepth(imagePyramidDepth+min_scale_image);
Expand All @@ -273,8 +290,8 @@ private static void alignImagesMacro(String args[]) {
unwarpJPointHandler targetPh=null;

// Open source
ImagePlus sourceImp;
sourceImp=opener.openImage(fn_source);
ImagePlus sourceImp = getInput(dataset);
// sourceImp=opener.openImage(fn_source);
unwarpJImageModel source =
new unwarpJImageModel(sourceImp.getProcessor(), false);
source.setPyramidDepth(imagePyramidDepth+min_scale_image);
Expand Down Expand Up @@ -477,6 +494,13 @@ private static void transformImageMacro(String args[]) {
fs.saveAsTiff(fn_out);
}

@Override
public ImagePlus processImagePlus(ImagePlus input) {
return input;
}



} /* end class UnwarpJ_ */

/*====================================================================
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/ijfx/plugins/UnwarpJPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
This file is part of ImageJ FX.
ImageJ FX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ImageJ FX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ImageJ FX. If not, see <http://www.gnu.org/licenses/>.
Copyright 2015,2016 Cyril MONGIS, Michael Knop
*/
package ijfx.plugins;

import ij.ImagePlus;
import net.imagej.Dataset;
import org.scijava.command.Command;
import org.scijava.plugin.Attr;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Command.class, menuPath = "Plugins>UnwarpJ", attrs = {
@Attr(name = "no-legacy")})
public class UnwarpJPlugin extends AbstractImageJ1PluginAdapter {

@Parameter(label = "Source")
Dataset source;

@Parameter(label = "Target")
Dataset target;

@Override
public ImagePlus processImagePlus(ImagePlus input) {
return input;
}

@Override
public void run() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

}

0 comments on commit ed7beee

Please sign in to comment.