本文整理汇总了Java中ij.plugin.filter.Convolver类的典型用法代码示例。如果您正苦于以下问题:Java Convolver类的具体用法?Java Convolver怎么用?Java Convolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Convolver类属于ij.plugin.filter包,在下文中一共展示了Convolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: makeGradientsAndMagnitudeGray
import ij.plugin.filter.Convolver; //导入依赖的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);
}
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:36,代码来源:CannyEdgeDetector.java
示例2: applyToolToImage
import ij.plugin.filter.Convolver; //导入依赖的package包/类
@Override
public Grid2D applyToolToImage(Grid2D imageProcessor) {
Grid2D out = new Grid2D(imageProcessor.getWidth(),imageProcessor.getHeight());
Convolver conv = new Convolver();
conv.setNormalize(false);
ImageProcessor fp = ImageUtil.wrapGrid2D((Grid2D)imageProcessor.clone());
conv.convolveFloat(fp, new float[]{-1,0,1, -2,0,2, -1,0,1},3, 3);
Grid2D Xgrad = ImageUtil.wrapImageProcessor(fp);
fp = ImageUtil.wrapGrid2D((Grid2D)imageProcessor.clone());
conv.convolveFloat(fp, new float[]{-1,-2,-1, 0,0,0, 1,2,1},3, 3);
Grid2D Ygrad = ImageUtil.wrapImageProcessor(fp);
Grid2D Mgrad = new Grid2D(imageProcessor.getWidth(),imageProcessor.getHeight());
runTransform(out, Xgrad, Ygrad, Mgrad);
return out;
}
开发者ID:akmaier,项目名称:CONRAD,代码行数:21,代码来源:FastRadialSymmetryTool.java
示例3: smussaEsottocampiona
import ij.plugin.filter.Convolver; //导入依赖的package包/类
public static ByteProcessor smussaEsottocampiona(final ByteProcessor input,
final int window, final float sigma) throws IllegalArgumentException {
final ByteProcessor prepocessing = copyByteProcessor(input);
final float gauss[] = initGaussianKernel(window, sigma);
final Convolver convolver = new Convolver();
convolver.convolve(prepocessing, gauss, (int) Math.sqrt(gauss.length),
(int) Math.sqrt(gauss.length));
int prepocessingWidth = prepocessing.getWidth();
int prepocessingHeight = prepocessing.getHeight();
final ByteProcessor out = new ByteProcessor(prepocessingWidth / 2,
prepocessingHeight / 2);
if (prepocessingWidth % 2 != 0)
prepocessingWidth--;
if (prepocessingHeight % 2 != 0)
prepocessingHeight--;
for (int i = 0, x = 0; i < prepocessingWidth; i = i + 2) {
for (int j = 0, y = 0; j < prepocessingHeight; j = j + 2) {
out.set(x, y, prepocessing.get(i, j));
y++;
}
x++;
}
return out;
}
开发者ID:Soulforged,项目名称:ecgdoctor,代码行数:26,代码来源:Supporto.java
示例4: convolveXY
import ij.plugin.filter.Convolver; //导入依赖的package包/类
public static void convolveXY (ImageProcessor fp, float[] h) {
Convolver conv = new Convolver();
conv.setNormalize(false);
conv.convolve(fp, h, h.length, 1);
conv.convolve(fp, h, 1, h.length);
// convolveX(fp, h);
// convolveY(fp, h);
}
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:9,代码来源:Filter.java
示例5: smooth
import ij.plugin.filter.Convolver; //导入依赖的package包/类
/**
* smoothing by 3*3 box filter
*/
private void smooth(float[] dIdu, int size) {
float[] kernel = {1f / 3f, 1f / 3f, 1f / 3f};
Convolver convolver = new Convolver();
FloatProcessor imp = new FloatProcessor(size - 1, size - 1, dIdu, null);
convolver.convolve(imp, kernel, kernel.length, 1);
convolver.convolve(imp, kernel, 1, kernel.length);
}
开发者ID:zitmen,项目名称:thunderstorm,代码行数:12,代码来源:RadialSymmetryFitter.java
示例6: detectSquarePulse
import ij.plugin.filter.Convolver; //导入依赖的package包/类
@Test
@Ignore
public void detectSquarePulse() {
final URL ecgImage = this.getClass().getResource(
"/image/ecg-pink-M201Mo234Std41Sk-1Ku0.jpg");
BufferedImage bi;
try {
bi = ImageIO.read(ecgImage);
final ImageProcessor ip = new ColorProcessor(bi);
final BinaryProcessor bp = new BinaryProcessor(
(ByteProcessor) ip.convertToByte(false));
final Convolver conv = new Convolver();
final BinaryProcessor proc = (BinaryProcessor) bp.convertToByte(false);
final ImagePlus imP = new ImagePlus("", proc);
conv.setup("", imP);
conv.setNormalize(false);
// final OwnFFTFilter fft = new OwnFFTFilter();
// fft.filter(ip, 3, 3, 2, 5);
// fft.filter(ip, 3, 3, 1, 5);
// conv.convolve(proc,new float[] {
// -4, -4, -4, -4, -4,
// -1, -1, -1, -1, -1,
// 32, 16, 0, 16, 32,
// -1, -1, -1, -1, -1,
// -4, -4, -4, -4, -4}, 5, 5);
final Harris_ harr = new Harris_();
// harr.setup("", imP);
harr.filter(proc, 10, 8, 1);
// harr.run(proc);
ImageIO.write(ip.getBufferedImage(), "png", new File(
"target/ecg-pink-org.png"));
ImageIO.write(proc.getBufferedImage(), "png", new File(
"target/ecg-pink-detected.png"));
} catch (final IOException e) {
e.printStackTrace();
}
}
开发者ID:Soulforged,项目名称:ecgdoctor,代码行数:38,代码来源:ImageJTest.java
示例7: makeGradientsAndMagnitudeColor
import ij.plugin.filter.Convolver; //导入依赖的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);
}
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:55,代码来源:CannyEdgeDetector.java
示例8: applyTo
import ij.plugin.filter.Convolver; //导入依赖的package包/类
public void applyTo(FloatProcessor fp) {
Convolver Conv = new Convolver();
Conv.setNormalize(true); // this is important!
Conv.convolve(fp, kernel1D, 1, kernel1D.length);
Conv.convolve(fp, kernel1D, kernel1D.length, 1);
}
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:7,代码来源:GaussianFilter.java
示例9: convolveX
import ij.plugin.filter.Convolver; //导入依赖的package包/类
public static void convolveX (ImageProcessor fp, float[] h) {
Convolver conv = new Convolver();
conv.setNormalize(false);
conv.convolve(fp, h, h.length, 1);
}
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:6,代码来源:Filter.java
示例10: convolveY
import ij.plugin.filter.Convolver; //导入依赖的package包/类
public static void convolveY (ImageProcessor fp, float[] h) {
Convolver conv = new Convolver();
conv.setNormalize(false);
conv.convolve(fp, h, 1, h.length);
}
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:6,代码来源:Filter.java
示例11: applySML
import ij.plugin.filter.Convolver; //导入依赖的package包/类
/**
* Applying the sML filter on the Original ImageStack
*
*/
public void applySML() {
// TODO replace number of ImagePlus, ImageStack new objects
// TODO update filtering according to the matlab code
// TODO change holding matrix data from short processor to floatprocessor
float[] M = { -1, 2, -1};
double[] hGDouble = {0.00296901674395050, 0.0133062098910137,0.0219382312797146,0.0133062098910137,0.00296901674395050,
0.0133062098910137,0.0596342954361801,0.0983203313488458,0.0596342954361801,0.0133062098910137,
0.0219382312797146,0.0983203313488458,0.162102821637127,0.0983203313488458,0.0219382312797146,
0.0133062098910137,0.0596342954361801,0.0983203313488458,0.0596342954361801,0.0133062098910137,
0.00296901674395050,0.0133062098910137,0.0219382312797146,0.0133062098910137,0.00296901674395050};
float[] hG = SME_ENS_Utils.convertDoubleVecFloat(hGDouble);
Convolver convENS = new Convolver();
ImagePlus imp_sml = sme_plugin.getImp().duplicate();
ImageProcessor ip = imp_sml.getProcessor();
sme_plugin.setStack1(imp_sml.getStack()); // ImagePlus into ImageStack
int W = ip.getWidth(); // Get the image width
int H = ip.getHeight(); // Get the image height
int i, j, slice; // Define the type of i, j and slice (equivalent to z axis)
int size_ = sme_plugin.getStack1().getSize(); // Size of the stack image
ImageStack smlResult = new ImageStack(W, H);
for (slice = 1; slice <= size_; slice++) { //Go through each slice
// Work on the duplicated images.
// TODO check if you can remove the dublicate call below
FloatProcessor ip_copy1_X =new FloatProcessor(ip.duplicate().getIntArray());
FloatProcessor ip_copy1_Y =new FloatProcessor(ip.duplicate().getIntArray());
ip = sme_plugin.getStack1().getProcessor(slice); // Returns an ImageProcessor for the specified slice
FloatProcessor ip_sum = new FloatProcessor(W, H); //Create an empty ImageProcessor
// Apply the convolution on the duplicated ImageProcessor
convENS.convolveFloat(ip_copy1_X, hG, 5, 5);
convENS.convolveFloat(ip_copy1_X, M, 3, 1);
convENS.convolveFloat(ip_copy1_Y, hG, 5, 5);
convENS.convolveFloat(ip_copy1_Y, M, 1, 3);
//ip_copy1_X.convolve(hG, 5, 5); // Make the convolution on the X axis
//ip_copy1_Y.convolve(M, 3, 1); // Make the convolution on the X axis
//ip_copy1_X.convolve(hG, 5, 5); // Make the convolution on the Y axis
//ip_copy1_Y.convolve(M, 1, 3); // Make the convolution on the Y axis
for (i = 0; i < W; ++i) {
for (j = 0; j < H; ++j) {
float a = ip_copy1_X.getf(i, j); // get the pixel value in the resultant image after convolution (X axis)
float b = ip_copy1_Y.getf(i, j); // get the pixel value in the resultant image after convolution (Y axis)
float sumPixl = Math.abs(a) +Math.abs(b); // add the 2 pixel values
ip_sum.putPixelValue(i, j, (double) sumPixl); // put the result of the addition in the newly created ImageProcessor
}
}
smlResult.addSlice(ip_sum); // Assigns a pixel array to the specified slice
}
sme_plugin.setStack1(smlResult);
IJ.saveAsTiff(new ImagePlus("SMEresult",smlResult),"SMEtempresults.tiff");
//Image display in new window
sme_plugin.setImp2(new ImagePlus("sML_" + sme_plugin.getImp().getTitle(), sme_plugin.getStack1()));
sme_plugin.getImp2().setStack(sme_plugin.getStack1(), 1, size_, 1);
sme_plugin.getImp2().setCalibration(sme_plugin.getImp2().getCalibration());
//sme_plugin.getImp2().show();
sme_plugin.setSmlImage(sme_plugin.getImp2());
}
开发者ID:biocompibens,项目名称:SME,代码行数:78,代码来源:SME_ENS_Sml_TEST.java
示例12: applyToGrid
import ij.plugin.filter.Convolver; //导入依赖的package包/类
public void applyToGrid(Grid2D input) {
Convolver c = new Convolver();
c.convolveFloat(ImageUtil.wrapGrid2D(input), dKernel.getBuffer(), 3, 3);
}
开发者ID:akmaier,项目名称:CONRAD,代码行数:5,代码来源:LaplaceKernel2D.java
示例13: applyToGrid
import ij.plugin.filter.Convolver; //导入依赖的package包/类
public void applyToGrid(Grid1D input) {
float[] inputFloat = input.getBuffer();
ImageProcessor ip = new FloatProcessor(inputFloat.length, 1, inputFloat);
Convolver c = new Convolver();
c.convolveFloat(ip, dKernel.getBuffer(), 2, 1);
}
开发者ID:akmaier,项目名称:CONRAD,代码行数:7,代码来源:DerivativeKernel.java
示例14: runTransform
import ij.plugin.filter.Convolver; //导入依赖的package包/类
private void runTransform(Grid2D output, Grid2D Xgrad, Grid2D Ygrad, Grid2D Mgrad){
Convolver conv = new Convolver();
conv.setNormalize(false);
// over all radii that are in the set
for (int i = 0; i < radii.length; i++) {
double radius = radii[i];
Grid2D Omap = new Grid2D(output.getWidth(),output.getHeight());
Grid2D Mmap = useOrientationOnly ? null : new Grid2D(output.getWidth(),output.getHeight());
Grid2D F = new Grid2D(output.getWidth(),output.getHeight());
float kappa = (Math.round(radius) <= 1) ? 8 : 9.9f;
// if we want to filter small gradients we need to precompute them to obtain the maximum
float min = Float.MAX_VALUE;
float max = Float.MIN_VALUE;
// go over all pixels and create the gradient magnitude
for (int y = 0; y < output.getHeight(); y++) {
for (int x = 0; x < output.getWidth(); x++) {
// compute gradient magnitude and normalize gradient vectors to unit length
Mgrad.setAtIndex(x, y, (float)(Math.sqrt(Math.pow(Xgrad.getAtIndex(x, y), 2)+Math.pow(Ygrad.getAtIndex(x, y), 2))));
if (Mgrad.getAtIndex(x, y) > max)
max = Mgrad.getAtIndex(x, y);
if (Mgrad.getAtIndex(x, y) < min)
min = Mgrad.getAtIndex(x, y);
}
}
// get the O and M maps
computeOandMmap(Omap, Mmap, Xgrad, Ygrad, Mgrad, radius, kappa, max, min);
// Unsmoothed symmetry measure at this radius value
for (int y = 0; y < output.getHeight(); y++) {
for (int x = 0; x < output.getWidth(); x++) {
if (Mmap == null)
F.setAtIndex(x, y, (float)(Math.pow(Math.abs(Omap.getAtIndex(x, y)/kappa),alpha)));
else
F.setAtIndex(x, y, (float)((Mmap.getAtIndex(x, y)/kappa) * Math.pow(Math.abs(Omap.getAtIndex(x, y)/kappa),alpha)));
}
}
// Generate a Gaussian of size proportional to n to smooth and spread
// the symmetry measure. The Gaussian is also scaled in magnitude
// by n so that large scales do not lose their relative weighting.
ImageProcessor ip = ImageUtil.wrapGrid2D(F);
int gaussSize = (int)Math.round(radius);
if(gaussSize%2==0)
gaussSize++;
conv.convolve(ip, ImageUtil.create2DGauss(gaussSize,gaussSize,0.25*radius).getBuffer(), gaussSize, gaussSize);
NumericPointwiseOperators.addBy(output, ImageUtil.wrapImageProcessor(ip));
}
}
开发者ID:akmaier,项目名称:CONRAD,代码行数:54,代码来源:FastRadialSymmetryTool.java
示例15: ConvolverWrapper
import ij.plugin.filter.Convolver; //导入依赖的package包/类
ConvolverWrapper(float[] kernel, int kw, int kh)
{
super(Convolver.class.getSimpleName(), kernel, kw, kh);
}
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:5,代码来源:KernelFilterTest.java
注:本文中的ij.plugin.filter.Convolver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论