本文整理汇总了Java中ij.process.FloatProcessor.resetMinAndMax方法的典型用法代码示例。如果您正苦于以下问题:Java FloatProcessor.resetMinAndMax方法的具体用法?Java FloatProcessor.resetMinAndMax怎么用?Java FloatProcessor.resetMinAndMax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.FloatProcessor
的用法示例。
在下文中一共展示了FloatProcessor.resetMinAndMax方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: normalize
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/** normalize the pixels of a FloatProcessor to a given range. */
static void normalize( FloatProcessor fp,
double low, double high ) {
float [] data = (float [])fp.getPixels();
// find min and max
float min = Float.MAX_VALUE;
float max = Float.MIN_VALUE;
for ( float i : data ) {
if (i<min) min = i;
if (i>max) max = i;
}
// scale
for (int i=0; i<data.length; i++)
data[i] = (float)
((( data[i]-min )/( max-min )) * (high-low) + low);
// tell it to recalculate its display scaling
fp.resetMinAndMax();
}
示例2: showImage
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static void showImage(
final String title,
final double [] array,
final int Ydim,
final int Xdim
) {
final FloatProcessor fp=new FloatProcessor(Xdim,Ydim);
int ij=0;
for (int i=0; i<Ydim; i++)
for (int j=0; j<Xdim; j++, ij++)
fp.putPixelValue(j,i,array[ij]);
fp.resetMinAndMax();
final ImagePlus ip=new ImagePlus(title, fp);
final ImageWindow iw=new ImageWindow(ip);
ip.updateImage();
}
示例3: showImage
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Show an image in a new bUnwarpJ window.
*
* @param title image title
* @param array image in a double array
* @param Ydim image height
* @param Xdim image width
*/
public static void showImage(
final String title,
final double [] array,
final int Ydim,
final int Xdim)
{
final FloatProcessor fp=new FloatProcessor(Xdim,Ydim);
int ij=0;
for (int i=0; i<Ydim; i++)
for (int j=0; j<Xdim; j++, ij++)
fp.putPixelValue(j,i,array[ij]);
fp.resetMinAndMax();
final ImagePlus ip=new ImagePlus(title, fp);
ip.updateImage();
ip.show();
}
示例4: getAccumulatorImage
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Creates and returns an image of the 2D accumulator array.
* @return A FloatProcessor (since accumulator values may be large).
*/
public FloatProcessor getAccumulatorImage() {
FloatProcessor fp = new FloatProcessor(nAng, nRad);
for (int ir = 0; ir < nRad; ir++) {
for (int ia = 0; ia < nAng; ia++) {
fp.setf(ia, ir, accumulator[ia][ir]);
}
}
fp.resetMinAndMax();
return fp;
}
示例5: getAccumulatorMaxImage
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Creates and returns an image of the local maxima of the
* 2D accumulator array.
* @return A FloatProcessor (since accumulator values may be large).
*/
public FloatProcessor getAccumulatorMaxImage() {
FloatProcessor fp = new FloatProcessor(nAng, nRad);
for (int ir = 0; ir < nRad; ir++) {
for (int ia = 0; ia < nAng; ia++) {
fp.setf(ia, ir, accumulatorMax[ia][ir]);
}
}
fp.resetMinAndMax();
return fp;
}
示例6: getAccumulatorImageExtended
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Creates and returns an image of the extended 2D accumulator array,
* produced by adding a vertically mirrored copy of the accumulator
* to its right end.
* @return A FloatProcessor (since accumulator values may be large).
*/
public FloatProcessor getAccumulatorImageExtended() {
FloatProcessor fp = new FloatProcessor(2 * accWidth, accHeight);
for (int ai = 0; ai < accWidth; ai++) {
for (int ri = 0; ri < accHeight; ri++) {
fp.setf(ai, ri, accumulator[ai][ri]);
if (ri > 0) {
fp.setf(accWidth + ai, ri, accumulator[ai][accHeight - ri]);
}
}
}
fp.resetMinAndMax();
return fp;
}
示例7: run
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Values of the <code>arg</code> argument: <ul> <li> 'about' - show short help message. </li>
* <li> 'VectorSobelEdgeOperator' - invoke {@link VectorSobelEdgeOperator} filter.</li>
* <li>'VectorGradientEdgeOperator' - invoke {@link VectorGradientEdgeOperator} filter.</li>
* <li>'VectorDifferenceEdgeOperator' - invoke {@link VectorDifferenceEdgeOperator} filter.</li>
* </ul>
*/
@Override
public void run(final String arg) {
if (ABOUT_COMMAND.equalsIgnoreCase(arg)) {
IJ.showMessage("About " + PLUGIN_NAME, ABOUT_MESSAGE);
return;
}
final ImagePlus imp = IJ.getImage();
if (imp == null) {
IJ.noImage();
return;
}
final FloatProcessor fp;
final String postFix;
if ("VectorSobelEdgeOperator".equalsIgnoreCase(arg)) {
fp = VectorSobelEdgeOperator.run(imp);
postFix = "Sobel";
} else if ("VectorDifferenceEdgeOperator".equalsIgnoreCase(arg)) {
fp = VectorDifferenceEdgeOperator.run(imp);
postFix = "difference";
} else if ("VectorGradientEdgeOperator".equalsIgnoreCase(arg)) {
fp = VectorGradientEdgeOperator.run(imp);
postFix = "gradient";
} else {
throw new IllegalArgumentException("Invalid invocation argument: " + arg);
}
fp.resetMinAndMax();
final String title = imp.getShortTitle() + " - " + postFix + " edges";
new ImagePlus(title, fp).show();
}
示例8: run
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/*********************************************************************
* Perform the registration
********************************************************************/
public void run (
) {
// Create output image
int Ydimt=target.getHeight();
int Xdimt=target.getWidth();
int Xdims=source.getWidth();
final FloatProcessor fp=new FloatProcessor(Xdimt,Ydimt);
for (int i=0; i<Ydimt; i++)
for (int j=0; j<Xdimt; j++)
if (sourceMsk.getValue(j,i) && targetMsk.getValue(j,i))
fp.putPixelValue(j,i,(target.getImage())[i*Xdimt+j]-
(source.getImage())[i*Xdims+j]);
else fp.putPixelValue(j,i,0);
fp.resetMinAndMax();
final ImagePlus ip=new ImagePlus("Output", fp);
final ImageWindow iw=new ImageWindow(ip);
ip.updateImage();
// Perform the registration
final unwarpJTransformation warp = new unwarpJTransformation(
sourceImp, targetImp, source, target, sourcePh, targetPh,
sourceMsk, targetMsk, min_scale_deformation, max_scale_deformation,
min_scale_image, divWeight, curlWeight, landmarkWeight, imageWeight,
stopThreshold, outputLevel, showMarquardtOptim, accurate_mode,
dialog.isSaveTransformationSet(), "", ip, dialog);
warp.doRegistration();
dialog.ungrayImage(sourcePh.getPointAction());
dialog.ungrayImage(targetPh.getPointAction());
dialog.restoreAll();
dialog.freeMemory();
}
示例9: runAnalysis
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/** This runs all steps of the analysis, given an ImageStack as input. */
void runAnalysis( ImageStack stck, float pxMin, float pxMax ) {
// helpers
Timing t1 = new Timing();
GaussianBlur gb = new GaussianBlur();
final int imgPerResult = stck.getSize() / nrResImages;
IJ.log("ESI: input images per resulting images: "+imgPerResult);
// stacks to store the results
ImageStack rec =
new ImageStack(2*stck.getWidth(), 2*stck.getHeight());
ImagePlus interm = null;
// image to show the summed-up result
FloatProcessor summedImg =
new FloatProcessor( 2*stck.getWidth(), 2*stck.getHeight());
ImagePlus summedImgP =
new ImagePlus("summed ESI result", summedImg) ;
summedImgP.show();
// Array to hold one TraceStack per Image Substack
TraceStack [] trStArray = new TraceStack[ nrResImages ];
// loop over subimages
for( int k=0; k < nrResImages ; k++) {
t1.start();
// generate and normalize the TraceStack
TraceStack trSt = new TraceStack( stck , k*imgPerResult , (k+1)*imgPerResult );
trSt.normalizeFrom( pxMin, pxMax );
trSt.createNormBinning( nrBins );
// run the analysis
FloatProcessor reconstruction;
if (doMultiCore) {
MTP mp = new MTP(this);
reconstruction = mp.doESI(trSt, esi_order);
} else {
reconstruction = doESI(trSt, esi_order);
}
gb.blurFloat( reconstruction , 0.8, 0.8, 0.01);
if (normOutput)
normalize( reconstruction );
// add these to the result stacks
rec.addSlice(reconstruction);
// add the slice to the current sum
ESI_Analysis.addFP( reconstruction, summedImg);
summedImg.resetMinAndMax();
summedImgP.updateAndDraw();
// present some intermediate result
if ( (rec.getSize()>1)||(nrResImages==1))
if ( interm == null) {
interm= new ImagePlus("ESI result", rec);
interm.show();
} else {
interm.setPosition( rec.getSize() );
}
t1.stop();
IJ.log("ESI: SubImg "+k+"/"+nrResImages+" took "+t1 );
}
}
示例10: applyTransformationToSource
import ij.process.FloatProcessor; //导入方法依赖的package包/类
static public void applyTransformationToSource(
ImagePlus sourceImp, ImagePlus targetImp,
unwarpJImageModel source,
int intervals,
double [][]cx,
double [][]cy) {
int targetHeight=targetImp.getProcessor().getHeight();
int targetWidth =targetImp.getProcessor().getWidth ();
int sourceHeight=sourceImp.getProcessor().getHeight();
int sourceWidth =sourceImp.getProcessor().getWidth ();
// Ask for memory for the transformation
double [][] transformation_x=new double [targetHeight][targetWidth];
double [][] transformation_y=new double [targetHeight][targetWidth];
// Compute the deformation
// Set these coefficients to an interpolator
unwarpJImageModel swx = new unwarpJImageModel(cx);
unwarpJImageModel swy = new unwarpJImageModel(cy);
// Compute the transformation mapping
boolean ORIGINAL=false;
for (int v=0; v<targetHeight; v++) {
final double tv = (double)(v * intervals) / (double)(targetHeight - 1) + 1.0F;
for (int u = 0; u<targetWidth; u++) {
final double tu = (double)(u * intervals) / (double)(targetWidth - 1) + 1.0F;
swx.prepareForInterpolation(tu, tv, ORIGINAL); transformation_x[v][u] = swx.interpolateI();
swy.prepareForInterpolation(tu, tv, ORIGINAL); transformation_y[v][u] = swy.interpolateI();
}
}
// Compute the warped image
FloatProcessor fp=new FloatProcessor(targetWidth,targetHeight);
for (int v=0; v<targetHeight; v++)
for (int u=0; u<targetWidth; u++) {
final double x = transformation_x[v][u];
final double y = transformation_y[v][u];
if (x>=0 && x<sourceWidth && y>=0 && y<sourceHeight) {
source.prepareForInterpolation(x,y,ORIGINAL);
fp.putPixelValue(u,v,source.interpolateI());
} else
fp.putPixelValue(u,v,0);
}
fp.resetMinAndMax();
sourceImp.setProcessor(sourceImp.getTitle(),fp);
sourceImp.updateImage();
}
示例11: showTransformation
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private void showTransformation(
final int intervals,
final double [][]cx, // Input, spline coefficients
final double [][]cy
){
boolean show_deformation=false;
// Ask for memory for the transformation
double [][] transformation_x=new double [targetHeight][targetWidth];
double [][] transformation_y=new double [targetHeight][targetWidth];
// Compute the deformation
computeDeformation(intervals,cx,cy,transformation_x,transformation_y);
if (show_deformation) {
unwarpJMiscTools.showImage("Transf. X",transformation_x);
unwarpJMiscTools.showImage("Transf. Y",transformation_y);
}
// Compute the warped image
FloatProcessor fp=new FloatProcessor(targetWidth,targetHeight);
FloatProcessor fp_mask=new FloatProcessor(targetWidth,targetHeight);
FloatProcessor fp_target=new FloatProcessor(targetWidth,targetHeight);
int uv=0;
for (int v=0; v<targetHeight; v++)
for (int u=0; u<targetWidth; u++,uv++) {
fp_target.putPixelValue(u,v,target.getImage()[uv]);
if (!targetMsk.getValue(u,v)) {
fp.putPixelValue(u,v,0);
fp_mask.putPixelValue(u,v,0);
} else {
final double x = transformation_x[v][u];
final double y = transformation_y[v][u];
if (sourceMsk.getValue(x,y)) {
source.prepareForInterpolation(x,y,ORIGINAL);
double sval=source.interpolateI();
fp.putPixelValue(u,v,sval);
fp_mask.putPixelValue(u,v,255);
} else {
fp.putPixelValue(u,v,0);
fp_mask.putPixelValue(u,v,0);
}
}
}
fp.resetMinAndMax();
//final ImageStack is = new ImageStack(targetWidth,targetHeight);
is = new ImageStack(targetWidth,targetHeight);
is.addSlice("Registered Image",fp);
System.out.println("outputLevel: " + outputLevel);
outputLevel = 2;
if (outputLevel>-1)
is.addSlice("Target Image",fp_target);
if (outputLevel>-1)
is.addSlice("Warped Source Mask",fp_mask);
if (outputLevel==2) {
System.out.println("true");
showDeformationVectors(intervals,cx,cy,is);
showDeformationGrid(intervals,cx,cy,is);
}
output_ip.setStack("Registered Image",is);
output_ip.setSlice(1); output_ip.getProcessor().resetMinAndMax();
output_ip.show();
if (outputLevel>-1) output_ip.updateAndRepaintWindow();
}