本文整理汇总了Java中ij.measure.ResultsTable.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java ResultsTable.setValue方法的具体用法?Java ResultsTable.setValue怎么用?Java ResultsTable.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.measure.ResultsTable
的用法示例。
在下文中一共展示了ResultsTable.setValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setColumn
import ij.measure.ResultsTable; //导入方法依赖的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]);
}
}
}
示例2: getPercentileNum
import ij.measure.ResultsTable; //导入方法依赖的package包/类
public long getPercentileNum(ImagePlus imp, double percentile){
ResultsTable rt = new ResultsTable();
long[] histogram = null; //is.histogram;
long totalCount = 0;
double value = 0.0;
double binWidth = 0.0;
double min = imp.getProcessor().getMin();
StackStatistics ss1 = new StackStatistics(imp);
min = ss1.histMin;
if(imp.getBitDepth() == 8 || imp.getBitDepth() == 24){
for(int i = 0; i < histogram.length; i++){
rt.setValue("Value", i, i);
rt.setValue("Count", i, histogram[i]);
}
}else{
value = min;
binWidth = ss1.binSize;
histogram = ss1.getHistogram();
for (int i=0; i<histogram.length; i++) {
rt.setValue("Value", i, value);
rt.setValue("Count", i, histogram[i]);
value += binWidth;
totalCount += histogram[i];
}
}
long percentileNum = (long) (percentile*totalCount);
return percentileNum;
}
示例3: findThreshold
import ij.measure.ResultsTable; //导入方法依赖的package包/类
public double findThreshold(ImagePlus imp, long percentileNum){
ResultsTable rt = new ResultsTable();
long[] histogram = null; //is.histogram;
long totalCount = 0;
double value = 0.0;
double binWidth = 0.0;
StackStatistics ss1 = new StackStatistics(imp);
double max = ss1.histMax;
histogram = ss1.getHistogram();
if(imp.getBitDepth() == 8 || imp.getBitDepth() == 24){
for(int i = histogram.length - 1; i > - 1; i--){
rt.setValue("Value", i, i);
rt.setValue("Count", i, histogram[i]);
if(percentileNum < totalCount){
return value;
}
}
}else{
value = max;
binWidth = ss1.binSize;
histogram = ss1.getHistogram();
for(int i = histogram.length - 1; i > - 1; i--){
value -= binWidth;
totalCount += histogram[i];
if(percentileNum < totalCount){
return value;
}
}
rt.show("Threshold Results");
}
return 0.0;
}
示例4: actionPerformed
import ij.measure.ResultsTable; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == correctResultsButton) {
ResultsTable table = Analyzer.getResultsTable();
if (table == null) {
IJ.showMessage("No results table!");
return;
}
for (int i = 0; i < table.getCounter(); i++) {
double slice = table.getValue("slice", i);
double x = table.getValue("x", i) - polynomial(slice - 1, xParameters);
double y = table.getValue("y", i) - polynomial(slice - 1, yParameters);
table.setValue("x", i, x);
table.setValue("y", i, y);
}
table.show("Results");
}
else if (e.getSource() == correctImageButton) {
ImagePlus imp = IJ.getImage();
ImageStack stack = imp.getStack();
for (int i = 0; i < stack.getSize(); i++) {
ImageProcessor ip = stack.getProcessor(i + 1);
ip.setInterpolationMethod(ImageProcessor.BILINEAR);
double dx = -polynomial(i, xParameters);
double dy = -polynomial(i, yParameters);
ip.translate(dx, dy);
}
imp.show();
}
}
示例5: sort
import ij.measure.ResultsTable; //导入方法依赖的package包/类
public static void sort(final ResultsTable table, final boolean ascending, final String... columns) {
Integer[] rowNumbers = new Integer[table.getCounter()];
for (int i = 0; i < rowNumbers.length; i++)
rowNumbers[i] = i;
Arrays.sort(rowNumbers, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
for (String column: columns) {
if (table.getColumnIndex(column) != ResultsTable.COLUMN_NOT_FOUND) {
double value1 = table.getValue(column, o1);
double value2 = table.getValue(column, o2);
int difference = Double.compare(value1, value2);
if (difference != 0)
return ascending ? difference : -difference;
}
}
return 0;
}
});
// put all rows in the correct order (in-place)
for (int i = 0; i < rowNumbers.length; i++) {
int j = rowNumbers[i];
if (i != j) {
while (j < i) // element at position j was already swapped with another element; find out which element that was
j = rowNumbers[j];
// swap rows
for (int k = 0; k <= table.getLastColumn(); k++) {
if (table.columnExists(k)) {
double d = table.getValueAsDouble(k, i);
table.setValue(k, i, table.getValueAsDouble(k, j));
table.setValue(k, j, d);
}
}
}
}
table.updateResults();
}
示例6: main
import ij.measure.ResultsTable; //导入方法依赖的package包/类
public static void main(String[] args) {
System.out.println("creating results table...");
ResultsTable rt = new ResultsTable();
for (int i = 0; i < 1e6; i++) {
rt.incrementCounter();
rt.setValue("x", i, (int)(Math.random() * 1000));
rt.setValue("y", i, (int)(Math.random() * 1000));
}
ResultsTableSorter.sort(rt, true, "x", "y");
// test table
System.out.println("testing results table...");
System.out.println("number of rows : " + rt.getCounter());
//System.out.println("x\ty");
//System.out.println(rt.getValue("x", 0) + "\t" + rt.getValue("y", 0));
for (int i = 1; i < rt.getCounter(); i++) {
//System.out.println(rt.getValue("x", i) + "\t" + rt.getValue("y", i));
int x1 = (int)rt.getValue("x", i - 1);
int x2 = (int)rt.getValue("x", i);
int y1 = (int)rt.getValue("y", i - 1);
int y2 = (int)rt.getValue("y", i);
if (x1 > x2) {
System.out.println("not sorted");
break;
}
if (x1 == x2 && y1 > y2) {
System.out.println("group not sorted");
break;
}
}
System.out.println("done");
}