本文整理汇总了Java中ij.process.FloatProcessor.getf方法的典型用法代码示例。如果您正苦于以下问题:Java FloatProcessor.getf方法的具体用法?Java FloatProcessor.getf怎么用?Java FloatProcessor.getf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.FloatProcessor
的用法示例。
在下文中一共展示了FloatProcessor.getf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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;
}
示例4: makeMeanAndVariance
import ij.process.FloatProcessor; //导入方法依赖的package包/类
@Override
protected void makeMeanAndVariance(ByteProcessor I, Parameters params) {
// //uses ImageJ's GaussianBlur
// local variance over square of size (size + 1 + size)^2
int width = I.getWidth();
int height = I.getHeight();
Imean = new FloatProcessor(width,height);
Isigma = new FloatProcessor(width,height);
FloatProcessor A = (FloatProcessor) I.convertToFloatProcessor();
FloatProcessor B = (FloatProcessor) I.convertToFloatProcessor();
B.sqr();
GaussianBlur gb = new GaussianBlur();
double sigma = params.radius * 0.6; // sigma of Gaussian filter should be approx. 0.6 of the disk's radius
gb.blurFloat(A, sigma, sigma, 0.002);
gb.blurFloat(B, sigma, sigma, 0.002);
for (int v = 0; v < height; v++) {
for (int u = 0; u < width; u++) {
float a = A.getf(u, v);
float b = B.getf(u, v);
float sigmaG = (float) Math.sqrt(b - a*a);
Imean.setf(u, v, a);
Isigma.setf(u, v, sigmaG);
}
}
}
示例5: 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;
}
示例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: collectCorners
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private List<Corner> collectCorners(FloatProcessor Q, float tH, int border) {
List<Corner> C = new ArrayList<Corner>();
for (int v = border; v < N - border; v++) {
for (int u = border; u < M - border; u++) {
float q = Q.getf(u, v);
if (q > tH && isLocalMax(Q, u, v)) {
Corner c = new Corner(u, v, q);
C.add(c);
}
}
}
return C;
}
示例8: isLocalMaximum
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private boolean isLocalMaximum(FloatProcessor gradMagnitude, int u, int v, int s_theta, float mMin) {
float mC = gradMagnitude.getf(u, v);
if (mC < mMin) {
return false;
}
else {
float mL = 0, mR = 0;
switch (s_theta) {
case 0 :
mL = gradMagnitude.getf(u-1, v);
mR = gradMagnitude.getf(u+1, v);
break;
case 1 :
mL = gradMagnitude.getf(u-1, v-1);
mR = gradMagnitude.getPixelValue(u+1, v+1);
break;
case 2 :
mL = gradMagnitude.getf(u, v-1);
mR = gradMagnitude.getf(u, v+1);
break;
case 3 :
mL = gradMagnitude.getf(u-1, v+1);
mR = gradMagnitude.getf(u+1, v-1);
break;
}
return (mL <= mC && mC >= mR);
}
}
示例9: 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;
}
示例10: computeDensities
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static double[] computeDensities(ByteProcessor bp, Polygon polyGrid, double coreDiameterPx) {
RankFilters rf = new RankFilters();
FloatProcessor fp = bp.convertToFloatProcessor();
fp.max(1.0);
rf.rank(fp, coreDiameterPx*0.5, RankFilters.MEAN);
double[] densities = new double[polyGrid.npoints];
for (int i = 0; i < densities.length; i++) {
int x = polyGrid.xpoints[i];
int y = polyGrid.ypoints[i];
if (x >= 0 && y >= 0 && x < bp.getWidth() && y < bp.getHeight())
densities[i] = fp.getf(x, y);
}
return densities;
}
示例11: 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;
}
示例12: samplePoisson
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Replaces each pixel value with a sample from a poisson distribution with mean value equal to the pixel original value.
*/
FloatProcessor samplePoisson(FloatProcessor fp){
for(int i = 0; i < fp.getPixelCount(); i ++){
float mean = fp.getf(i);
double value = mean > 0 ? (rand.nextPoisson(mean)) : 0;
fp.setf(i, (float)value);
}
return fp;
}
示例13: sampleGamma
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Replaces each pixel value with a sample from a Gamma distribution with shape equal to the original pixel value and scale equal to the gain parameter.
*/
FloatProcessor sampleGamma(FloatProcessor fp, double gain){
for(int i = 0; i < fp.getPixelCount(); i ++){
double value = fp.getf(i);
value = rand.nextGamma(value + 1e-10, gain);
fp.setf(i, (float)value);
}
return fp;
}
示例14: multiplyImageByGaussianMask
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private static void multiplyImageByGaussianMask(Point2D.Double gaussianCenter, double gaussianSigma, FloatProcessor image) {
for(int y = 0; y < image.getHeight(); y++) {
for(int x = 0; x < image.getWidth(); x++) {
double maskValue = MathProxy.exp(-(MathProxy.sqr(x - gaussianCenter.x) + MathProxy.sqr(y - gaussianCenter.y)) / (2 * gaussianSigma * gaussianSigma));
float newValue = (float) (image.getf(x, y) * maskValue);
image.setf(x, y, newValue);
}
}
}
示例15: modulo
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static FloatProcessor modulo(float val, FloatProcessor mat) {
FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight());
res.setMask(mat.getMask());
float tmp;
for (int i = 0, im = mat.getWidth(); i < im; i++) {
for (int j = 0, jm = mat.getHeight(); j < jm; j++) {
tmp = val / mat.getf(i, j);
res.setf(i, j, val - (((float)((int)tmp)) * mat.getf(i, j)));
}
}
return res;
}