当前位置: 首页>>代码示例>>Java>>正文


Java FloatProcessor类代码示例

本文整理汇总了Java中ij.process.FloatProcessor的典型用法代码示例。如果您正苦于以下问题:Java FloatProcessor类的具体用法?Java FloatProcessor怎么用?Java FloatProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FloatProcessor类属于ij.process包,在下文中一共展示了FloatProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: c2c2DFFT

import ij.process.FloatProcessor; //导入依赖的package包/类
/** Complex to Complex Inverse Fourier Transform
*   @author Joachim Wesner
*/
void c2c2DFFT(float[] rein, float[] imin, int maxN, float[] reout, float[] imout) 
{
        FHT fht = new FHT(new FloatProcessor(maxN,maxN));
        float[] fhtpixels = (float[])fht.getPixels();
        // Real part of inverse transform
        for (int iy = 0; iy < maxN; iy++)
              cplxFHT(iy, maxN, rein, imin, false, fhtpixels);
        fht.inverseTransform();
        // Save intermediate result, so we can do a "in-place" transform
        float[] hlp = new float[maxN*maxN];
        System.arraycopy(fhtpixels, 0, hlp, 0, maxN*maxN);
        // Imaginary part of inverse transform
        for (int iy = 0; iy < maxN; iy++)
              cplxFHT(iy, maxN, rein, imin, true, fhtpixels);
        fht.inverseTransform();
        System.arraycopy(hlp, 0, reout, 0, maxN*maxN);
        System.arraycopy(fhtpixels, 0, imout, 0, maxN*maxN);
  }
 
开发者ID:ekatrukha,项目名称:Correlescence,代码行数:22,代码来源:ImCrossCorrelation.java

示例2: 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));
		}
	}
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:26,代码来源:NiblackThresholder.java

示例3: copyResultToImage

