本文整理汇总了Java中ij.process.FloatProcessor.getRoi方法的典型用法代码示例。如果您正苦于以下问题:Java FloatProcessor.getRoi方法的具体用法?Java FloatProcessor.getRoi怎么用?Java FloatProcessor.getRoi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.FloatProcessor
的用法示例。
在下文中一共展示了FloatProcessor.getRoi方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PixelIterator
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public PixelIterator(final FloatProcessor fp) {
final Rectangle roi = fp.getRoi();
width = fp.getWidth();
pixels = (float[]) fp.getPixels();
xMin = roi.x + 1;
xMax = roi.x + roi.width - 2;
yMin = roi.y + 1;
yMax = roi.y + roi.height - 2;
rowOffset = width;
rewind();
}
示例2: sharpenFloat
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/**
* Dynamic Density Optimization of a float image. 'fp' must have a valid snapshot.
* Almost identical to sharpenFloat in UnsharpMask.java from ImageJ.
* Unsharp mask is added instead of subtracted as the filter is applied in log domain.
*
* @param fp the Processor to be masked
* @param sigma the standard deviation
* @param weight the weight of the mask [0,1]
*/
public void sharpenFloat(FloatProcessor fp, double sigma, float weight) {
GaussianBlur gb = new GaussianBlur();
gb.blurGaussian(fp, sigma, sigma, 0.01);
if (Thread.currentThread().isInterrupted()) return;
float[] pixels = (float[])fp.getPixels();
float[] snapshotPixels = (float[])fp.getSnapshotPixels();
int width = fp.getWidth();
Rectangle roi = fp.getRoi();
for (int y=roi.y; y<roi.y+roi.height; y++)
for (int x=roi.x, p=width*y+x; x<roi.x+roi.width; x++,p++)
pixels[p] = (snapshotPixels[p] + weight*pixels[p])/(1f - weight);
}
示例3: convolveFloat1D
import ij.process.FloatProcessor; //导入方法依赖的package包/类
/** Convolves the image <code>ip</code> with a kernel of width
<code>kw</code> and height <code>kh</code>. */
public void convolveFloat1D(FloatProcessor ip, float[] kernel, int kw, int kh, double scale) {
int width = ip.getWidth();
int height = ip.getHeight();
Rectangle r = ip.getRoi();
int x1 = r.x;
int y1 = r.y;
int x2 = x1 + r.width;
int y2 = y1 + r.height;
int uc = kw/2;
int vc = kh/2;
float[] pixels = (float[])ip.getPixels();
float[] pixels2 = (float[])ip.getSnapshotPixels();
if (pixels2==null)
pixels2 = (float[])ip.getPixelsCopy();
boolean vertical = kw==1;
double sum;
int offset, i;
boolean edgePixel;
int xedge = width-uc;
int yedge = height-vc;
for(int y=y1; y<y2; y++) {
for(int x=x1; x<x2; x++) {
sum = 0.0;
i = 0;
if (vertical) {
edgePixel = y<vc || y>=yedge;
offset = x+(y-vc)*width;
for(int v=-vc; v<=vc; v++) {
if (edgePixel)
sum += getPixel(x+uc, y+v, pixels2, width, height)*kernel[i++];
else
sum += pixels2[offset+uc]*kernel[i++];
offset += width;
}
} else {
edgePixel = x<uc || x>=xedge;
offset = x+(y-vc)*width;
for(int u = -uc; u<=uc; u++) {
if (edgePixel)
sum += getPixel(x+u, y+vc, pixels2, width, height)*kernel[i++];
else
sum += pixels2[offset+u]*kernel[i++];
}
}
pixels[x+y*width] = (float)(sum*scale);
}
}
}
示例4: run
import ij.process.FloatProcessor; //导入方法依赖的package包/类
public FloatProcessor run(final FloatProcessor src) {
final int width = src.getWidth();
final FloatProcessor dest = (FloatProcessor) src.duplicate();
final float[] srcPixels = (float[]) src.getPixels();
final float[] destPixels = (float[]) dest.getPixels();
final int xr = filterWidth / 2;
final int yr = filterHeight / 2;
final Rectangle roi = src.getRoi();
final int xMin = roi.x;
final int xMax = roi.x + roi.width;
final int yMin = roi.y;
final int yMax = roi.y + roi.height;
// Calculate increment, make sure that different/larger than 0 otherwise '%' operation will fail.
final int progressIncrement = Math.max((yMax - yMin) / 100, 1);
final float[] packet = new float[filterHeight];
for (int y = yMin; y < yMax; ++y) {
final int yOffset = y * width;
// Initialize median operator, with all but the last column in the structural key
operator.clear();
final int yyMin = Math.max(y - yr, yMin);
final int yyMax = Math.min(y + yr, yMax);
final int xxMin = xMin;
final int xxMax = Math.min(xMin + xr, xMax);
for (int xx = xxMin; xx < xxMax; ++xx) {
for (int yy = yyMin; yy < yyMax; ++yy) {
packet[yy - yyMin] = srcPixels[xx + yy * width];
}
operator.push(yyMax - yyMin, packet);
}
for (int x = xMin; x < xMax; ++x) {
if (x + xr < xMax) {
for (int yy = yyMin; yy < yyMax; ++yy) {
packet[yy - yyMin] = srcPixels[x + xr + yy * width];
}
operator.push(yyMax - yyMin, packet);
}
destPixels[x + yOffset] = operator.evaluate();
}
if (y % progressIncrement == 0) {
showProgress((double) (y - yMin) / (yMax - yMin));
}
}
hideProgress();
return dest;
}