本文整理汇总了Java中ij.process.FloatProcessor.setf方法的典型用法代码示例。如果您正苦于以下问题:Java FloatProcessor.setf方法的具体用法?Java FloatProcessor.setf怎么用?Java FloatProcessor.setf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.FloatProcessor
的用法示例。
在下文中一共展示了FloatProcessor.setf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeMeanAndVariance
import ij.process.FloatProcessor; //导入方法依赖的package包/类
@Override
protected void makeMeanAndVariance(ByteProcessor I, Parameters params) {
int width = I.getWidth();
int height = I.getHeight();
Imean = new FloatProcessor(width, height);
Isigma = new FloatProcessor(width, height);
final int radius = params.radius;
final int n = (radius + 1 + radius) * (radius + 1 + radius);
for (int v = 0; v < height; v++) {
for (int u = 0; u < width; u++) {
long A = 0; // sum of image values in support region
long B = 0; // sum of squared image values in support region
for (int j = -radius; j <= radius; j++) {
for (int i = -radius; i <= radius; i++) {
int p = getPaddedPixel(I, u + i, v + j); // this is slow!
A = A + p;
B = B + p * p;
}
}
Imean.setf(u, v, (float) A / n);
Isigma.setf(u, v, (float) Math.sqrt((B - (double) (A * A) / n) / n));
}
}
}
示例2: makeGradientsAndMagnitudeGray
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private void makeGradientsAndMagnitudeGray(ImageProcessor I) {
FloatProcessor If = I.convertToFloatProcessor(); // always makes a copy
// apply a separable Gaussian filter to I
float[] gaussKernel = makeGaussKernel1d(params.gSigma);
Convolver conv = new Convolver();
conv.setNormalize(true);
conv.convolve(If, gaussKernel, gaussKernel.length, 1);
conv.convolve(If, gaussKernel, 1, gaussKernel.length);
// calculate the gradients in X- and Y-direction
Ex = If;
Ey = (FloatProcessor) If.duplicate();
float[] gradKernel = {-0.5f, 0, 0.5f};
conv.setNormalize(false);
conv.convolve(Ex, gradKernel, gradKernel.length, 1);
conv.convolve(Ey, gradKernel, 1, gradKernel.length);
Emag = new FloatProcessor(M, N);
float emax = 0;
for (int v = 0; v < N; v++) {
for (int u = 0; u < M; u++) {
float dx = Ex.getf(u,v);
float dy = Ey.getf(u,v);
float mag = (float) Math.hypot(dx, dy); // = (float) Math.sqrt(dx*dx + dy*dy);
if (mag > emax)
emax = mag;
Emag.setf(u, v, mag);
}
}
// normalize gradient magnitude
if (params.normGradMag && emax > 0.001)
Emag.multiply(100.0/emax);
}
示例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: readMask
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private FloatProcessor readMask(String imagePath) {
if((imagePath != null) && (imagePath.trim().length() > 0)) {
ImagePlus imp = IJ.openImage(imagePath);
if(imp != null) {
// ensure that the maximum value cannot be more than 1.0 !
FloatProcessor fmask = (FloatProcessor) imp.getProcessor().convertToFloat();
float min = 0;
float max = (float) fmask.getMax();
if(max > 0) {
for(int x = 0; x < fmask.getWidth(); x++) {
for(int y = 0; y < fmask.getHeight(); y++) {
fmask.setf(x, y, (fmask.getf(x, y) - min) / (max - min));
}
}
}
return fmask;
}
}
return ImageMath.ones(width, height);
}
示例5: showSteepestDescentImages
import ij.process.FloatProcessor; //导入方法依赖的package包/类
protected void showSteepestDescentImages(double[][][] S) { // S[u][v][n]
String titlePrefix = "sd";
int w = S.length;
int h = S[0].length;
int n = S[0][0].length;
for (int i = 0; i < n; i++) {
FloatProcessor sdip = new FloatProcessor(w, h);
for (int u = 0; u < w; u++) {
for (int v = 0; v < h; v++) {
sdip.setf(u, v, (float) S[u][v][i]);
}
}
(new ImagePlus(titlePrefix + i, sdip)).show();
}
}
示例6: getUnwarpedImage
import ij.process.FloatProcessor; //导入方法依赖的package包/类
@Deprecated
public static FloatProcessor getUnwarpedImage(ImageProcessor I, LinearMapping W, int w, int h) {
FloatProcessor J = new FloatProcessor(w, h);
int uc = w/2; // center (origin) of R
int vc = h/2;
for (int u = 0; u < w; u++) {
for (int v = 0; v < h; v++) {
double[] x = {u - uc, v - vc}; // position w.r.t. the center of R
double[] xw = W.applyTo(x); // warp from x -> xw
float val = (float) I.getInterpolatedValue(xw[0], xw[1]);
J.setf(u, v, val);
}
}
return J;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: nonMaxSuppression
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private void nonMaxSuppression() {
// perform non-maximum suppression along gradient direction
Enms = new FloatProcessor(M, N);
for (int v = 1; v < N - 1; v++) {
for (int u = 1; u < M - 1; u++) {
int s_theta = getOrientationSector(Ex.getf(u, v), Ey.getf(u, v));
if (isLocalMaximum(Emag, u, v, s_theta, (float) params.loThr)) {
Enms.setf(u, v, Emag.getf(u, v)); // keep local maximum only
}
}
}
}
示例11: getEdgeOrientation
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public FloatProcessor getEdgeOrientation() {
FloatProcessor E_theta = new FloatProcessor(M, N);
for (int u = 0; u < M; u++) {
for (int v = 0; v < N; v++) {
double ex = Ex.getf(u, v);
double ey = Ey.getf(u, v);
float theta = (float) Math.atan2(ey, ex);
E_theta.setf(u, v, theta);
}
}
return E_theta;
}
示例12: 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();
}
示例13: logAnd
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static FloatProcessor logAnd(FloatProcessor a, FloatProcessor b) {
if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
throw new IllegalArgumentException("Error during evaluation of `a&b` expression! Both operands must be of the same size!");
}
FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
for(int x = 0; x < a.getWidth(); x++) {
for(int y = 0; y < a.getHeight(); y++) {
res.setf(x, y, (((a.getf(x, y) != 0.0f) && (b.getf(x, y) != 0.0f)) ? 1.0f : 0.0f));
}
}
return res;
}
示例14: relEq
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static FloatProcessor relEq(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: relNeq
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static FloatProcessor relNeq(FloatProcessor a, FloatProcessor b) {
if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
throw new IllegalArgumentException("Error during evaluation of `a<b` expression! Both operands must be of the same size!");
}
FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
for(int x = 0; x < a.getWidth(); x++) {
for(int y = 0; y < a.getHeight(); y++) {
res.setf(x, y, ((a.getf(x, y) != b.getf(x, y)) ? 1.0f : 0.0f));
}
}
return res;
}