本文整理匯總了Java中ij.process.ImageProcessor類的典型用法代碼示例。如果您正苦於以下問題:Java ImageProcessor類的具體用法?Java ImageProcessor怎麽用?Java ImageProcessor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ImageProcessor類屬於ij.process包,在下文中一共展示了ImageProcessor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getmaxpositions
import ij.process.ImageProcessor; //導入依賴的package包/類
/** Gets x and y coordinates of maximum intensity pixel on image. */
int [] getmaxpositions(ImageProcessor ipp)
{
int [] results = new int [2];
results[0]=0;
results[1]=0;
double s;
double smax=Double.MIN_VALUE;
for (int i=0;i<ipp.getWidth();i++)
{
for (int j=0;j<ipp.getHeight();j++)
{
s=ipp.get(i, j);
if (s>smax)
{
smax=s;
results[0]=i;
results[1]=j;
}
}
}
return results;
}
示例2: pad
import ij.process.ImageProcessor; //導入依賴的package包/類
/**
* some parts from ij.plugin.FFT code
*
* */
ImageProcessor pad(ImageProcessor ip)
{
int originalWidth = ip.getWidth();
int originalHeight = ip.getHeight();
int maxN = Math.max(originalWidth, originalHeight);
int i = 2;
while(i<maxN) i *= 2;
if (i==maxN && originalWidth==originalHeight)
{
return ip;
}
maxN = i;
ImageStatistics stats = ImageStatistics.getStatistics(ip, ImageStatistics.MEAN, null);
ImageProcessor ip2 = ip.createProcessor(maxN, maxN);
ip2.setValue(stats.mean);
ip2.fill();
ip2.insert(ip, 0, 0);
Undo.reset();
//new ImagePlus("padded", ip2.duplicate()).show();
return ip2;
}
示例3: padzeros
import ij.process.ImageProcessor; //導入依賴的package包/類
ImageProcessor padzeros(ImageProcessor ip)
{
int originalWidth = ip.getWidth();
int originalHeight = ip.getHeight();
int maxN = Math.max(originalWidth, originalHeight);
int i = 2;
while(i<maxN) i *= 2;
if (i==maxN && originalWidth==originalHeight)
{
return ip;
}
maxN = i;
ImageProcessor ip2 = ip.createProcessor(maxN, maxN);
ip2.setValue(0);
ip2.fill();
ip2.insert(ip, 0, 0);
Undo.reset();
//new ImagePlus("padded", ip2.duplicate()).show();
return ip2;
}
示例4: showFilter
import ij.process.ImageProcessor; //導入依賴的package包/類
public void showFilter(int[][] filter, String title){
int w = filter[0].length;
int h = filter.length;
ImageProcessor ip = new ByteProcessor(w,h);
for (int v = 0; v < h; v++) {
for (int u = 0; u < w; u++) {
if (filter[v][u] == 1)
ip.putPixel(u, v, 255);
else
ip.putPixel(u, v, 0);
}
}
ip.invertLut();
ImagePlus win = new ImagePlus(title,ip);
win.show();
}
示例5: copyResultToImage
import ij.process.ImageProcessor; //導入依賴的package包/類
void copyResultToImage(ImageProcessor ip) {
final int[] pixel = new int[K];
if (ip instanceof ColorProcessor) {
for (int u = 0; u < M; u++) {
for (int v = 0; v < N; v++) {
for (int k = 0; k < K; k++) {
int c = params.useLinearRgb ?
Math.round(rgbToSrgb(I[k][u][v])) :
Math.round(I[k][u][v]);
if (c < 0) c = 0;
if (c > 255) c = 255;
pixel[k] = c;
}
ip.putPixel(u,v,pixel);
}
}
}
else { // 8-bit, 16-bit or 32-bit (float) processor
for (int u = 0; u < M; u++) {
for (int v = 0; v < N; v++) {
ip.setf(u, v, I[0][u][v]);
}
}
}
}
示例6: applyTo
import ij.process.ImageProcessor; //導入依賴的package包/類
public void applyTo(ImageProcessor ip) {
M = ip.getWidth();
N = ip.getHeight();
FilterOperator fm = null;
if (ip instanceof ColorProcessor) {
switch (params.colorMode) {
case SeparateChannels : fm = new FilterColorSeparate(); break;
case BrightnessGradient : fm = new FilterColorBrightnessGradient(); break;
case ColorGradient : fm = new FilterColorColorGradient(); break;
}
}
else {
fm = new FilterScalar();
}
fm.filter(ip);
}
示例7: filter
import ij.process.ImageProcessor; //導入依賴的package包/類
public void filter(ImageProcessor ip) {
// create temporary data structures
I = ip.getFloatArray();
Dx = new float[M][N];
Dy = new float[M][N];
if (params.useLinearRgb) srgbToRgb(I);
// perform actual filter operation
for (int n = 1; n <= T; n++) {
IJ.showProgress(n, T);
iterateOnce();
}
if (params.useLinearRgb) rgbToSrgb(I);
copyResultToImage(I, ip);
I = null;
Dx = null;
Dy = null;
}
示例8: copyResultToImage
import ij.process.ImageProcessor; //導入依賴的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]));
}
}
}
}
示例9: makeDerivatives
import ij.process.ImageProcessor; //導入依賴的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
}
示例10: process
import ij.process.ImageProcessor; //導入依賴的package包/類
private void process(ImageProcessor ip) {
ByteProcessor check = new ByteProcessor(M, N);
if (params.showProgress) IJ.showStatus("filling accumulator ...");
for (int v = 0; v < N; v++) {
if (params.showProgress) IJ.showProgress(v, N);
for (int u = 0; u < M; u++) {
if ((0xFFFFFF & ip.get(u, v)) != 0) { // this is a foreground (edge) pixel - use ImageAccessor??
doOnePoint(u, v);
check.putPixel(u, v, 128);
}
}
}
if (params.showProgress)
IJ.showProgress(1, 1);
if (params.showCheckImage)
(new ImagePlus("Check", check)).show();
}
示例11: process
import ij.process.ImageProcessor; //導入依賴的package包/類
private void process(ImageProcessor ip) {
// ByteProcessor check = new ByteProcessor(M, N);
if (params.showProgress) IJ.showStatus("filling accumulator ...");
for (int v = 0; v < N; v++) {
if (params.showProgress) IJ.showProgress(v, N);
for (int u = 0; u < M; u++) {
if ((0xFFFFFF & ip.get(u, v)) != 0) { // this is a foreground (edge) pixel - use ImageAccessor??
processPoint(u, v);
// check.putPixel(u, v, 128);
}
}
}
if (params.showProgress)
IJ.showProgress(1, 1);
// if (params.showCheckImage)
// (new ImagePlus("Check", check)).show();
}
示例12: draw
import ij.process.ImageProcessor; //導入依賴的package包/類
/**
* This is a brute-force drawing method which simply marks all
* image pixels that are sufficiently close to the HoughLine hl.
* The drawing color for ip must be previously set.
* @param ip The ImageProcessor to draw to.
* @param thickness The thickness of the lines to be drawn.
*/
public void draw(ImageProcessor ip, double thickness) {
final int w = ip.getWidth();
final int h = ip.getHeight();
final double dmax = 0.5 * thickness;
for (int u = 0; u < w; u++) {
for (int v = 0; v < h; v++) {
// get the distance between (u,v) and the line hl:
double d = Math.abs(this.getDistance(u, v));
if (d <= dmax) {
ip.drawPixel(u, v);
}
}
}
}
示例13: makeGradientsAndMagnitudeGray
import ij.process.ImageProcessor; //導入依賴的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);
}
示例14: drawOneKey
import ij.process.ImageProcessor; //導入依賴的package包/類
void drawOneKey(SiftKeypoint key, ImageProcessor ip) {
double x = (int) Math.rint(key.x);
double y = (int) Math.rint(key.y);
int u0 = (int) x;
int v0 = (int) y;
double phi = key.orientation;
double scale = key.scale;
double dx = magnification * scale * Math.cos(phi);
double dy = magnification * scale * Math.sin(phi); // NOTE: angle runs reversed
int u1 = (int) Math.rint(x + dx);
int v1 = (int) Math.rint(y + dy);
ip.setColor(boxColor);
ip.drawRect(u0-1, v0-1, 3, 3);
ip.setColor(lineColor);
ip.drawLine(u0,v0,u1,v1);
}
示例15: brightLut
import ij.process.ImageProcessor; //導入依賴的package包/類
/**
* Modifies the lookup table to display a bright image with gray values
* in the range minGray ... 255. Does nothing if ip is of type
* ColorProcessor.
*
* @param ip The target image.
* @param minGray Minimum gray value.
*/
public static void brightLut(ImageProcessor ip, int minGray) {
if (minGray < 0 || minGray >= 255)
return;
ColorModel cm = ip.getColorModel();
if (!(cm instanceof IndexColorModel))
return;
IndexColorModel icm = (IndexColorModel) cm;
int mapSize = icm.getMapSize();
byte[] reds = new byte[mapSize];
byte[] grns = new byte[mapSize];
byte[] blus = new byte[mapSize];
float scale = (255 - minGray) / 255f;
for (int i = 0; i < mapSize; i++) {
byte g = (byte) (Math.round(minGray + scale * i) & 0xFF);
reds[i] = g;
grns[i] = g;
blus[i] = g;
}
ip.setColorModel(new IndexColorModel(8, mapSize, reds, grns, blus));
}