本文整理了Java中ij.plugin.filter.GaussianBlur
类的一些代码示例,展示了GaussianBlur
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GaussianBlur
类的具体详情如下:
包路径:ij.plugin.filter.GaussianBlur
类名称:GaussianBlur
[英]This plug-in filter uses convolution with a Gaussian function for smoothing. 'Radius' means the radius of decay to exp(-0.5) ~ 61%, i.e. the standard deviation sigma of the Gaussian (this is the same as in Photoshop, but different from the 'Gaussian Blur' in ImageJ versions before 1.38u, where a value 2.5 times as much had to be entered. - Like all convolution operations in ImageJ, it assumes that out-of-image pixels have a value equal to the nearest edge pixel. This gives higher weight to edge pixels than pixels inside the image, and higher weight to corner pixels than non-corner pixels at the edge. Thus, when smoothing with very high blur radius, the output will be dominated by the edge pixels and especially the corner pixels (in the extreme case, with a blur radius of e.g. 1e20, the image will be raplaced by the average of the four corner pixels). - For increased speed, except for small blur radii, the lines (rows or columns of the image) are downscaled before convolution and upscaled to their original length thereafter. Version 03-Jun-2007 M. Schmid with preview, progressBar stack-aware, snapshot via snapshot flag; restricted range for resetOutOfRoi 20-Feb-2010 S. Saalfeld inner multi-threading
[中]该插件过滤器使用卷积和高斯函数进行平滑半径’指衰减至exp(-0.5)~61%的半径,即高斯分布的标准偏差σ(这与Photoshop中的相同,但不同于1.38u之前的ImageJ版本中的“高斯模糊”,其中必须输入2.5倍的值。-与ImageJ中的所有卷积运算一样,它假设图像外像素的值等于最近的边缘像素。这使边缘像素的权重高于图像内像素的权重与边缘的非角点像素相比,角点像素的权重更高。因此,当使用非常高的模糊半径进行平滑时,输出将由边缘像素,尤其是角点像素控制(在极端情况下,使用例如1e20的模糊半径,图像将由四个角点像素的平均值重新定位)为了提高速度,除了较小的模糊半径外,线(图像的行或列)在卷积之前被缩小,之后被放大到其原始长度。版本03-Jun-2007 M.Schmid,带预览、progressBar堆栈感知、快照通过快照标志;resetOutOfRoi的限制范围2010年2月20日S.Saalfeld内多线程
代码示例来源:origin: sc.fiji/TrakEM2_
@Override
public ImageProcessor process(ImageProcessor ip) {
ij.plugin.filter.GaussianBlur g = new ij.plugin.filter.GaussianBlur();
g.blurGaussian(ip, sigmaX, sigmaY, accuracy);
return ip;
}
代码示例来源:origin: mpicbg/mpicbg
/**
* Smooth with a Gaussian kernel that represents downsampling at a given
* scale factor and sourceSigma.
*/
final static public void smoothForScale(
final FloatProcessor source,
final double scale,
final float sourceSigma,
final float targetSigma )
{
assert scale <= 1.0f : "Downsampling requires a scale factor < 1.0";
final double s = targetSigma / scale;
final double v = s * s - sourceSigma * sourceSigma;
if ( v <= 0 )
return;
final float sigma = ( float )Math.sqrt( v );
// final float[] kernel = createNormalizedGaussianKernel( sigma );
// convolveSeparable( source, kernel, kernel );
new GaussianBlur().blurFloat( source, sigma, sigma, 0.01 );
}
代码示例来源:origin: net.imagej/ij
/** Since most computing time is spent in GaussianBlur, forward the
* information about the number of passes to Gaussian Blur. The
* ProgressBar will be handled by GaussianBlur. */
public void setNPasses(int nPasses) {
if (gb == null) gb = new GaussianBlur();
gb.setNPasses(nPasses);
}
}
代码示例来源:origin: net.imagej/ij
/** Blurs the image by convolving with a Gaussian function. */
public void blurGaussian(double sigma) {
resetRoi();
GaussianBlur gb = new GaussianBlur();
gb.showProgress(false);
gb.blurGaussian(this, sigma);
}
代码示例来源:origin: sc.fiji/Interactive_3D_Surface_Plot
protected void applySmoothingFilter(double rad) {
float[] pixels = new float[gridHeight*gridWidth];
for (int i=0; i < gridHeight*gridWidth; i++) {
pixels[i] = (float) plotList[i].lum;
}
ImageProcessor ip = new FloatProcessor(gridWidth, gridHeight, pixels, null);
new GaussianBlur().blur(ip, rad);
// reset progress bar (which was set by gaussian blur)
IJ.showProgress( 1.);
// ImagePlus imp2 = new ImagePlus("test", ip);
// imp2.show();
// imp2.updateAndDraw();
pixels = (float[] )ip.getPixels();
for (int i=0; i < gridHeight*gridWidth; i++) {
plotList[i].z = plotList[i].zf = pixels[i];
}
applyMinMax();
}
代码示例来源:origin: stackoverflow.com
importClass(Packages.ij.plugin.filter.GaussianBlur);
var imp = IJ.openImage("http://imagej.nih.gov/ij/images/clown.jpg");
IJ.run(imp, "8-bit", "");
var ip = imp.getProcessor();
var gs = new GaussianBlur();
gs.blurGaussian(ip,20,20,0.01);
imp.show();
代码示例来源:origin: net.imagej/ij
int[] smooth(int[] a, int n) {
FloatProcessor fp = new FloatProcessor(n, 1);
for (int i=0; i<n; i++)
fp.putPixelValue(i, 0, a[i]);
GaussianBlur gb = new GaussianBlur();
gb.blur1Direction(fp, 2.0, 0.01, true, 0);
for (int i=0; i<n; i++)
a[i] = (int)Math.round(fp.getPixelValue(i, 0));
return a;
}
代码示例来源:origin: net.imagej/ij
public static void blur(ImagePlus imp, double sigmaX, double sigmaY, double sigmaZ) {
imp.deleteRoi();
ImageStack stack = imp.getStack();
if (sigmaX>0.0 || sigmaY>0.0) {
GaussianBlur gb = new GaussianBlur();
int channels = stack.getProcessor(1).getNChannels();
gb.setNPasses(channels*imp.getStackSize());
for (int i=1; i<=imp.getStackSize(); i++) {
ImageProcessor ip = stack.getProcessor(i);
double accuracy = (imp.getBitDepth()==8||imp.getBitDepth()==24)?0.002:0.0002;
gb.blurGaussian(ip, sigmaX, sigmaY, accuracy);
}
}
if (sigmaZ>0.0) {
if (imp.isHyperStack())
blurHyperStackZ(imp, sigmaZ);
else
blurZ(stack, sigmaZ);
imp.updateAndDraw();
}
}
代码示例来源:origin: net.imagej/ij
private static void blurZ(ImageStack stack, double sigmaZ) {
GaussianBlur gb = new GaussianBlur();
double accuracy = (stack.getBitDepth()==8||stack.getBitDepth()==24)?0.002:0.0002;
int w=stack.getWidth(), h=stack.getHeight(), d=stack.getSize();
float[] zpixels = null;
FloatProcessor fp =null;
IJ.showStatus("Z blurring");
gb.showProgress(false);
int channels = stack.getProcessor(1).getNChannels();
for (int y=0; y<h; y++) {
IJ.showProgress(y, h-1);
for (int channel=0; channel<channels; channel++) {
zpixels = stack.getVoxels(0, y, 0, w, 1, d, zpixels, channel);
if (fp==null)
fp = new FloatProcessor(w, d, zpixels);
//if (y==h/2) new ImagePlus("before-"+h/2, fp.duplicate()).show();
gb.blur1Direction(fp, sigmaZ, accuracy, false, 0);
stack.setVoxels(0, y, 0, w, 1, d, zpixels, channel);
}
}
IJ.showStatus("");
}
代码示例来源:origin: stackoverflow.com
GaussianBlur gaussianBlur = new GaussianBlur();
gaussianBlur.load();
gaussianBlur.attributes.set("radius",15);
gaussianBlur.process(image.clone(), image, mask1);
gaussianBlur.process(image.clone(), image, mask2);
gaussianBlur.process(image.clone(), image, mask3);
gaussianBlur.process(image.clone(), image, mask4);
代码示例来源:origin: net.imagej/ij
/** Gaussian Filtering of an ImageProcessor
* @param ip The ImageProcessor to be filtered.
* @param sigma Standard deviation of the Gaussian (pixels)
*
* @see ij.process.ImageProcessor#blurGaussian(double)
*/
public void blurGaussian(ImageProcessor ip, double sigma) {
double accuracy = (ip instanceof ByteProcessor||ip instanceof ColorProcessor)?0.002:0.0002;
blurGaussian(ip, sigma, sigma, accuracy);
}
代码示例来源:origin: net.imagej/ij
/** Gaussian Filtering of an ImageProcessor
* @param ip The ImageProcessor to be filtered.
* @param sigmaX Standard deviation of the Gaussian in x direction (pixels)
* @param sigmaY Standard deviation of the Gaussian in y direction (pixels)
* @param accuracy Accuracy of kernel, should not be above 0.02. Better (lower)
* accuracy needs slightly more computing time.
*/
public void blurGaussian(ImageProcessor ip, double sigmaX, double sigmaY, double accuracy) {
boolean hasRoi = ip.getRoi().height!=ip.getHeight() && sigmaX>0 && sigmaY>0;
if (hasRoi && !calledAsPlugin)
ip.snapshot();
if (nPasses<=1)
nPasses = ip.getNChannels() * (sigmaX>0 && sigmaY>0 ? 2 : 1);
FloatProcessor fp = null;
for (int i=0; i<ip.getNChannels(); i++) {
fp = ip.toFloat(i, fp);
if (Thread.currentThread().isInterrupted()) return; // interruption for new parameters during preview?
blurFloat(fp, sigmaX, sigmaY, accuracy);
if (Thread.currentThread().isInterrupted()) return;
ip.setPixels(i, fp);
}
if (hasRoi)
resetOutOfRoi(ip, (int)Math.ceil(5*sigmaY)); // reset out-of-Rectangle pixels above and below roi
return;
}
代码示例来源:origin: axtimwalde/mpicbg
filter.blurFloat( ipD, sigma, sigma, 0.002 );
代码示例来源:origin: sc.fiji/Fiji_Plugins
GaussianBlur blurImage= new GaussianBlur();
pos = 0;
for(channel = 0; channel < 3; channel++){
blurImage= new GaussianBlur();
blurImage.blur(imProcBGR[channel],(double)RetinexScales[scale]*2.5); //2.5 is the difference between IJ blur and photoshop's see ImageJ API
out=(float[]) imProcBGR[channel].getPixelsCopy();
代码示例来源:origin: stackoverflow.com
GaussianBlur blurEffect = new GaussianBlur(5);
root.setEffect(blurEffect);
代码示例来源:origin: net.imagej/ij
float[] smooth(float[] a, int n) {
FloatProcessor fp = new FloatProcessor(n, 1);
for (int i=0; i<n; i++)
fp.setf(i, 0, a[i]);
GaussianBlur gb = new GaussianBlur();
gb.blur1Direction(fp, 2.0, 0.01, true, 0);
for (int i=0; i<n; i++)
a[i] = fp.getf(i, 0);
return a;
}
代码示例来源:origin: imagej/ImageJA
/** Blurs the image by convolving with a Gaussian function. */
public void blurGaussian(double sigma) {
resetRoi();
GaussianBlur gb = new GaussianBlur();
gb.showProgress(false);
gb.blurGaussian(this, sigma);
}
代码示例来源:origin: imagej/ImageJA
public static void blur(ImagePlus imp, double sigmaX, double sigmaY, double sigmaZ) {
imp.deleteRoi();
ImageStack stack = imp.getStack();
if (sigmaX>0.0 || sigmaY>0.0) {
GaussianBlur gb = new GaussianBlur();
int channels = stack.getProcessor(1).getNChannels();
gb.setNPasses(channels*imp.getStackSize());
for (int i=1; i<=imp.getStackSize(); i++) {
ImageProcessor ip = stack.getProcessor(i);
double accuracy = (imp.getBitDepth()==8||imp.getBitDepth()==24)?0.002:0.0002;
gb.blurGaussian(ip, sigmaX, sigmaY, accuracy);
}
}
if (sigmaZ>0.0) {
if (imp.isHyperStack())
blurHyperStackZ(imp, sigmaZ);
else
blurZ(stack, sigmaZ);
imp.updateAndDraw();
}
}
代码示例来源:origin: imagej/ImageJA
private static void blurZ(ImageStack stack, double sigmaZ) {
GaussianBlur gb = new GaussianBlur();
double accuracy = (stack.getBitDepth()==8||stack.getBitDepth()==24)?0.002:0.0002;
int w=stack.getWidth(), h=stack.getHeight(), d=stack.getSize();
float[] zpixels = null;
FloatProcessor fp =null;
IJ.showStatus("Z blurring");
gb.showProgress(false);
int channels = stack.getProcessor(1).getNChannels();
for (int y=0; y<h; y++) {
IJ.showProgress(y, h-1);
for (int channel=0; channel<channels; channel++) {
zpixels = stack.getVoxels(0, y, 0, w, 1, d, zpixels, channel);
if (fp==null)
fp = new FloatProcessor(w, d, zpixels);
//if (y==h/2) new ImagePlus("before-"+h/2, fp.duplicate()).show();
gb.blur1Direction(fp, sigmaZ, accuracy, false, 0);
stack.setVoxels(0, y, 0, w, 1, d, zpixels, channel);
}
}
IJ.showStatus("");
}
代码示例来源:origin: imagej/ImageJA
/** Since most computing time is spent in GaussianBlur, forward the
* information about the number of passes to Gaussian Blur. The
* ProgressBar will be handled by GaussianBlur. */
public void setNPasses(int nPasses) {
if (gb == null) gb = new GaussianBlur();
gb.setNPasses(nPasses);
}
}
内容来源于网络,如有侵权,请联系作者删除!