ij.measure.ResultsTable.setValue()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中ij.measure.ResultsTable.setValue方法的一些代码示例,展示了ResultsTable.setValue的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResultsTable.setValue方法的具体详情如下:
包路径:ij.measure.ResultsTable
类名称:ResultsTable
方法名:setValue

ResultsTable.setValue介绍

[英]Sets the value of the given column and row, where where 0<=column<=(lastRow+1 and 0<=row<=size().
[中]设置给定列和行的值,其中0<=列<=(lastRow+1和0<=行<=大小()。

代码示例

代码示例来源:origin: ijpb/MorphoLibJ

private static final void addColumnToTable(ResultsTable table, String colName, double[] values)
  {
    for (int i = 0; i < values.length; i++)
    {
      table.setValue(colName, i, values[i]);
    }
  }
}

代码示例来源:origin: net.imagej/imagej-legacy

/**
 * Sets the value at the given row column. If the passed value is a
 * {@code Number} it will be stored as a {@code double}.
 */
@Override
public void set(final String colHeader, final int row, final Object value) {
  if (value instanceof String) table.setValue(colHeader, row, (String) value);
  else if (value instanceof Number) table.setValue(colHeader, row,
    ((Number) value).doubleValue());
}

代码示例来源:origin: net.imagej/imagej-legacy

/**
 * Sets the value at the given row column. If the passed value is a
 * {@code Number} it will be stored as a {@code double}.
 */
@Override
public void set(final int col, final int row, final Object value) {
  final int actualCol = getActualColumnIndex(col);
  if (value instanceof String) table.setValue(actualCol, row, (String) value);
  else if (value instanceof Number) table.setValue(actualCol, row,
    ((Number) value).doubleValue());
}

代码示例来源:origin: net.imagej/ij

private void debug() {
  FloatPolygon p = getFloatPolygon();
  ResultsTable rt = new ResultsTable();
  for (int i=0; i<nPoints; i++) {
    if (counters!=null) {
      rt.setValue("Counter", i, counters[i]);
      rt.setValue("Position", i, positions[i]);
    } 
    rt.setValue("X", i, p.xpoints[i]);
    rt.setValue("Y", i, p.ypoints[i]);
  }
  rt.show(getCountsTitle());
}

代码示例来源:origin: imagej/ImageJA

private void debug() {
  FloatPolygon p = getFloatPolygon();
  ResultsTable rt = new ResultsTable();
  for (int i=0; i<nPoints; i++) {
    if (counters!=null) {
      rt.setValue("Counter", i, counters[i]);
      rt.setValue("Position", i, positions[i]);
    } 
    rt.setValue("X", i, p.xpoints[i]);
    rt.setValue("Y", i, p.ypoints[i]);
  }
  rt.show(getCountsTitle());
}

代码示例来源:origin: net.imagej/ij

/** Returns the histogram values as a ResultsTable. */
public ResultsTable getResultsTable() {
  ResultsTable rt = new ResultsTable();
  rt.setPrecision(digits);
  String vheading = stats.binSize==1.0?"value":"bin start";
  if (cal.calibrated() && !cal.isSigned16Bit()) {
    for (int i=0; i<stats.nBins; i++) {
      rt.setValue("level", i, i);
      rt.setValue(vheading, i, cal.getCValue(stats.histMin+i*stats.binSize));
      rt.setValue("count", i, histogram[i]);
    }
  } else {
    for (int i=0; i<stats.nBins; i++) {
      if (stats.binSize!=1.0)
        rt.setValue("index", i, i);
      rt.setValue(vheading, i, cal.getCValue(stats.histMin+i*stats.binSize));
      rt.setValue("count", i, histogram[i]);
    }
  }
  return rt;
}

代码示例来源:origin: net.imagej/imagej-legacy

@Override
public void setValue(final int column, final int row, final double value) {
  super.setValue(column, row, value);
  // NB: In IJ String and double values are in separate data structures,
  // so when String values are set the corresponding position in the double
  // structure is set to NaN. These are all in one structure in ImageJ2,
  // so if the value is NaN do not overwrite the value.
  if (Double.isNaN(value)) return;
  createMissingColumns(column);
  setDoubleValue(column, row, value);
}

代码示例来源:origin: net.imagej/imagej-legacy

/**
 * Sets the value at the given index. If {@code element} is a {@code Number}
 * it will be stored as {@code double}.
 */
@Override
public Object set(final int index, final Object element) {
  // Store the previous value
  Object prev = null;
  if (checkString(index)) prev = table.getStringValue(col, index);
  else prev = table.getValueAsDouble(col, index);
  // Set the new value
  if (element instanceof Number) table.setValue(col, index, ((Number) element)
    .doubleValue());
  else if (element != null) table.setValue(col, index, element.toString());
  else throw new NullPointerException();
  return prev;
}

代码示例来源:origin: net.imagej/ij

/** Sets the value of the given column and row, where
  where 0&lt;=row&lt;size(). If the specified column does 
  not exist, it is created. When adding columns, 
  <code>show()</code> must be called to update the 
  window that displays the table.*/
public void setValue(String column, int row, double value) {
  if (column==null)
    throw new IllegalArgumentException("Column is null");
  int col = getColumnIndex(column);
  if (col==COLUMN_NOT_FOUND)
    col = getFreeColumn(column);
  setValue(col, row, value);
}

代码示例来源:origin: net.imagej/ij

/** Sets the string value of the given column and row, where
  where 0&lt;=row&lt;size(). If the specified column does 
  not exist, it is created. When adding columns, 
  <code>show()</code> must be called to update the 
  window that displays the table.*/
public void setValue(String column, int row, String value) {
  if (column==null)
    throw new IllegalArgumentException("Column is null");
  int col = getColumnIndex(column);
  if (col==COLUMN_NOT_FOUND)
    col = getFreeColumn(column);
  setValue(col, row, value);
}

代码示例来源:origin: imagej/ImageJA

/** Sets the value of the given column and row, where
  where 0&lt;=row&lt;size(). If the specified column does 
  not exist, it is created. When adding columns, 
  <code>show()</code> must be called to update the 
  window that displays the table.*/
public void setValue(String column, int row, double value) {
  if (column==null)
    throw new IllegalArgumentException("Column is null");
  int col = getColumnIndex(column);
  if (col==COLUMN_NOT_FOUND)
    col = getFreeColumn(column);
  setValue(col, row, value);
}

代码示例来源:origin: imagej/ImageJA

/** Sets the string value of the given column and row, where
  where 0&lt;=row&lt;size(). If the specified column does 
  not exist, it is created. When adding columns, 
  <code>show()</code> must be called to update the 
  window that displays the table.*/
public void setValue(String column, int row, String value) {
  if (column==null)
    throw new IllegalArgumentException("Column is null");
  int col = getColumnIndex(column);
  if (col==COLUMN_NOT_FOUND)
    col = getFreeColumn(column);
  setValue(col, row, value);
}

代码示例来源:origin: net.imagej/imagej-legacy

@Override
public void setValue(final int column, final int row, final String value) {
  super.setValue(column, row, value);
  createMissingColumns(column);
  setStringValue(column, row, value);
}

代码示例来源:origin: net.imagej/imagej-legacy

@Override
public void appendRow() {
  // Determine if empty cells are NaN or 0
  double fill = 0;
  try {
    final Field f = ResultsTable.class.getDeclaredField(
      "NaNEmptyCells");
    f.setAccessible(true);
    final boolean nan = (boolean) f.get(table);
    fill = nan ? Double.NaN : 0;
  }
  catch (final Exception exc) {
    // Keep as zero
  }
  for (int i = 0; i <= table.getLastColumn(); i++) {
    // setValue increments the column whereas addValue does not
    table.setValue(i, table.size(), fill);
  }
}

代码示例来源:origin: net.imagej/ij

void list(ImageProcessor ip) {
  IndexColorModel icm = (IndexColorModel)ip.getColorModel();
  int size = icm.getMapSize();
  byte[] r = new byte[size];
  byte[] g = new byte[size];
  byte[] b = new byte[size];
  icm.getReds(r); 
  icm.getGreens(g); 
  icm.getBlues(b);        
  ResultsTable rt = new ResultsTable();
  for (int i=0; i<size; i++) {
     rt.setValue("Index", i, i);
     rt.setValue("Red", i, r[i]&255);
     rt.setValue("Green", i, g[i]&255);
     rt.setValue("Blue", i, b[i]&255);
   }
  rt.show("LUT");
}

代码示例来源:origin: net.imagej/imagej-legacy

@Override
public boolean add(final Column<? extends Object> column) {
  final int colIndex = table.getLastColumn() + 1;
  for (int i = 0; i < column.size(); i++) {
    if (column.get(i) instanceof Number) table.setValue(colIndex, i,
      ((Number) column.get(i)).doubleValue());
    else if (column.get(i) != null) table.setValue(colIndex, i, column.get(i)
      .toString());
    else return false;
  }
  return true;
}

代码示例来源:origin: imagej/ImageJA

void list(ImageProcessor ip) {
  IndexColorModel icm = (IndexColorModel)ip.getColorModel();
  int size = icm.getMapSize();
  byte[] r = new byte[size];
  byte[] g = new byte[size];
  byte[] b = new byte[size];
  icm.getReds(r); 
  icm.getGreens(g); 
  icm.getBlues(b);        
  ResultsTable rt = new ResultsTable();
  for (int i=0; i<size; i++) {
     rt.setValue("Index", i, i);
     rt.setValue("Red", i, r[i]&255);
     rt.setValue("Green", i, g[i]&255);
     rt.setValue("Blue", i, b[i]&255);
   }
  rt.show("LUT");
}

代码示例来源:origin: net.imagej/ij

/** Adds a string value to the end of the given column. If the column
  does not exist, it is created. */
public void addValue(String column, String value) {
  if (column==null)
    throw new IllegalArgumentException("Column is null");
  int index = getColumnIndex(column);
  if (index==COLUMN_NOT_FOUND)
    index = getFreeColumn(column);
  addValue(index, Double.NaN);
  setValue(column, size()-1, value);
  keep[index] = true;
}

代码示例来源:origin: imagej/ImageJA

/** Adds a string value to the end of the given column. If the column
  does not exist, it is created. */
public void addValue(String column, String value) {
  if (column==null)
    throw new IllegalArgumentException("Column is null");
  int index = getColumnIndex(column);
  if (index==COLUMN_NOT_FOUND)
    index = getFreeColumn(column);
  addValue(index, Double.NaN);
  setValue(column, size()-1, value);
  keep[index] = true;
}

代码示例来源:origin: sc.fiji/3D_Objects_Counter

/** Returns an ResultsTable containing coordinates of the surface pixels for all objects:
 * <ul>
 * <li>Object ID: current object number.</li>
 * <li>X, Y and Z: coordinates of the current object's surface pixel.</li>
 * </ul>
 */
public void showSurfPix(){
  if (!getSurfCoord) populateSurfPixCoord();
  
  String[] header={"Object ID", "X", "Y", "Z"};
  ResultsTable rt=new ResultsTable();
  for (int i=0; i<header.length; i++) rt.setHeading(i, header[i]);
  for (int i=0; i<surfCoord.length; i++){
    rt.incrementCounter();
    for (int j=0; j<4; j++) rt.setValue(j, i, surfCoord[i][j]);
  }
  
  rt.show("Surface pixel coordinates for "+title);
}

相关文章

微信公众号

最新文章

更多