FloodTracker3D.java
Go to the documentation of this file.00001 package theba.trackers;
00002
00003 import javax.swing.JOptionPane;
00004
00005 import theba.core.ImageFunctions;
00006 import theba.core.Stack;
00007 import theba.core.Tracker;
00008 import theba.core.gui.ThebaGUI;
00009 import theba.core.math.Point3D;
00010
00011
00019 public class FloodTracker3D extends Tracker {
00020
00021 public FloodTracker3D(ThebaGUI f) {
00022 super(f);
00023 }
00024
00025 @Override
00026 public void setup() {
00027 Runnable lumenAction = new Runnable() {
00028 public void run() {
00029 track();
00030 }
00031 };
00032 control.addMenuItem("Label regions", lumenAction);
00033 }
00034
00038 @Override
00039 public void track() {
00040 Stack input = control.getStack();
00041 String min = JOptionPane.showInputDialog(
00042 "Set minimum region size in voxels", "100");
00043 if (min == null)
00044 return;
00045 long totalSize = 0;
00046 int removeCount = 0;
00047 int count = 0;
00048 short id = 255;
00049 for (int z = 0; z < input.getDepth(); z++) {
00050 for (int y = 0; y < input.getHeight(); y++) {
00051 for (int x = 0; x < input.getWidth(); x++) {
00052 short val = input.getVoxelUnchecked(x, y, z);
00053 if (val == 0xff) {
00054 id++;
00055 long size = ImageFunctions.floodFill3D(input, x, y, z,
00056 id);
00057 totalSize += size;
00058 if (size < 100) {
00059 ImageFunctions.delete3D(input, x, y, z);
00060 id--;
00061 removeCount++;
00062 } else {
00063 count++;
00064 }
00065 }
00066 }
00067 }
00068 StringBuffer total = new StringBuffer();
00069 total.append("Regions found : " + (count) + "\n");
00070 total.append("Removed: " + removeCount + "\n");
00071 total.append("Avgsize : " + (totalSize / (count)) + "\n");
00072 control.showResults(total, "Results");
00073 control.setProgress(z);
00074 }
00075
00076 control.updateImage();
00077 }
00078
00079 @Override
00080 public void mouseClicked(Point3D point3D) {
00081
00082 }
00083
00084 @Override
00085 public void stop() {
00086
00087 }
00088
00089 @Override
00090 public void reset() {
00091
00092 }
00093 }