import ij.process.FloatProcessor; //导入依赖的package包/类
private void copyResultToImage(float[][] imgData, ImageProcessor ip) {
	if (ip instanceof FloatProcessor) {
		FloatProcessor cp = (FloatProcessor) ip;
		for (int v = 0; v < N; v++) {
			for (int u = 0; u < M; u++) {
				cp.putPixelValue(u, v, imgData[u][v]);
			}
		}
	}
	else {
		for (int v = 0; v < N; v++) {
			for (int u = 0; u < M; u++) {
				ip.putPixel(u, v, (int) Math.round(imgData[u][v]));
			}
		}
	}
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:18,代码来源:PeronaMalikFilter.java

示例4: makeDerivatives

import ij.process.FloatProcessor; //导入依赖的package包/类
private void makeDerivatives(ImageProcessor I) {
	FloatProcessor Ix = I.convertToFloatProcessor(); 
	FloatProcessor Iy = I.convertToFloatProcessor();
	
	Filter.convolveX(Ix, hp);				// pre-filter Ix horizontally
	Filter.convolveX(Ix, hd);				// get horizontal derivative 
	
	Filter.convolveY(Iy, hp);				// pre-filter Iy vertically
	Filter.convolveY(Iy, hd);				// get vertical derivative
	
	A = ImageMath.sqr(Ix);					// A <- Ix^2
	B = ImageMath.sqr(Iy);					// B <- Iy^2
	C = ImageMath.mult(Ix, Iy);				// C <- Ix * Iy
	
	Filter.convolveXY(A, hb);				// blur A in x/y
	Filter.convolveXY(B, hb);				// blur B in x/y
	Filter.convolveXY(C, hb);				// blur C in x/y
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:19,代码来源:HarrisCornerDetector.java

示例5: isLocalMax

import ij.process.FloatProcessor; //导入依赖的package包/类
private boolean isLocalMax (FloatProcessor Q, int u, int v) {
	if (u <= 0 || u >= M - 1 || v <= 0 || v >= N - 1) {
		return false;
	} 
	else {
		final float[] q = (float[]) Q.getPixels();
		final int i0 = (v - 1) * M + u;
		final int i1 = v * M + u;
		final int i2 = (v + 1) * M + u;
		final float q0 = q[i1];
		return	// check 8 neighbors of q0
			q0 >= q[i0 - 1] && q0 >= q[i0] && q0 >= q[i0 + 1] &&
			q0 >= q[i1 - 1] &&                q0 >= q[i1 + 1] && 
			q0 >= q[i2 - 1] && q0 >= q[i2] && q0 >= q[i2 + 1] ;
	}
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:17,代码来源:HarrisCornerDetector.java

示例6: 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);
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:36,代码来源:CannyEdgeDetector.java

示例7: rgbToFloatChannels

import ij.process.FloatProcessor; //导入依赖的package包/类
private FloatProcessor[] rgbToFloatChannels(ColorProcessor cp) {
	int w = cp.getWidth();
	int h = cp.getHeight();
	FloatProcessor rp = new FloatProcessor(w, h);
	FloatProcessor gp = new FloatProcessor(w, h);
	FloatProcessor bp = new FloatProcessor(w, h);
	int[] pixels = (int[]) cp.getPixels(); 
	float[] rpix = (float[]) rp.getPixels();
	float[] gpix = (float[]) gp.getPixels();
	float[] bpix = (float[]) bp.getPixels();
   	for (int i=0; i<pixels.length; i++) {
           int c = pixels[i];
           rpix[i] = (c&0xff0000)>>16;
   		gpix[i] = (c&0xff00)>>8;
		bpix[i] =  c&0xff;
   	}
   	return new FloatProcessor[] {rp, gp, bp};
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:19,代码来源:CannyEdgeDetector.java

示例8: 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;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:17,代码来源:Statistics.java

示例9: 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;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:20,代码来源:Statistics.java

示例10: makeBoundsHeatmap

import ij.process.FloatProcessor; //导入依赖的package包/类
private BufferedImage makeBoundsHeatmap() {
    long time = 0;
    ImagePlus imp;
    Rectangle rect;
    FloatProcessor ip = new FloatProcessor(viewer.getThumbnail().getWidth(), viewer.getThumbnail().getHeight());
    Rectangle[] boundsArray = trackerFeatures.getBoundsArray();
    for (int i = 0; i < boundsArray.length; i++) {
        progressBarFrame.setCurrentFrame(i);
        setProgress((int) ((double) (i * 100) / (double) totalTasks));
        if (boundsArray[i] != null) {
            time = trackerFeatures.getTracker().getFrame(i).getTimestamp() - time;

            rect = rescaleRectangle(boundsArray[i], scalex, scaley);

            fillRectangle(rect, ip, time);
        }
    }
    imp = new ImagePlus("Bounds heatmap", ip);
    IJ.run(imp, "Fire", "");
    return imp.getBufferedImage();
}
 
开发者ID:Alanocallaghan,项目名称:qupath-tracking-extension,代码行数:22,代码来源:HeatmapOverlay.java

示例11: showMasks

import ij.process.FloatProcessor; //导入依赖的package包/类
void showMasks() {
	int w=150, h=150;
	ImageStack stack = new ImageStack(w, h);
	//for (double r=0.1; r<3; r+=0.01) {
	for (double r=0.5; r<50; r+=0.5) {
		ImageProcessor ip = new FloatProcessor(w,h,new int[w*h]);
		float[] pixels = (float[])ip.getPixels();
		int[] lineRadii = makeLineRadii(r);
		int kHeight = kHeight(lineRadii);
		int kRadius = kRadius(lineRadii);
		int y0 = h/2-kHeight/2;
		for (int i = 0, y = y0; i<kHeight; i++, y++)
			for (int x = w/2+lineRadii[2*i], p = x+y*w; x <= w/2+lineRadii[2*i+1]; x++, p++)
				pixels[p] = 1f;
		stack.addSlice("radius="+r+", size="+(2*kRadius+1), ip);
	}
	new ImagePlus("Masks", stack).show();
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:19,代码来源:RankFiltersOrbit.java

示例12: applyStackManifold

import ij.process.FloatProcessor; //导入依赖的package包/类
public ImagePlus applyStackManifold(ImageStack imStack, ImagePlus manifold){
    int dimW            =   imStack.getWidth();
    int dimH            =   imStack.getHeight();

    RealMatrix projMnold    = MatrixUtils.createRealMatrix(SME_ENS_Utils.convertFloatMatrixToDoubles(manifold.getProcessor().getFloatArray(),dimW,dimH)).transpose();

    for(int j=0;j<dimH;j++){
        for(int i=0;i<dimW;i++){
            int zIndex = ((int) Math.round(stackSize*(projMnold.getEntry(j,i)/255)));
            projMnold.setEntry (j,i,imStack.getVoxel(i,j,zIndex-1));
        }
    }

    float[][] mfoldFlaot = SME_ENS_Utils.convertDoubleMatrixToFloat(projMnold.transpose().getData(),dimW,dimH);
    ImagePlus smeManifold = new ImagePlus("",((ImageProcessor) new FloatProcessor(mfoldFlaot)));

    return(smeManifold);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:19,代码来源:SME_Plugin_Simple.java

示例13: convolve

import ij.process.FloatProcessor; //导入依赖的package包/类
/** Convolves <code>ip</code> with a kernel of width <code>kw</code> and
	height <code>kh</code>. Returns false if the user cancels the operation. */
public boolean convolve(ImageProcessor ip, float[] kernel, int kw, int kh) {
	if (canceled || kw*kh!=kernel.length) return false;
	if ((kw&1)!=1 || (kh&1)!=1)
		throw new IllegalArgumentException("Kernel width or height not odd ("+kw+"x"+kh+")");
	boolean notFloat = !(ip instanceof FloatProcessor);
	ImageProcessor ip2 = ip;
	if (notFloat) {
		if (ip2 instanceof ColorProcessor) 
			throw new IllegalArgumentException("RGB images not supported");
		ip2 = ip2.convertToFloat();
	}
	if (kw==1 || kh==1)
		convolveFloat1D((FloatProcessor)ip2, kernel, kw, kh, normalize?getScale(kernel):1.0);
	else
		convolveFloat(ip2, kernel, kw, kh);
	if (notFloat) {
		if (ip instanceof ByteProcessor)
			ip2 = ip2.convertToByte(false);
		else
			ip2 = ip2.convertToShort(false);
		ip.setPixels(ip2.getPixels());
	}
	return !canceled;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:SME_ENS_Convolver.java

示例14: repmatMatrixVar

import ij.process.FloatProcessor; //导入依赖的package包/类
public static ImageStack repmatMatrixVar(RealMatrix inMatrix, ImageStack base){
    //varold2=sum((base-repmat(Mold,[1 1 8])).^2,3);
    final int DIMZ              = 8;
    int nrowsMat                = inMatrix.getRowDimension();
    int ncolsMat                = inMatrix.getColumnDimension();
    ImageStack baseMatrix       = new ImageStack(ncolsMat,nrowsMat);

    for(int inz=0;inz<DIMZ;inz++){
            RealMatrix currentSlice = MatrixUtils.createRealMatrix(
                    convertFloatMatrixToDoubles(base.getProcessor(inz+1).getFloatArray(),
                            ncolsMat,nrowsMat));
            currentSlice = currentSlice.transpose();

            RealMatrix tmpSlice =   currentSlice.subtract(inMatrix);
            tmpSlice            =   realmatrixDoublepow(tmpSlice,2);
            tmpSlice            =   tmpSlice.transpose();

            baseMatrix.addSlice((ImageProcessor) new FloatProcessor(
                    SME_ENS_Utils.convertDoubleMatrixToFloat(
                            tmpSlice.getData(),ncolsMat,nrowsMat
                    )));
    }

    return(baseMatrix);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:SME_ENS_Utils.java

示例15: getRayFunction

import ij.process.FloatProcessor; //导入依赖的package包/类
private SME_ENS_Projection_Function getRayFunction(int method, FloatProcessor fp) {
    switch (method) {
        case AVG_METHOD:
            return new SME_ENS_ENS_Projection_Average_Intensity(fp, sliceCount);
        case MAX_METHOD:
            return new SME_ENS_Projection_Max_Intensity(fp);
        case SUM_METHOD:
            return new SME_ENS_Projection_Sum_Intensity(fp);
        case MEDIAN_METHOD:
            return new SME_ENS_Projection_Median_Intensity(fp);
        case MIN_METHOD:
            return new SME_ENS_Projection_Min_Intensity(fp);
        case SD_METHOD:
            return new SME_ENS_Projection_STD_Intensity(fp, sliceCount);
        default:
            IJ.error("Z Project", "Unknown method.");
            return null;
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:20,代码来源:SME_ENS_Image_Prepare.java


注:本文中的ij.process.FloatProcessor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。