本文整理汇总了Java中ij.process.FloatProcessor.multiply方法的典型用法代码示例。如果您正苦于以下问题:Java FloatProcessor.multiply方法的具体用法?Java FloatProcessor.multiply怎么用?Java FloatProcessor.multiply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.FloatProcessor
的用法示例。
在下文中一共展示了FloatProcessor.multiply方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: imposeMinima
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static void imposeMinima(final FloatProcessor fp, final Roi roi) {
final ImageProcessor fpOrig = fp.duplicate();
// ImageStatistics stats = fp.getStatistics();
fp.setValue(Float.NEGATIVE_INFINITY);
fp.fill(roi);
ROILabeling.fillOutside(fp, roi, Float.POSITIVE_INFINITY);
fpOrig.copyBits(fp, 0, 0, Blitter.MIN);
fpOrig.multiply(-1);
fp.multiply(-1);
morphologicalReconstruction(fp, fpOrig);
fp.multiply(-1);
}
示例3: applyGating
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Applies gating to an angiogram by multiplication of the projection with the corresponding weight.
* Angiograms consist of projection matrices, projection images and the corresponding ECG signal.
* @param a
* @return
*/
public Angiogram applyGating(Angiogram a){
Projection[] pMat = a.getPMatrices();
ImageStack ims = a.getProjections().getImageStack();
double[] primA = a.getPrimAngles();
double[] ecg = a.getEcg();
double[] weights = evaluate(ecg);
ImageStack weightedIms = new ImageStack(ims.getProcessor(1).getWidth(), ims.getProcessor(1).getHeight());
for(int i = 0; i < weights.length; i++){
FloatProcessor current = (FloatProcessor) ims.getProcessor(i+1);
current.multiply(weights[i]);
weightedIms.addSlice(current);
}
ImagePlus reducedImp = new ImagePlus();
reducedImp.setStack(weightedIms);
return new Angiogram(reducedImp, pMat, primA, ecg);
}
示例4: watershedExpand
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public static ImageProcessor watershedExpand(final ByteProcessor bp, final double maxDistance, final boolean conn8) {
FloatProcessor fpEDM = new EDM().makeFloatEDM(bp, (byte)255, false);
fpEDM.multiply(-1);
ImageProcessor ipLabels = ROILabeling.labelImage(bp, conn8);
doWatershed(fpEDM, ipLabels, -maxDistance, conn8);
return ipLabels;
}
示例5: applyToolToImage
import ij.process.FloatProcessor; //导入方法依赖的package包/类
@Override
public Grid2D applyToolToImage(Grid2D imageProcessor)
throws Exception {
FloatProcessor revan = new FloatProcessor(imageProcessor.getWidth(), imageProcessor.getHeight());
revan.setPixels(imageProcessor.getBuffer());
if (operation.equals(MULTIPLY)) {
revan.multiply(operand);
}
if (operation.equals(DIVIDE)) {
revan.multiply(1.0 / operand);
}
if (operation.equals(SUBTRACT)) {
revan.add(-operand);
}
if (operation.equals(ADD)) {
revan.add(operand);
}
if (operation.equals(LOGARITHM)) {
revan.log();
}
if (operation.equals(SQUARE)) {
revan.sqr();
}
if (operation.equals(SQUAREROOT)) {
revan.sqrt();
}
return imageProcessor;
}
示例6: applyToolToImage
import ij.process.FloatProcessor; //导入方法依赖的package包/类
@Override
public Grid2D applyToolToImage(Grid2D imageProcessor) {
FloatProcessor revan = new FloatProcessor(imageProcessor.getWidth(), imageProcessor.getHeight());
revan.setPixels(imageProcessor.getBuffer());
if (!twoD){
float [] kernel = designKernel(nTimes);
if (horizontal)
revan.convolve(kernel, kernel.length, 1);
else
revan.convolve(kernel, 1, kernel.length);
revan.multiply(0.5/Configuration.getGlobalConfiguration().getGeometry().getPixelDimensionX());
} else {
FloatProcessor xDerivative = (FloatProcessor) revan.duplicate();
xDerivative.convolve(designKernelX(), nTimes, nTimes);
xDerivative.multiply(0.5/Configuration.getGlobalConfiguration().getGeometry().getPixelDimensionX());
xDerivative.sqr();
FloatProcessor yDerivative = (FloatProcessor) revan.duplicate();
yDerivative.convolve(designKernelY(), nTimes, nTimes);
yDerivative.sqr();
yDerivative.multiply(0.5/Configuration.getGlobalConfiguration().getGeometry().getPixelDimensionY());
ImageUtil.addProcessors(xDerivative, yDerivative);
xDerivative.sqrt();
revan = xDerivative;
}
Grid2D result = new Grid2D((float[]) revan.getPixels(), revan.getWidth(), revan.getHeight());
return result;
}
示例7: makeGradientsAndMagnitudeColor
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private void makeGradientsAndMagnitudeColor(ColorProcessor I) {
FloatProcessor[] Irgb = rgbToFloatChannels(I);
FloatProcessor[] Ixrgb = new FloatProcessor[3];
FloatProcessor[] Iyrgb = new FloatProcessor[3];
// apply a separable Gaussian filter to each RGB channel
float[] gaussKernel = makeGaussKernel1d(params.gSigma);
Convolver conv = new Convolver();
conv.setNormalize(true);
for (int i=0; i<Irgb.length; i++) {
FloatProcessor If = Irgb[i];
conv.convolve(If, gaussKernel, gaussKernel.length, 1);
conv.convolve(If, gaussKernel, 1, gaussKernel.length);
Ixrgb[i] = If;
Iyrgb[i] = (FloatProcessor) If.duplicate();
}
// calculate the gradients in X- and Y-direction for each RGB channel
float[] gradKernel = {-0.5f, 0, 0.5f};
conv.setNormalize(false);
for (int i = 0; i < Irgb.length; i++) {
FloatProcessor Ix = Ixrgb[i];
FloatProcessor Iy = Iyrgb[i];
conv.convolve(Ix, gradKernel, gradKernel.length, 1);
conv.convolve(Iy, gradKernel, 1, gradKernel.length);
}
// calculate gradient magnitude
Ex = new FloatProcessor(M, N);
Ey = new FloatProcessor(M, N);
Emag = new FloatProcessor(M, N);
float emax = 0;
for (int v = 0; v < N; v++) {
for (int u = 0; u < M; u++) {
float rx = Ixrgb[0].getf(u,v), ry = Iyrgb[0].getf(u,v);
float gx = Ixrgb[1].getf(u,v), gy = Iyrgb[1].getf(u,v);
float bx = Ixrgb[2].getf(u,v), by = Iyrgb[2].getf(u,v);
float A = rx*rx + gx*gx + bx*bx;
float B = ry*ry + gy*gy + by*by;
float C = rx*ry + gx*gy + bx*by;
float D = (float) Math.sqrt((A - B)*(A - B) + 4*C*C);
float mag = (float) Math.sqrt(0.5*(A+B+D));
if (mag > emax) emax = mag;
Emag.setf(u, v, mag);
Ex.setf(u, v, A - B + D);
Ey.setf(u, v, 2*C);
}
}
//IJ.log("RGB emax = " + emax);
// normalize gradient magnitude
if (params.normGradMag && emax > 0.001)
Emag.multiply(100.0/emax);
}
示例8: backproject
import ij.process.FloatProcessor; //导入方法依赖的package包/类
@Override
public void backproject(Grid2D projection, int projectionNumber) {
boolean debug = false;
int count = 0;
initialize(projection);
FloatProcessor currentProjection = new FloatProcessor(projection.getWidth(), projection.getHeight(), projection.getBuffer(), null);
// Constant part of distance weighting (D^2) + additional weighting for arbitrary scan ranges
double D = getGeometry().getSourceToDetectorDistance();
currentProjection.multiply(10* D*D * 2* Math.PI * getGeometry().getPixelDimensionX() / getGeometry().getNumProjectionMatrices());
int p = projectionNumber;
double[] voxel = new double [4];
voxel[3] = 1;
for (int k = 0; k < maxK ; k++){ // for all slices
voxel[2] = (this.getGeometry().getVoxelSpacingZ() * k) - offsetZ;
for (int i=0; i < maxI; i++){ // for all lines
voxel[0] = (this.getGeometry().getVoxelSpacingX() * i) - offsetX;
for (int j = 0; j < maxJ; j++){ // for all voxels
// compute real world coordinates in homogenious coordinates;
//if (voiMap[i][j][k]){
voxel[1] = (this.getGeometry().getVoxelSpacingY() * j) - offsetY;
SimpleVector point3d = new SimpleVector(voxel);
//Compute coordinates in projection data.
Projection Pcurr = getGeometry().getProjectionMatrix(p);
SimpleVector point2d = SimpleOperators.multiply(Pcurr.computeP(), point3d);
double coordX = point2d.getElement(0) / point2d.getElement(2);
double coordY = point2d.getElement(1) / point2d.getElement(2);
// back project
double distanceWeight = point2d.getElement(2);
double increment = currentProjection.getInterpolatedValue(coordX + lineOffset, coordY)/(distanceWeight*distanceWeight);
if (Double.isNaN(increment)){
debug = true;
if (count < 10) System.out.println("NAN Happened at i = " + i + " j = " + j + " k = " + k + " projection = " + projectionNumber + " x = " + coordX + " y = " + coordY );
increment = 1;
count ++;
}
updateVolume(i, j, k, increment);
//}
}
}
}
if (debug) {
throw new RuntimeException("Encountered NaN in projection!");
}
}