forked from jayunruh/Jay_Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_objects_jru_v1.java
More file actions
59 lines (56 loc) · 2.13 KB
/
Copy pathedit_objects_jru_v1.java
File metadata and controls
59 lines (56 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*******************************************************************************
* Copyright (c) 2012 Jay Unruh, Stowers Institute for Medical Research.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v2.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
******************************************************************************/
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;
import jguis.*;
import jalgs.jseg.*;
import jalgs.*;
public class edit_objects_jru_v1 implements PlugIn {
public void run(String arg) {
ImagePlus imp2=WindowManager.getCurrentImage();
int width=imp2.getWidth(); int height=imp2.getHeight();
int slices=imp2.getStack().getSize();
if(slices!=2){
float[] pix=(float[])imp2.getProcessor().convertToFloat().getPixels();
ImageStack dispstack=new ImageStack(width,height);
dispstack.addSlice("",pix);
if(!(imp2.getProcessor() instanceof ByteProcessor)){
IJ.showMessage("Assuming indexed objects image");
//return;
dispstack.addSlice("",algutils.convert_arr_float(findblobs3.threshimage(pix,0.5f)));
} else {
dispstack.addSlice("",pix.clone());
}
imp2=new ImagePlus("Outlined Objects",dispstack);
imp2.setOpenAsHyperStack(true);
imp2.setDimensions(2,1,1);
imp2.copyScale(WindowManager.getCurrentImage());
imp2=new CompositeImage(imp2,CompositeImage.COMPOSITE);
imp2.show();
}
CompositeImage imp=(CompositeImage)imp2;
imp.setPosition(1,1,1);
LUT graylut=jutils.get_lut_for_color(Color.white);
imp.setChannelColorModel(graylut);
imp.setPosition(2,1,1);
LUT redlut=jutils.get_lut_for_color(Color.red);
imp.setChannelColorModel(redlut);
imp.setPosition(1,1,1);
imp.updateAndRepaintWindow();
threshold_panel tp=new threshold_panel();
findblobs3 fb=new findblobs3(width,height);
float[] temp=(float[])imp.getStack().getPixels(2);
float[] objects=fb.dofindblobs(temp,254.0f);
tp.init(imp,objects,false);
threshold_panel.launch_frame(tp);
}
}