|
| 1 | +package ic.ufal.br.PDI; |
| 2 | + |
| 3 | +import java.io.File; |
| 4 | +import java.io.IOException; |
| 5 | +import java.io.PrintWriter; |
| 6 | +import java.util.HashMap; |
| 7 | +import java.util.Map; |
| 8 | + |
| 9 | +import org.scijava.module.ModuleInfo; |
| 10 | + |
| 11 | +import net.imagej.Dataset; |
| 12 | +import net.imagej.ImageJ; |
| 13 | +import net.imglib2.IterableInterval; |
| 14 | +import net.imglib2.type.numeric.real.DoubleType; |
| 15 | +import net.imagej.plugins.commands.typechange.TypeChanger; |
| 16 | + |
| 17 | +public class Main { |
| 18 | + |
| 19 | + public static void main(String[] args) throws IOException { |
| 20 | + ImageJ ij = new ImageJ(); |
| 21 | + ModuleInfo module = ij.command().getCommand(TypeChanger.class); |
| 22 | + |
| 23 | + File file = ij.ui().chooseFile(null, "Open"); |
| 24 | + String fileName = file.getName(); |
| 25 | + |
| 26 | + PrintWriter pw = new PrintWriter(new File("test.csv")); |
| 27 | + StringBuilder sb = new StringBuilder(); |
| 28 | + sb.append("magnitude"); |
| 29 | + sb.append(","); |
| 30 | + sb.append("label"); |
| 31 | + sb.append("\n"); |
| 32 | + |
| 33 | + Dataset dataset = ij.scifio().datasetIO().open(file.getPath()); |
| 34 | + ij.ui().show(dataset); |
| 35 | + Map<String, Object> input = new HashMap<String, Object>(); |
| 36 | + input.put("data", dataset); |
| 37 | + input.put("typeName", "8-bit unsigned integer"); |
| 38 | + input.put("combineChannels", true); |
| 39 | + ij.module().waitFor(ij.module().run(module, true, input)); |
| 40 | + |
| 41 | + // ij.op().haralick, ij.op().zernike, ij.op().tamura, ij.op().stats estes são os descritores que possuem |
| 42 | + // os atributos |
| 43 | + DoubleType value = ij.op().zernike().magnitude((IterableInterval<DoubleType>)dataset.getImgPlus(), 0,0); |
| 44 | + sb.append(value); |
| 45 | + sb.append(","); |
| 46 | + // maligno ou benigno |
| 47 | + sb.append(fileName.substring(fileName.lastIndexOf(".") - 1, fileName.lastIndexOf("."))); |
| 48 | + sb.append("\n"); |
| 49 | + |
| 50 | + pw.write(sb.toString()); |
| 51 | + pw.close(); |
| 52 | + System.out.println(value); |
| 53 | + } |
| 54 | +} |
0 commit comments