本文整理汇总了Java中ij.process.ByteProcessor.getPixels方法的典型用法代码示例。如果您正苦于以下问题:Java ByteProcessor.getPixels方法的具体用法?Java ByteProcessor.getPixels怎么用?Java ByteProcessor.getPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.ByteProcessor
的用法示例。
在下文中一共展示了ByteProcessor.getPixels方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public void filter(ImageProcessor ip) {
ColorProcessor I = (ColorProcessor) ip;
// extract color channels as individual ByteProcessor images:
ByteProcessor Ir = new ByteProcessor(M, N);
ByteProcessor Ig = new ByteProcessor(M, N);
ByteProcessor Ib = new ByteProcessor(M, N);
byte[] pR = (byte[]) Ir.getPixels();
byte[] pG = (byte[]) Ig.getPixels();
byte[] pB = (byte[]) Ib.getPixels();
I.getRGB(pR, pG, pB);
FilterScalar fm = new FilterScalar();
fm.filter(Ir);
fm.filter(Ig);
fm.filter(Ib);
// copy back to color image
I.setRGB(pR, pG, pB);
}
示例2: Rgb
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public Rgb(ColorProcessor ip, OutOfBoundsStrategy obs, InterpolationMethod ipm) {
super(ip, obs, ipm);
this.ip = ip;
this.pixels = (int[]) this.ip.getPixels();
int width = ip.getWidth();
int height = ip.getHeight();
ByteProcessor rp = new ByteProcessor(width, height);
ByteProcessor gp = new ByteProcessor(width, height);
ByteProcessor bp = new ByteProcessor(width, height);
byte[] rpix = (byte[]) rp.getPixels();
byte[] gpix = (byte[]) gp.getPixels();
byte[] bpix = (byte[]) bp.getPixels();
ip.getRGB(rpix, gpix, bpix); // fill byte arrays
rAcc = new ImageAccessor.Byte(rp, obs, ipm);
gAcc = new ImageAccessor.Byte(gp, obs, ipm);
bAcc = new ImageAccessor.Byte(bp, obs, ipm);
}
示例3: splitRGB
import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
* Splits ColorProcessor into ByteProcessors representing each of three bands (red, green, and blue).
*
* @param cp input color processor
* @return ByteProcessor for each band.
* @see #mergeRGB(ij.process.ByteProcessor[])
*/
public static ByteProcessor[] splitRGB(final ColorProcessor cp) {
Validate.argumentNotNull(cp, "cp");
final int width = cp.getWidth();
final int height = cp.getHeight();
final ByteProcessor redBp = new ByteProcessor(width, height);
final ByteProcessor greenBp = new ByteProcessor(width, height);
final ByteProcessor blueBp = new ByteProcessor(width, height);
final byte[] redPixels = (byte[]) redBp.getPixels();
final byte[] greenPixels = (byte[]) greenBp.getPixels();
final byte[] bluePixels = (byte[]) blueBp.getPixels();
cp.getRGB(redPixels, greenPixels, bluePixels);
return new ByteProcessor[]{redBp, greenBp, blueBp};
}
示例4: fillOutside
import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
* Fill in a region outside a specified ROI
* @param ip
* @param roi
*/
public static void fillOutside(ImageProcessor ip, Roi roi, double value) {
// Check we don't have a full rectangle
if (roi.getType() == Roi.RECTANGLE && roi.getBounds().equals(new Rectangle(0, 0, ip.getWidth(), ip.getHeight())))
return;
// if (roi instanceof ShapeRoi) {
// Appears to be a bug with ShapeRois so that filling outside can fail using ImageJ's own code
ByteProcessor bpMask = new ByteProcessor(ip.getWidth(), ip.getHeight());
bpMask.setValue(1);
bpMask.fill(roi);
if (value == 0)
ip.copyBits(bpMask, 0, 0, Blitter.MULTIPLY);
else {
float floatValue = (float)value;
byte[] px = (byte[])bpMask.getPixels();
for (int i = 0; i < px.length; i++) {
if (px[i] == (byte)0)
ip.setf(i, floatValue);
}
}
// } else {
// ip.setValue(value);
// ip.fillOutside(roi);
// }
}
示例5: toShape
import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
* Convert ImageJ's Roi to Java 3D Shape representation.
*
* @param roi source roi.
* @return translated to Shape.
*/
public static Shape toShape(final Roi roi) {
final Shape result;
if (roi instanceof PointRoi) {
final ByteProcessor mask = (ByteProcessor) roi.getMask();
final byte[] maskPixels = (byte[]) mask.getPixels();
final Rectangle maskBounds = roi.getBounds();
final int maskWidth = mask.getWidth();
final int maskHeight = mask.getHeight();
final Area area = new Area();
for (int y = 0; y < maskHeight; y++) {
final int yOffset = y * maskWidth;
for (int x = 0; x < maskWidth; x++) {
if (maskPixels[x + yOffset] != 0) {
area.add(new Area(new Rectangle(x + maskBounds.x, y + maskBounds.y, 1, 1)));
}
}
}
result = area;
} else {
result = makeShapeFromArray(new ShapeRoi(roi).getShapeAsArray());
}
return result;
}
示例6: run
import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
public void run(final ImageProcessor ip) {
final GenericDialog dialog = new GenericDialog(PLUGIN_NAME);
dialog.addNumericField("Intensity shift", shift, 0);
dialog.showDialog();
if (dialog.wasCanceled()) {
return;
}
shift = (int) Math.abs(Math.round(dialog.getNextNumber()));
final ByteProcessor bp = (ByteProcessor) ip;
final byte[] pixels = (byte[]) bp.getPixels();
for (int i = 0; i < pixels.length; i++) {
int pixel = pixels[i] & 0xff;
pixel += shift;
pixel %= 256;
pixels[i] = (byte) (pixel & 0xff);
}
}
示例7: fill
import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
* Fill the ByteProcessor with provided value.
*
* @param bp buffer
* @param val value to fill buffer with
*/
public static void fill (ByteProcessor bp,
int val)
{
final byte[] pixels = (byte[]) bp.getPixels();
Arrays.fill(pixels, (byte) val);
}
示例8: dilate
import ij.process.ByteProcessor; //导入方法依赖的package包/类
/** Performs gray level dilation
*
* @param ip the ImageProcessor
*/
public void dilate (ByteProcessor ip)
{
int width = ip.getWidth();
int height = ip.getHeight();
int max = 32768; //,k=0,x=0,y=0;
//int[][]pg=se.getVect();
// IJ.log("pg: "+pg.length);
int sz = pg.length; //se.getWidth()*se.getHeight();
byte[] pixels = (byte[]) ip.getPixels();
int[] wnd = new int[sz];
byte[] newpix = new byte[pixels.length];
//int i,j=0;
for (int c = 0; c < pixels.length; c++) {
//i=c/width;
//j=c%width;
wnd = getMinMax(c, width, height, pixels, pg, DILATE);
max = wnd[1] - 255;
newpix[c] = (byte) (max & 0xFF);
}
System.arraycopy(newpix, 0, pixels, 0, pixels.length);
}
示例9: greaterThanOrEqual
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public static ByteProcessor greaterThanOrEqual(ImageProcessor ip1, ImageProcessor ip2) {
ByteProcessor bp = new ByteProcessor(ip1.getWidth(), ip1.getHeight());
byte[] bpPixels = (byte[])bp.getPixels();
for (int i = 0; i < bpPixels.length; i++) {
if (ip1.getf(i) >= ip2.getf(i))
bpPixels[i] = (byte)255;
}
return bp;
}
示例10: greaterThan
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public static ByteProcessor greaterThan(ImageProcessor ip1, ImageProcessor ip2) {
ByteProcessor bp = new ByteProcessor(ip1.getWidth(), ip1.getHeight());
byte[] bpPixels = (byte[])bp.getPixels();
for (int i = 0; i < bpPixels.length; i++) {
if (ip1.getf(i) > ip2.getf(i))
bpPixels[i] = (byte)255;
}
return bp;
}
示例11: thresholdBelow
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public static ByteProcessor thresholdBelow(ImageProcessor ip, float threshold) {
ByteProcessor bp = new ByteProcessor(ip.getWidth(), ip.getHeight());
byte[] bpPixels = (byte[])bp.getPixels();
for (int i = 0; i < bpPixels.length; i++) {
if (ip.getf(i) < threshold)
bpPixels[i] = (byte)255;
}
return bp;
}
示例12: thresholdBelowEquals
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public static ByteProcessor thresholdBelowEquals(ImageProcessor ip, float threshold) {
ByteProcessor bp = new ByteProcessor(ip.getWidth(), ip.getHeight());
byte[] bpPixels = (byte[])bp.getPixels();
for (int i = 0; i < bpPixels.length; i++) {
if (ip.getf(i) <= threshold)
bpPixels[i] = (byte)255;
}
return bp;
}
示例13: imagesEqual
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public static ByteProcessor imagesEqual(ImageProcessor ip1, ImageProcessor ip2) {
ByteProcessor bp = new ByteProcessor(ip1.getWidth(), ip1.getHeight());
byte[] bpPixels = (byte[])bp.getPixels();
for (int i = 0; i < bpPixels.length; i++) {
if (ip1.getf(i) == ip2.getf(i))
bpPixels[i] = (byte)255;
}
return bp;
}
示例14: thresholdAbove
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public static ByteProcessor thresholdAbove(ImageProcessor ip, float threshold) {
ByteProcessor bp = new ByteProcessor(ip.getWidth(), ip.getHeight());
byte[] bpPixels = (byte[])bp.getPixels();
for (int i = 0; i < bpPixels.length; i++) {
if (ip.getf(i) > threshold)
bpPixels[i] = (byte)255;
}
return bp;
}
示例15: thresholdBetween
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public static ByteProcessor thresholdBetween(ImageProcessor ip, float lowThreshold, float highThreshold) {
ByteProcessor bp = new ByteProcessor(ip.getWidth(), ip.getHeight());
byte[] bpPixels = (byte[])bp.getPixels();
for (int i = 0; i < bpPixels.length; i++) {
float val = ip.getf(i);
if (val >= lowThreshold && val <= highThreshold)
bpPixels[i] = (byte)255;
}
return bp;
}