本文整理汇总了Java中ij.process.FloatProcessor.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java FloatProcessor.getWidth方法的具体用法?Java FloatProcessor.getWidth怎么用?Java FloatProcessor.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.FloatProcessor
的用法示例。
在下文中一共展示了FloatProcessor.getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVariance
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static double getVariance(FloatProcessor ip) {
final int W = ip.getWidth();
final int H = ip.getHeight();
final int N = W * H;
final double mean = getMean(ip);
double sum = 0;
for (int j = 0; j < H; j++) {
for (int i = 0; i < W; i++) {
double d = ip.getf(i, j) - mean;
sum = sum + d * d;
}
}
return sum / N;
}
示例2: getVariance2
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static double getVariance2(FloatProcessor ip) {
final int W = ip.getWidth();
final int H = ip.getHeight();
final int N = W * H;
double sumX = 0;
double sumX2 = 0;
for (int j = 0; j < H; j++) {
for (int i = 0; i < W; i++) {
double x = ip.getf(i, j);
sumX = sumX + x;
sumX2 = sumX2 + x * x;
}
}
double var = (sumX2 - sumX * sumX / N) / N ;
return var;
}
示例3: imposeMaxima
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static void imposeMaxima(final FloatProcessor fp, final ImageProcessor ipMask) {
final ImageProcessor fpOrig = fp.duplicate();
final ImageStatistics stats = fp.getStatistics();
final int w = fp.getWidth();
final int h = fp.getHeight();
for (int i = 0; i < w * h; i++) {
if (ipMask.getf(i) == 0)
fp.setf(i, Float.NEGATIVE_INFINITY);
else
fp.setf(i, Float.POSITIVE_INFINITY);
}
fpOrig.copyBits(fp, 0, 0, Blitter.MAX);
morphologicalReconstruction(fp, fpOrig);
for (int i = 0; i < w * h; i++) {
if (ipMask.getf(i) != 0)
fp.setf(i, (float)stats.max);
}
}
示例4: getLine
import ij.process.FloatProcessor; //导入方法依赖的package包/类
protected double[] getLine(FloatProcessor fp, int v) {
double[] line = new double[fp.getWidth()];
for (int u = 0; u < line.length; u++) {
line[u] = fp.getf(u, v);
}
return line;
}
示例5: LucasKanadeMatcher
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Creates a new Lucas-Kanade-type matcher.
* @param I the search image (of type {@link FloatProcessor}).
* @param R the reference image (of type {@link FloatProcessor})
* @param params a parameter object of type {@link LucasKanadeMatcher.Parameters}.
*/
protected LucasKanadeMatcher(FloatProcessor I, FloatProcessor R, Parameters params) {
this.I = I; // search image
this.R = R; // reference image
this.params = params;
wR = R.getWidth();
hR = R.getHeight();
xc = 0.5 * (wR - 1);
yc = 0.5 * (hR - 1);
}
示例6: getMatch
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public float[][] getMatch(FloatProcessor R) {
this.R = R;
this.MR = R.getWidth();
this.NR = R.getHeight();
this.K = MR * NR;
// calculate the mean and variance of template
double sumR = 0;
double sumR2 = 0;
for (int j = 0; j < NR; j++) {
for (int i = 0; i < MR; i++) {
float aR = R.getf(i,j);
sumR += aR;
sumR2 += aR * aR;
}
}
this.meanR = sumR / K;
this.varR = Math.sqrt(sumR2 - K * meanR * meanR);
float[][] C = new float[MI - MR + 1][NI - NR + 1];
for (int r = 0; r <= MI - MR; r++) {
for (int s = 0; s <= NI - NR; s++) {
float d = (float) getMatchValue(r, s);
C[r][s] = d;
}
}
this.R = null;
return C;
}
示例7: getMean
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static double getMean(FloatProcessor ip) {
final int W = ip.getWidth();
final int H = ip.getHeight();
final int N = W * H;
double sum = 0;
for (int j = 0; j < H; j++) {
for (int i = 0; i < W; i++) {
sum = sum + ip.getf(i, j);
}
}
return sum / N;
}
示例8: makeEyeTrackHeatmap
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private BufferedImage makeEyeTrackHeatmap() {
long time = 0;
ImagePlus imp;
FloatProcessor ip = new FloatProcessor(viewer.getThumbnail().getWidth(), viewer.getThumbnail().getHeight());
Point2D[] eyeArray = trackerFeatures.getEyeArray();
for (int i = 0; i < eyeArray.length; i++) {
progressBarFrame.setCurrentFrame(i);
setProgress((int) ((double) (i * 100) / (double)totalTasks));
if (eyeArray[i] != null) {
if (i == 0) {
time = trackerFeatures.getTracker().getFrame(i).getTimestamp();
} else {
time = trackerFeatures.getTracker().getFrame(i).getTimestamp() - time;
}
int x = (int) (eyeArray[i].getX()*scalex);
int y = (int) (eyeArray[i].getY()*scaley);
if(x > 0 && y > 0 && x < ip.getWidth() && y < ip.getHeight())
ip.setf(x, y, ip.getf(x, y) + 100);
}
}
ip.blurGaussian(25);
imp = new ImagePlus("Eye heatmap", ip);
IJ.run(imp, "Fire", "");
return imp.getBufferedImage();
}
示例9: PixelIterator
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public PixelIterator(final FloatProcessor fp) {
final Rectangle roi = fp.getRoi();
width = fp.getWidth();
pixels = (float[]) fp.getPixels();
xMin = roi.x + 1;
xMax = roi.x + roi.width - 2;
yMin = roi.y + 1;
yMax = roi.y + roi.height - 2;
rowOffset = width;
rewind();
}
示例10: generate
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public void generate(FloatProcessor img) {
double [] params = new double[molecule.values.length];
for(int i = 0; i < params.length; i++) {
params[i] = molecule.values[i];
}
//
int width = img.getWidth(), height = img.getHeight();
for(int x = (int)(molecule.getX() - region), xm = (int)(molecule.getX() + region); x <= xm; x++) {
if((x < 0) || (x >= width)) continue;
for(int y = (int)(molecule.getY() - region), ym = (int)(molecule.getY() + region); y <= ym; y++) {
if((y < 0) || (y >= height)) continue;
img.setf(x, y, img.getf(x, y) + (float)model.getValue(params, x+0.5, y+0.5));
}
}
}
示例11: generateBackground
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public FloatProcessor generateBackground(int width, int height, Drift drift, Range bkg) {
// padd the background image; crop the center of the image later, after the drift is applied
FloatProcessor img = new FloatProcessor(width + 2*(int)ceil(drift.dist), height + 2*(int)ceil(drift.dist));
for(int x = 0, w = img.getWidth(); x < w; x++)
for(int y = 0, h = img.getHeight(); y < h; y++)
img.setf(x, y, (float)getNextUniform(bkg.from, bkg.to));
IFilter filter = new BoxFilter(1+2*(int)(((double)Math.min(width, width))/8.0));
return filter.filterImage(img);
}
示例12: generateMolecules
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public Vector<EmitterModel> generateMolecules(int width, int height, FloatProcessor mask, double density, Range intensity_photons, IPsfUI psf) {
MoleculeDescriptor descriptor = null;
double[] params = new double[PSFModel.Params.PARAMS_LENGTH];
Vector<EmitterModel> molist = new Vector<EmitterModel>();
double gPpx = Units.NANOMETER_SQUARED.convertTo(Units.MICROMETER_SQUARED, sqr(CameraSetupPlugIn.getPixelSize())*width*height/(mask.getWidth()*mask.getHeight())) * density, p_px, p, fwhm0;
double zFrom = psf.getZRange().from, zTo = psf.getZRange().to;
for(int x = 0; x < mask.getWidth(); x++) {
for(int y = 0; y < mask.getHeight(); y++) {
p_px = gPpx * mask.getf(x, y); //expected number of molecules inside a pixel
int nMols = p_px > 0 ? (int) rand.nextPoisson(p_px) : 0; //actual number of molecules inside a pixel
for(int i = 0; i < nMols; i++) {
double z = getNextUniform(zFrom, zTo);
params[PSFModel.Params.X] = (x + 0.5 + getNextUniform(-0.5, +0.5)) * width / mask.getWidth();
params[PSFModel.Params.Y] = (y + 0.5 + getNextUniform(-0.5, +0.5)) * height / mask.getHeight();
params[PSFModel.Params.SIGMA] = psf.getSigma1(z);
params[PSFModel.Params.SIGMA1] = psf.getSigma1(z);
params[PSFModel.Params.SIGMA2] = psf.getSigma2(z);
params[PSFModel.Params.INTENSITY] = getNextUniform(intensity_photons.from, intensity_photons.to);
params[PSFModel.Params.ANGLE] = psf.getAngle();
PSFModel model = psf.getImplementation();
Molecule mol = model.newInstanceFromParams(params, Units.PHOTON, false);
if(psf.is3D()) {
mol.addParam(PSFModel.Params.LABEL_Z, Units.NANOMETER, z);
}
//set a common MoleculeDescriptor for all molecules in a frame to save memory
if(descriptor != null){
mol.descriptor = descriptor;
}else{
descriptor = mol.descriptor;
}
molist.add(new EmitterModel(model, mol));
}
}
}
return molist;
}
示例13: computeUVDerivative
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private Grid2D computeUVDerivative(int index){
float [] kernel = {-1, 0, 1};
ImageProcessor revan = new FloatProcessor(inputQueue.get(index).getWidth(), inputQueue.get(index).getHeight());
// derivative in row direction
FloatProcessor uDev = new FloatProcessor(revan.getWidth(), revan.getHeight());
System.arraycopy(inputQueue.get(index).getBuffer(), 0, (float[]) uDev.getPixels(), 0, inputQueue.get(index).getBuffer().length);
uDev.convolve(kernel, 3, 1);
// derivative in column direction
ImageProcessor vDev = new FloatProcessor(revan.getWidth(), revan.getHeight());
System.arraycopy(inputQueue.get(index).getBuffer(), 0, (float[]) vDev.getPixels(), 0, inputQueue.get(index).getBuffer().length);
vDev.convolve(kernel, 1, 3);
// weight and add to result.
for(int i =0; i<uDev.getWidth(); i++){
for (int j=0; j< uDev.getHeight(); j++){
double u = uDev.getPixelValue(i, j);
u /= detectorElementSizeX * 2;
u *= uWeights[i];
uDev.putPixelValue(i, j, u);
double v = vDev.getPixelValue(i, j);
v *= vWeights[i][j];
v /= detectorElementSizeY * 2;
revan.putPixelValue(i, j, v+u);
}
}
//if (index == 1) VisualizationUtil.showImageProcessor(revan);
return new Grid2D((float[])revan.getPixels(), revan.getWidth(), revan.getHeight());
}
示例14: relNeq
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static FloatProcessor relNeq(Double val, FloatProcessor mat) {
float v = val.floatValue();
FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight());
res.setMask(mat.getMask());
for(int x = 0; x < mat.getWidth(); x++) {
for(int y = 0; y < mat.getHeight(); y++) {
res.setf(x, y, ((mat.getf(x, y) != v) ? 1.0f : 0.0f));
}
}
return res;
}
示例15: SerializableFloatProcessor
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/** Creates a new FloatProcessor using the specified ImageProcessor.
Set 'cm' to null to use the default grayscale LUT. */
public SerializableFloatProcessor(ImageProcessor imageProcessor) {
imageProcessor = imageProcessor.duplicate();
FloatProcessor floatProcessor = imageProcessor.toFloat(0, null);
this.width = floatProcessor.getWidth();
this.height = floatProcessor.getHeight();
this.pixels = (float []) floatProcessor.getPixels();
this.cm = floatProcessor.getColorModel();
resetRoi();
if (pixels!=null)
findMinAndMax();
}