本文整理汇总了Java中ij.process.FloatProcessor.getPixelValue方法的典型用法代码示例。如果您正苦于以下问题:Java FloatProcessor.getPixelValue方法的具体用法?Java FloatProcessor.getPixelValue怎么用?Java FloatProcessor.getPixelValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.FloatProcessor
的用法示例。
在下文中一共展示了FloatProcessor.getPixelValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyToolToImage
import ij.process.FloatProcessor; //导入方法依赖的package包/类
@Override
public Grid2D applyToolToImage(Grid2D imageProcessor)
throws Exception {
FloatProcessor revan = new FloatProcessor(imageProcessor.getWidth(), imageProcessor.getHeight(), imageProcessor.getBuffer());
revan.setInterpolationMethod(ImageProcessor.BICUBIC);
for(int y = 0; y < revan.getHeight(); y++){
for(int x = 0; x < revan.getWidth();x++){
if(Double.isNaN(revan.getPixelValue(x, y))){
revan.putPixelValue(x, y, 0);
revan.putPixelValue(x, y, revan.getInterpolatedPixel(x, y));
}
if (operation.equals(MIN) && revan.getPixelValue(x, y)< threshold) {
revan.putPixelValue(x, y, threshold);
}
else if (operation.equals(MAX) && revan.getPixelValue(x, y)>threshold) {
revan.putPixelValue(x, y, threshold);
}
}
}
Grid2D out = new Grid2D((float[])revan.getPixels(), revan.getWidth(), revan.getHeight());
out.setOrigin(imageProcessor.getOrigin());
out.setSpacing(imageProcessor.getSpacing());
return out;
}
示例2: GetMeanofDownSampledModFun
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
*
* @param fp the downsampled modulation function
* @return the mean value of the modulation function
*/
private double GetMeanofDownSampledModFun(FloatProcessor fp){
if(dsModFunMean!=0)
return dsModFunMean;
if(fp==null) {
dsModFunMean = 0;
return 0;
}
int nDsW = fp.getWidth();
int nDsH = fp.getHeight();
double dMean = 0;
for (int i=0;i<nDsH;i++){
for (int j=0;j<nDsW;j++){
dMean += fp.getPixelValue(j, i);
}
}
dsModFunMean = dMean/(nDsW*nDsH);
return dsModFunMean;
}
示例3: 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);
}
}
示例4: computeUVDerivative
import ij.process.FloatProcessor; //导入方法依赖的package包/类
private Grid2D computeUVDerivative(int index){
float [] kernel = {-1, 0, 1};
ImageProcessor revan = new FloatProcessor(inputQueue.get(index).getWidth(), inputQueue.get(index).getHeight());
// derivative in row direction
FloatProcessor uDev = new FloatProcessor(revan.getWidth(), revan.getHeight());
System.arraycopy(inputQueue.get(index).getBuffer(), 0, (float[]) uDev.getPixels(), 0, inputQueue.get(index).getBuffer().length);
uDev.convolve(kernel, 3, 1);
// derivative in column direction
ImageProcessor vDev = new FloatProcessor(revan.getWidth(), revan.getHeight());
System.arraycopy(inputQueue.get(index).getBuffer(), 0, (float[]) vDev.getPixels(), 0, inputQueue.get(index).getBuffer().length);
vDev.convolve(kernel, 1, 3);
// weight and add to result.
for(int i =0; i<uDev.getWidth(); i++){
for (int j=0; j< uDev.getHeight(); j++){
double u = uDev.getPixelValue(i, j);
u /= detectorElementSizeX * 2;
u *= uWeights[i];
uDev.putPixelValue(i, j, u);
double v = vDev.getPixelValue(i, j);
v *= vWeights[i][j];
v /= detectorElementSizeY * 2;
revan.putPixelValue(i, j, v+u);
}
}
//if (index == 1) VisualizationUtil.showImageProcessor(revan);
return new Grid2D((float[])revan.getPixels(), revan.getWidth(), revan.getHeight());
}
示例5: getFloatArray
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* convert FloatProcessor to 2D Aray
* @param fp the FloatProcessor to convert
* @return the 2D array
*/
private float[][] getFloatArray(FloatProcessor fp)
{
int W = fp.getWidth();
int H = fp.getHeight();
float[][] f = new float[H][W];
for (int j=0;j<H;j++){
for(int i=0;i<W;i++){
f[j][i] = fp.getPixelValue(i, j);
}
}
return f;
}
示例6: GetScatterDistributionSMI
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Estimate scatter from the primary-modulated image
* @param ip the primary-modulated image
* @return scatter distribution
*/
private ImageProcessor GetScatterDistributionSMI(ImageProcessor ip)
{
if (modulationFunction==null || alphaDist==null)
return null;
int nW = modulationFunction.getWidth();
int nH = modulationFunction.getHeight();
//smooth the primary-modulated image
MeanFilteringTool mean = new MeanFilteringTool();
mean.configure(meanfilterLen, meanfilterLen);
//downsample projection
dsModFun = (FloatProcessor)downsampleProjection(
ImageUtil.wrapGrid2D(
mean.applyToolToImage(ImageUtil.wrapImageProcessor(modulationFunction.getProcessor())))
);
double dMean = GetMeanofDownSampledModFun(dsModFun);
//refine modulation function
dsModFun.add(-dMean*gaincutfactor);
FloatProcessor dsIp = (FloatProcessor)downsampleProjection(
ImageUtil.wrapGrid2D(mean.applyToolToImage(ImageUtil.wrapImageProcessor(ip))));
int nDsW = dsModFun.getWidth();
int nDsH = dsModFun.getHeight();
double val = 0;
for(int i=0;i<nDsH;i++){
for (int j=0;j<nDsW;j++){
val = dsIp.getPixelValue(j, i)/dsModFun.getPixelValue(j, i);
dsIp.putPixelValue(j, i, val);
}
}
int nZW = max(128,(int) Math.pow(2, nextPower2(nDsW)));
int nZH = max(128,(int) Math.pow(2, nextPower2(nDsH)));
//padding image for FFT
float[][] dsAP = AlternatePadding(getFloatArray(dsIp),nZW,nZH);
//create low-pass filter and the corresponding high-pass filter
float [][] LowPassFilter = Hamming(nZW,nZH,lowPassFilterWidth,lowPassFilterHeight);
float [][] HighPassFilter = FFTUtil.fftshift(LowPassFilter, false, true);
float [][] LowPassImage = new float[nZH][nZW];
float [][] HighPassImage = new float[nZH][nZW];
//Get low and high frequency image
FFTUtil.GetLowandHighPassImage(dsAP,LowPassFilter,HighPassFilter,LowPassImage,HighPassImage);
//LowPassImage = AlternatePaddingInverse(LowPassImage,nDsW,nDsH);
HighPassImage = AlternatePaddingInverse(HighPassImage,nDsW,nDsH);
//FloatProcessor fPLowPassImage = (FloatProcessor) upsampleProjection(Array2FloatProcessor(LowPassImage));
FloatProcessor fPHighPassImage = (FloatProcessor) upsampleProjection(Array2FloatProcessor(HighPassImage));
// get scatter distribution
double dAlpha=0;
double dVal = 0;
FloatProcessor fSc = new FloatProcessor(nW,nH);
for (int i=0;i<nH;i++){
for (int j=0;j<nW;j++){
dAlpha = alphaDist.getPixelValue(j, i);
dVal = 4 * scatterEstScale * dAlpha/(1-dAlpha*dAlpha) * dMean * fPHighPassImage.getPixelValue(j, i);
fSc.putPixelValue(j, i, dVal);
}
}
return fSc;
}