本文整理汇总了Java中ij.plugin.filter.Analyzer类的典型用法代码示例。如果您正苦于以下问题:Java Analyzer类的具体用法?Java Analyzer怎么用?Java Analyzer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Analyzer类属于ij.plugin.filter包,在下文中一共展示了Analyzer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResultsTable
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
/**
* Returns the instance of the ResultsTable.
*
* @return Instance of the ResultsTable
*/
public static Object getResultsTable(){
ResultsTable rt=Analyzer.getResultsTable();
int col=0;
int[] index=new int[ResultsTable.MAX_COLUMNS];
for (int cnt=0;cnt<ResultsTable.MAX_COLUMNS; cnt++) {
if (rt.columnExists(cnt)){
index[col]=cnt;
col++;
}
}
int counter=rt.getCounter();
double [][] results=new double[counter][col];
for( int i=0;i<col;i++) {
for( int j=0;j<counter;j++) {
results[j][i]=rt.getValueAsDouble(index[i],j);
}
}
return results;
}
示例2: setColumn
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
/**
* Set a specifying column into the current instance ResultsTable.
*
* @param heading heading of a column
* @param object
*/
public static void setColumn(String heading, Object object){
ResultsTable rt=Analyzer.getResultsTable();
int col= rt.getColumnIndex(heading);
if (col==ResultsTable.COLUMN_NOT_FOUND)
col=rt.getFreeColumn(heading);
int cc=rt.getCounter();
if (object instanceof double[]) {
double[] values = (double[]) object;
for (int i=0; i<values.length; i++){
if (cc<=i) rt.incrementCounter();
rt.setValue(col, i, values[i]);
}
}
}
示例3: createPathObjectsFromROIs
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
/**
* Turn an array of ImageJ ROIs into a list of QuPath PathObjects, optionally adding measurements as well.
*
* @param imp
* @param rois
* @param server
* @param downsample
* @param asDetection
* @param includeMeasurements
* @return
*/
public static List<PathObject> createPathObjectsFromROIs(final ImagePlus imp, final Roi[] rois, final ImageServer<?> server, final double downsample, final boolean asDetection, final boolean includeMeasurements, final int c, final int z, final int t) {
List<PathObject> pathObjects = new ArrayList<>();
ResultsTable rt = new ResultsTable();
Analyzer analyzer = new Analyzer(imp, Analyzer.getMeasurements(), rt);
String[] headings = null;
for (Roi roi : rois) {
PathObject pathObject = IJTools.convertToPathObject(imp, server, roi, downsample, asDetection, c, z, t);
if (pathObject == null)
IJ.log("Sorry, I could not convert " + roi + " to a value QuPath object");
else {
// Make measurements
if (includeMeasurements) {
ImageProcessor ip = imp.getProcessor();
ip.setRoi(roi);
ImageStatistics stats = ImageStatistics.getStatistics(ip, Analyzer.getMeasurements(), imp.getCalibration());
analyzer.saveResults(stats, roi);
// Get measurements from table and append
if (headings == null)
headings = rt.getHeadings();
int row = rt.getCounter()-1;
MeasurementList ml = pathObject.getMeasurementList();
for (String h : headings) {
if ("Label".equals(h))
continue;
ml.putMeasurement(h, rt.getValue(h, row));
}
ml.closeList();
}
pathObjects.add(pathObject);
}
}
return pathObjects;
}
示例4: showHistogram
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
/**
* Draws the histogram using the specified title, number of bins and
* histogram range. Currently, the number of bins must be 256 and the
* histogram range range must be the same as the image range expect for 32
* bit images.
*/
public void showHistogram(ImagePlus imp, int bins, double histMin, double histMax) {
boolean limitToThreshold = (Analyzer.getMeasurements() & LIMIT) != 0;
if(channel != INTENSITY && imp.getType() == ImagePlus.COLOR_RGB) {
ColorProcessor cp = (ColorProcessor) imp.getProcessor();
ImageProcessor ip = cp.toFloat(channel, null);
ImagePlus imp2 = new ImagePlus("", ip);
imp2.setRoi(imp.getRoi());
stats = imp2.getStatistics(AREA + MEAN + MODE + MIN_MAX, bins, histMin, histMax);
} else {
stats = imp.getStatistics(AREA + MEAN + MODE + MIN_MAX + (limitToThreshold ? LIMIT : 0), bins, histMin, histMax);
}
showHistogram(imp, stats);
}
示例5: drawHistogram
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
void drawHistogram(ImagePlus imp, ImageProcessor ip, boolean fixedRange, double xMin, double xMax) {
int x, y;
long maxCount2 = 0;
int mode2 = 0;
int saveModalCount;
ip.setColor(Color.black);
ip.setLineWidth(1);
decimalPlaces = Analyzer.getPrecision();
digits = cal.calibrated() || stats.binSize != 1.0 ? decimalPlaces : 0;
saveModalCount = histogram[stats.mode];
for(int i = 0; i < histogram.length; i++) {
if((histogram[i] > maxCount2) && (i != stats.mode)) {
maxCount2 = histogram[i];
mode2 = i;
}
}
newMaxCount = histogram[stats.mode];
if((newMaxCount > (maxCount2 * 2)) && (maxCount2 != 0)) {
newMaxCount = (int) (maxCount2 * 1.5);
//histogram[stats.mode] = newMaxCount;
}
if(logScale || IJ.shiftKeyDown() && !liveMode()) {
drawLogPlot(yMax > 0 ? yMax : newMaxCount, ip);
}
drawPlot(yMax > 0 ? yMax : newMaxCount, ip);
histogram[stats.mode] = saveModalCount;
x = XMARGIN + 1;
y = YMARGIN + HIST_HEIGHT + 2;
if(imp == null) {
lut.drawUnscaledColorBar(ip, x - 1, y, 256, BAR_HEIGHT);
} else {
drawAlignedColorBar(imp, xMin, xMax, ip, x - 1, y, 256, BAR_HEIGHT);
}
y += BAR_HEIGHT + 15;
drawText(ip, x, y, fixedRange);
srcImageID = imp.getID();
}
示例6: getListColumns
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
/**
* Returns the list of columns currently used in the ResultsTable.
*
* @return list of columns
*/
public static String[] getListColumns() {
ResultsTable rt = Analyzer.getResultsTable();
StringTokenizer st = new StringTokenizer(rt.getColumnHeadings());
int n = st.countTokens();
String[] strings = new String[n];
for (int i = 0; i < n; i++) {
strings[i] =st.nextToken();
}
return strings;
}
示例7: getColumn
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
/**
* Returns a specifying column the current instance of ResultsTable.
*
* @param heading heading of a column
* @return column specified by its heading
*/
public static Object getColumn(String heading){
ResultsTable rt=Analyzer.getResultsTable();
int col= rt.getColumnIndex(heading);
int counter=rt.getCounter();
double []results=new double[counter];
results=rt.getColumnAsDoubles(col);
return results;
}
示例8: showResults
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
private static void showResults() {
TextWindow resultsWindow = new TextWindow("Results", "", 400, 250);
textPanel = resultsWindow.getTextPanel();
textPanel.setResultsTable(Analyzer.getResultsTable());
if (ij!=null)
textPanel.addKeyListener(ij);
}
示例9: deleteRows
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
/** Deletes 'row1' through 'row2' of the "Results" window. Arguments
must be in the range 0-Analyzer.getCounter()-1. */
public static void deleteRows(int row1, int row2) {
int n = row2 - row1 + 1;
ResultsTable rt = Analyzer.getResultsTable();
for (int i=row1; i<row1+n; i++)
rt.deleteRow(row1);
rt.show("Results");
}
示例10: run
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
public void run(String arg) {
ImagePlus current = IJ.getImage();
Analyzer.setMeasurement(Measurements.LABELS, true);
for (int i=0; i<current.getStackSize(); i++) {
current.setSlice(i+1);
IJ.showProgress(i+1, current.getStackSize());
IJ.run(current, "Measure", "");
}
}
示例11: resultsExample
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
void resultsExample()
{
ResultsTable rt = Analyzer.getResultsTable();
if (rt == null) {
rt = new ResultsTable();
Analyzer.setResultsTable(rt);
}
for (int i = 1; i <= 10; i++) {
rt.incrementCounter();
rt.addValue("i", i);
rt.addValue("log", Math.log(i));
}
rt.show("Results");
}
示例12: takeMeasure
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
private static String takeMeasure(Roi roi, ImagePlus imp, Hashtable<String, String> toMeasure, LinkedList<BacteriaMeasurement> measurements, int collarSize, int idBacteria, int frameNo, int idRoiType, int idChannel ) {
roi.setImage(imp);
imp.setRoi(roi);
Analyzer.getResultsTable().reset();
// for the time being, I'm using default ResultTable and delete it (and measurements options)
Analyzer analyzer = new Analyzer(roi.getImage());
analyzer.measure();
ResultsTable rt = Analyzer.getResultsTable();
String dbg = " ";
DecimalFormat df = new DecimalFormat("0.00");
for (int i = 0; i <= rt.getLastColumn(); ++i) {
try {
// ControlPanel.addStatusMessage("toMeasure.containsKey(" + rt.getColumnHeading(i).toLowerCase() + ")) = " + toMeasure.containsKey(rt.getColumnHeading(i).toLowerCase()));
if (toMeasure.containsKey(rt.getColumnHeading(i).toLowerCase())) {
BacteriaMeasurement bm = new BacteriaMeasurement (
idBacteria,
frameNo,
DALService.getMeasurementId(rt.getColumnHeading(i)),
rt.getValueAsDouble(i, 0),
idRoiType,
idChannel
);
dbg += rt.getColumnHeading(i) + "(" + collarSize + ") = " + df.format(rt.getValueAsDouble(i, 0)) + "\t";
measurements.add(bm);
}
} catch (Exception e) {
// Dirty, I know, I haven't figured out the better way.
// Don't like parsing rt.getColumnHeadings() any better
}
}
return dbg;
}
示例13: closeResultsWindow
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
public static void closeResultsWindow() {
Analyzer.getResultsTable().reset();
java.awt.Frame[] arrayOfFrames = WindowManager.getNonImageWindows();
for (int i = 0; i < arrayOfFrames.length; ++i) {
String localName = arrayOfFrames[i].getTitle();
if (localName.equalsIgnoreCase("Results")) {
TextWindow tw = (TextWindow) arrayOfFrames[i];
tw.close();
}
}
}
示例14: getHyperstackProfile
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
private float[] getHyperstackProfile(Roi roi, double minThreshold, double maxThreshold) {
int slices = imp.getNSlices();
int frames = imp.getNFrames();
int c = imp.getC();
int z = imp.getZ();
int t = imp.getT();
int size = slices;
if (firstTime)
timeProfile = slices==1 && frames>1;
if (slices>1 && frames>1 && (!isPlotMaker ||firstTime)) {
showingDialog = true;
GenericDialog gd = new GenericDialog("Profiler");
gd.addChoice("Profile", choices, choice);
gd.showDialog();
if (gd.wasCanceled())
return null;
choice = gd.getNextChoice();
timeProfile = choice.equals(choices[0]);
}
if (timeProfile)
size = frames;
else
size = slices;
float[] values = new float[size];
Calibration cal = imp.getCalibration();
Analyzer analyzer = new Analyzer(imp);
int measurements = Analyzer.getMeasurements();
boolean showResults = !isPlotMaker && measurements!=0 && measurements!=LIMIT;
measurements |= MEAN;
if (showResults) {
if (!Analyzer.resetCounter())
return null;
}
ImageStack stack = imp.getStack();
for (int i=1; i<=size; i++) {
int index = 1;
if (timeProfile)
index = imp.getStackIndex(c, z, i);
else
index = imp.getStackIndex(c, i, t);
ImageProcessor ip = stack.getProcessor(index);
if (minThreshold!=ImageProcessor.NO_THRESHOLD)
ip.setThreshold(minThreshold,maxThreshold,ImageProcessor.NO_LUT_UPDATE);
ip.setRoi(roi);
ImageStatistics stats = ImageStatistics.getStatistics(ip, measurements, cal);
analyzer.saveResults(stats, roi);
values[i-1] = (float)stats.mean;
}
if (showResults) {
ResultsTable rt = Analyzer.getResultsTable();
rt.show("Results");
}
return values;
}
示例15: getZAxisProfile
import ij.plugin.filter.Analyzer; //导入依赖的package包/类
private float[] getZAxisProfile(Roi roi, double minThreshold, double maxThreshold) {
ImageStack stack = imp.getStack();
if (firstTime) {
int slices = imp.getNSlices();
int frames = imp.getNFrames();
timeProfile = slices==1 && frames>1;
}
int size = stack.getSize();
float[] values = new float[size];
Calibration cal = imp.getCalibration();
Analyzer analyzer = new Analyzer(imp);
int measurements = Analyzer.getMeasurements();
boolean showResults = !isPlotMaker && measurements!=0 && measurements!=LIMIT;
boolean showingLabels = firstTime && showResults && ((measurements&LABELS)!=0 || (measurements&SLICE)!=0);
measurements |= MEAN;
if (showResults) {
if (!Analyzer.resetCounter())
return null;
}
boolean isLine = roi!=null && roi.isLine();
int current = imp.getCurrentSlice();
for (int i=1; i<=size; i++) {
if (showingLabels)
imp.setSlice(i);
ImageProcessor ip = stack.getProcessor(i);
if (minThreshold!=ImageProcessor.NO_THRESHOLD)
ip.setThreshold(minThreshold,maxThreshold,ImageProcessor.NO_LUT_UPDATE);
ip.setRoi(roi);
ImageStatistics stats = null;
if (isLine)
stats = getLineStatistics(roi, ip, measurements, cal);
else
stats = ImageStatistics.getStatistics(ip, measurements, cal);
analyzer.saveResults(stats, roi);
values[i-1] = (float)stats.mean;
}
if (showResults) {
ResultsTable rt = Analyzer.getResultsTable();
rt.show("Results");
}
if (showingLabels)
imp.setSlice(current);
return values;
}