本文整理汇总了Java中javax.media.jai.PlanarImage.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java PlanarImage.getHeight方法的具体用法?Java PlanarImage.getHeight怎么用?Java PlanarImage.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.jai.PlanarImage
的用法示例。
在下文中一共展示了PlanarImage.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public PlanarImage process(final PlanarImage image) {
if (image == null || (image.getWidth() * image.getHeight() > 6000 * 6000L))
throw new IllegalArgumentException("this implementation can only handle images where width*height<=6000*6000. (And image cannot be null)");
TMAPointsResult res = findCircles(image);
this.radius = res.getRadius();
List<Point> pList = res.getSpotList();
HashMap<Point, Point> pMap = clusterLines(pList);
pMap = discardDuplicatePoints(pMap);
BufferedImage buffImg = res.getSpotImage();
Graphics g = buffImg.createGraphics();
g.setColor(Color.blue);
g.setFont(new Font("System", Font.PLAIN, 9));
for (Point p : pMap.keySet()) {
Point pos = pMap.get(p);
g.drawString(pos.x + "/" + pos.y, p.x, p.y);
}
spotMap = pMap;
return PlanarImage.wrapRenderedImage(buffImg);
}
示例2: reportPoints
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
* returns all UEP with a threshold > min in a pointlist.
* The UEP process has to be applied before!
*
* @param img
* @param min
* @return
*/
private List<Point> reportPoints(PlanarImage img, int min) {
Raster r = img.getData();
int[] rgb = new int[3];
double d;
List<Point> pList = new ArrayList<Point>();
for (int x = 0; x < img.getWidth(); x++)
for (int y = 0; y < img.getHeight(); y++) {
rgb = r.getPixel(x, y, rgb);
d = (rgb[0]);
if (d > min) {
Point p = new Point(x, y);
pList.add(p);
if (logger.isTraceEnabled()) {
logger.trace(x + "," + y + ": " + d);
}
}
}
return pList;
}
示例3: toBinaryImagePlus
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
* Creats a binary ImagePlus based on a planar image. If a pixel is fg it is set to white, otherwise to black.
*
* @param image
* @param fg
* @return
*/
public static ImagePlus toBinaryImagePlus(PlanarImage image, Color fg) {
if (image == null || (image.getWidth() * image.getHeight() > 6000 * 6000L))
throw new IllegalArgumentException("this implementation can only handle images where width*height<=6000*6000. (And image cannot be null)");
int width = image.getWidth();
int height = image.getHeight();
Raster raster = image.getData();
int[] arr = new int[4];
// set background to black and foreground to white for imageJ watershed
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
int b = 0;
for (int y = b; y < height - b; y++) {
for (int x = b; x < width - b; x++) {
arr = raster.getPixel(x, y, arr);
if (arr[0] == fg.getRed() && arr[1] == fg.getGreen() && arr[2] == fg.getBlue()) {
bi.setRGB(x, y, Color.WHITE.getRGB());
} else {
bi.setRGB(x, y, Color.BLACK.getRGB());
}
}
}
ImagePlus ip = new ImagePlus("watershed", bi);
return ip;
}
示例4: toPlanarImage
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
* Creats a planar image based on an ImagePlus. The originalImage is just used for dimensions and tileSize (could be replaced by its int values).
*
* @param ip
* @param originalImage
* @param fg
* @param bg
* @return
*/
public static PlanarImage toPlanarImage(ImagePlus ip, PlanarImage originalImage, Color fg, Color bg) {
TiledImageWriter imageWriter = new TiledImageWriter(originalImage.getWidth(), originalImage.getHeight(), originalImage.getTileWidth(), originalImage.getTileHeight());
// resImg
Point[] tileArr = imageWriter.getImage().getTileIndices(null);
int[] p = new int[4];
int[] bgArr = new int[]{bg.getRed(), bg.getGreen(), bg.getBlue(), 255};
int[] fgArr = new int[]{fg.getRed(), fg.getGreen(), fg.getBlue(), 255};
for (Point tileNum : tileArr) {
WritableRaster writeRaster = imageWriter.getImage().getWritableTile(tileNum.x, tileNum.y);
for (int x = imageWriter.getImage().tileXToX(tileNum.x); x < Math.min(imageWriter.getImage().tileXToX(tileNum.x) + imageWriter.getImage().getTileWidth(), imageWriter.getImage().getWidth()); x++)
for (int y = imageWriter.getImage().tileYToY(tileNum.y); y < Math.min(imageWriter.getImage().tileYToY(tileNum.y) + imageWriter.getImage().getTileHeight(), imageWriter.getImage().getHeight()); y++) {
p = ip.getPixel(x, y);
if (p[0] != 0) p = fgArr;
else p = bgArr;
writeRaster.setPixel(x, y, p); // since it is not a gray-scale image, we just use the red channel
} // x,y
imageWriter.getImage().releaseWritableTile(tileNum.x, tileNum.y);
} // tileNum
return imageWriter.getImage();
}
示例5: TiledImageWriter
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public TiledImageWriter(PlanarImage inputImage, int xOffs, int yOffs) {
this.width = inputImage.getWidth();
this.height = inputImage.getHeight();
this.tileWidth = inputImage.getTileWidth();
this.tileHeight = inputImage.getTileHeight();
colorModel = new ComponentColorModel(
ColorSpace.getInstance(ColorSpace.CS_sRGB),
new int[]{8, 8, 8, 8}, true, false,
Transparency.TRANSLUCENT,
DataBuffer.TYPE_BYTE);
sampleModel = colorModel.createCompatibleSampleModel(tileWidth, tileHeight);
image = new DiskMemImageOrbit(xOffs, yOffs, width, height, 0, 0, sampleModel, colorModel);
((DiskMemImageOrbit) image).setUseCommonCache(true);
TiledImagePainter painter = new TiledImagePainter(inputImage, "");
Graphics2D g2d = image.createGraphics();
try { // 03.05.2010 Manuel (exception with JRE 1.5, with JRE 1.6 fine)
painter.drawImage(g2d, xOffs, yOffs, width, height, 100d, -1);
} catch (Throwable e) {
//System.out.println("TiledImageWriter Error",e);
//e.printStackTrace();
}
}
示例6: detectSegmentations
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public List<Shape> detectSegmentations(int minSegmentationSize, PlanarImage sourceImage) {
logger.trace("getSegmentations (minSegmentation=" + minSegmentationSize + ")");
rf.initializeClassColors();
//if (rf.getNegativeChannel() != null) rf.getNegativeChannel().initializeClassColors();
if (sourceImage == null) return new ArrayList<Shape>(0);
short[][] smap = new short[sourceImage.getWidth()][sourceImage.getHeight()];
for (int x = 0; x < sourceImage.getWidth(); x++)
for (int y = 0; y < sourceImage.getHeight(); y++)
smap[x][y] = Short.MAX_VALUE;
// init
Point[] tileArr = sourceImage.getTileIndices(null);
int c;
for (Point tileNum : tileArr) {
if (isCancelled()) break;
final int b = 2;
Raster raster = sourceImage.getTile(tileNum.x, tileNum.y);
for (int x = sourceImage.tileXToX(tileNum.x) + b; x < Math.min(sourceImage.tileXToX(tileNum.x) + sourceImage.getTileWidth() - b, sourceImage.getWidth()); x++) {
for (int y = sourceImage.tileYToY(tileNum.y) + b; y < Math.min(sourceImage.tileYToY(tileNum.y) + sourceImage.getTileHeight() - b, sourceImage.getHeight()); y++) {
if (fullRoi != null && !(fullRoi.contains(x + roi.getBounds().x, y + roi.getBounds().y))) {
continue;
}
c = raster.getSample(x, y, 0) < 200 ? 0 : 1; // dark=foreground, white=background (only red channel is taken into account)
if (c == 0) { // not background, not assigned
smap[x][y] = 1; // 1
} else {
smap[x][y] = 0; // 0
}
} //y
} // x
} // tileNum
if (isCancelled()) return null;
return findPolygons(smap, minSegmentationSize);
}
示例7: detectSegmentations
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public List<Shape> detectSegmentations(int minSegmentationSize, PlanarImage sourceImage, Shape roi) {
logger.trace("getSegmentations (minSegmentation=" + minSegmentationSize + ")");
if (sourceImage == null) return new ArrayList<Shape>(0);
short[][] smap = new short[sourceImage.getWidth()][sourceImage.getHeight()];
for (int x = 0; x < sourceImage.getWidth(); x++)
for (int y = 0; y < sourceImage.getHeight(); y++)
smap[x][y] = Short.MAX_VALUE;
// init
Point[] tileArr = sourceImage.getTileIndices(null);
int c;
for (Point tileNum : tileArr) {
if (isCancelled()) break;
final int b = 2;
Raster raster = sourceImage.getTile(tileNum.x, tileNum.y);
for (int x = sourceImage.tileXToX(tileNum.x) + b; x < Math.min(sourceImage.tileXToX(tileNum.x) + sourceImage.getTileWidth() - b, sourceImage.getWidth()); x++) {
for (int y = sourceImage.tileYToY(tileNum.y) + b; y < Math.min(sourceImage.tileYToY(tileNum.y) + sourceImage.getTileHeight() - b, sourceImage.getHeight()); y++) {
if (fullRoi != null && !(fullRoi.contains(x + roi.getBounds().x, y + roi.getBounds().y))) {
continue;
}
c = raster.getSample(x, y, 0) < 200 ? 0 : 1; // dark=foreground, white=background (only red channel is taken into account)
if (c == 0) { // not background, not assigned
smap[x][y] = 1; // 1
} else {
smap[x][y] = 0; // 0
}
} //y
} // x
} // tileNum
if (isCancelled()) return null;
return findPolygons(smap, orderPoints, minSegmentationSize, roi);
}
示例8: adjustBlur
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public static PlanarImage adjustBlur(PlanarImage srcImg, final int b) {
final int width = srcImg.getWidth();
final int height = srcImg.getHeight();
final int[] src = srcImg.getData().getPixels(0, 0, width, height, new int[width * height * 3]);
final int[] dest = new int[width * height * 3];
for (int l = 0; l < b; l++) {
if (l == 0) {
int dum;
for (int i = 0; i < src.length - 3; i += 3) {
dum = src[i + 0];
src[i + 0] = src[i + 2];
src[i + 2] = dum;
}
} else {
for (int i = 0; i < src.length - 3; i += 3) {
src[i + 0] = dest[i + 0];
src[i + 1] = dest[i + 1];
src[i + 2] = dest[i + 2];
}
}
for (int i = width * 3 + 3; i < src.length - 3 - width * 3; i += 3) {
dest[i + 0] = (src[i + 0] + src[i + 0 + 3] + src[i + 0 - 3] + src[i + 0 - width * 3] + src[i + 0 + 3 - width * 3] + src[i + 0 - 3 - width * 3] + src[i + 0 + width * 3] + src[i + 0 + 3 + width * 3] + src[i + 0 - 3 + width * 3]) / 9;
dest[i + 1] = (src[i + 1] + src[i + 1 + 3] + src[i + 1 - 3] + src[i + 1 - width * 3] + src[i + 1 + 3 - width * 3] + src[i + 1 - 3 - width * 3] + src[i + 1 + width * 3] + src[i + 1 + 3 + width * 3] + src[i + 1 - 3 + width * 3]) / 9;
dest[i + 2] = (src[i + 2] + src[i + 2 + 3] + src[i + 2 - 3] + src[i + 2 - width * 3] + src[i + 2 + 3 - width * 3] + src[i + 2 - 3 - width * 3] + src[i + 2 + width * 3] + src[i + 2 + 3 + width * 3] + src[i + 2 - 3 + width * 3]) / 9;
}
}
DataBufferByte db = new DataBufferByte(dest.length);
for (int i = 0; i < dest.length; i++) {
db.setElem(i, dest[i]);
}
WritableRaster raster = WritableRaster.createWritableRaster(srcImg.getSampleModel(), db, new Point(0, 0));
BufferedImage bi = new BufferedImage(srcImg.getColorModel(), raster, srcImg.getColorModel().isAlphaPremultiplied(), null);
return PlanarImage.wrapRenderedImage(bi);
}
示例9: OrbitTiledImagePlanarImage
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public OrbitTiledImagePlanarImage(PlanarImage image) throws Exception {
super("");
this.image = image;
this.width = image.getWidth();
this.height = image.getHeight();
this.tileWidth = image.getTileWidth();
this.tileHeight = image.getTileHeight();
this.tileGridXOffset = image.getTileGridXOffset();
this.tileGridYOffset = image.getTileGridYOffset();
this.minX = image.getMinX();
this.minY = image.getMinY();
this.numBands = image.getNumBands();
this.colorModel = image.getColorModel();
this.sampleModel = image.getSampleModel();
// if (numBands==1) this.colorModel = grayColorModel; else
// {
// this.colorModel = rgbColorModel;
// }
// this.colorModel = rgbColorModel; // an OrbitTiledImage is always a RGB image
// this.sampleModel = colorModel.createCompatibleSampleModel(tileWidth, tileHeight);
// bugfix 20.04.2012 Manuel: colorModel is now always defined by input image (overview image problem)
this.colorModel = image.getColorModel();
this.sampleModel = image.getSampleModel();
this.filename = "PlanarImage " + image.hashCode();
// better set useCache always to false here???
}
示例10: performScale
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
* Scale an image.
* @param image the image to scale.
* @return the scaled image.
*/
public PlanarImage performScale(PlanarImage image) {
ParameterBlock pb = new ParameterBlock();
pb.addSource(image);
float xFl = getWidth();
float yFl = getHeight();
if (!xPercent) {
xFl = xFl / image.getWidth();
}
if (!yPercent) {
yFl = yFl / image.getHeight();
}
if ("width".equals(proportions)) {
yFl = xFl;
} else if ("height".equals(proportions)) {
xFl = yFl;
} else if ("fit".equals(proportions)) {
yFl = Math.min(xFl, yFl);
xFl = yFl;
} else if ("cover".equals(proportions)) {
yFl = Math.max(xFl, yFl);
xFl = yFl;
}
pb.add(Float.valueOf(xFl));
pb.add(Float.valueOf(yFl));
log("\tScaling to " + (xFl * HUNDRED) + "% x "
+ (yFl * HUNDRED) + "%");
return JAI.create("scale", pb);
}
示例11: findCircles
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
private TMAPointsResult findCircles(PlanarImage img) {
double r = 6d;
double d;
Color classCol = OrbitImageAnalysis.getInstance().getModel().getClassShapes().get(1).getColor();
int red = classCol.getRed();
int green = classCol.getGreen();
int blue = classCol.getBlue();
int[] c = new int[4];
logger.trace("class color: " + classCol.toString());
final Raster raster = img.getData();
short[][] buf = new short[img.getWidth()][img.getHeight()]; // num tissue pixels buffer
for (int x = 0; x < img.getWidth(); x++)
for (int y = 0; y < img.getHeight(); y++) {
// x,y is center. Now count #tissue pixel in radius around center
for (int bx = x - (int) r; bx <= x + r; bx++) {
if (bx < 0 || bx >= img.getWidth()) continue;
for (int by = y - (int) r; by <= y + r; by++) {
if (by < 0 || by >= img.getHeight()) continue;
d = Point.distance(bx, by, x, y);
if (d <= r) {
c = raster.getPixel(bx, by, c);
if (c[0] == red && c[1] == green && c[2] == blue) {
buf[x][y]++;
}
}
}
}
}
BufferedImage resImg = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
WritableRaster raster2 = resImg.getRaster();
for (int x = 0; x < resImg.getWidth(); x++)
for (int y = 0; y < resImg.getHeight(); y++) {
raster2.setPixel(x, y, new int[]{buf[x][y], buf[x][y], buf[x][y]});
//System.out.println(buf[x][y]);
}
// TODO: instead of UEP create TMPSpot lost, order (by score) and take highest scored spots
// and check for intersection (maybe with min threshold)
ImagePlus ip = new ImagePlus("TMAPoints", resImg);
thresholder.applyThreshold(ip);
edm.setup("points", null); // "points" for Ultimate points
edm.run(ip.getProcessor());
PlanarImage img1 = PlanarImage.wrapRenderedImage(ip.getBufferedImage());
List<Point> pList = reportPoints(img1, 1);
double radius = guessRadius(pList);
return new TMAPointsResult(pList, radius, resImg);
}
示例12: process
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public SegmentationResult process(final PlanarImage image) {
if (image == null || (image.getWidth() * image.getHeight() > 6000 * 6000L))
throw new IllegalArgumentException("this implementation can only handle images where width*height<=6000*6000. (And image cannot be null)");
logger.debug("voronoi start");
// ImageJ implementation
ImagePlus ip = new ImagePlus("skeleton", image.getAsBufferedImage());
ThresholderOrbit thresholder = new ThresholderOrbit();
thresholder.applyThreshold(ip);
ip.getProcessor().convertToByte(false);
BinaryProcessor bp = new BinaryProcessor((ByteProcessor) ip.getProcessor());
EDM edm = new EDM();
edm.toWatershed(bp);
edm.setup("voronoi", ip);
edm.run(bp);
bp.threshold(0);
bp.dilate();
bp.dilate();
// bp.dilate();
logger.debug("voronoi end");
// make recognitionFrame for segmentation
TiledImagePainter tip = new TiledImagePainter(PlanarImage.wrapRenderedImage(bp.getBufferedImage()), "vronoiImage");
List<ClassShape> classShapes = new ArrayList<ClassShape>(2);
classShapes.add(new ClassShape("Background", Color.black, ClassShape.SHAPETYPE_POLYGONEXT));
classShapes.add(new ClassShape("Foreground", Color.white, ClassShape.SHAPETYPE_POLYGONEXT));
TiledImageWriter tiw = new TiledImageWriter(PlanarImage.wrapRenderedImage(bp.convertToRGB().getBufferedImage()));
RecognitionFrame rf = new RecognitionFrame(tip);
rf.setClassImage(tiw);
rf.getClassShapes().clear();
rf.getClassShapes().addAll(classShapes);
rf.setRatio(new double[rf.getClassShapes().size()]);
rf.initializeClassColors();
ObjectSegmentationWorker seg = new ObjectSegmentationWorker(rf, null, classShapes, null);
seg.setDontClassify(true);
seg.setDoWatershed(false);
seg.setNumThreads(1);
seg.setWithGUI(false);
seg.run();
SegmentationResult segRes = seg.getSegmentationResult();
logger.debug("cytoplasma segmentation count: " + segRes.getObjectCount());
//return PlanarImage.wrapRenderedImage(bp.getBufferedImage());
return segRes;
}
示例13: computeRectUShort
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
private void computeRectUShort(PlanarImage src, RasterAccessor dst) {
RandomIter iter;
if(extender != null) {
Rectangle bounds = new Rectangle(src.getMinX(), src.getMinY(),
src.getWidth() + 1,
src.getHeight() + 1);
iter = RandomIterFactory.create(src.getExtendedData(bounds,
extender),
bounds);
} else {
iter = RandomIterFactory.create(src, src.getBounds());
}
int minX = src.getMinX();
int maxX = src.getMaxX() -
(extender != null ? 0 : 1); // Right padding
int minY = src.getMinY();
int maxY = src.getMaxY() -
(extender != null ? 0 : 1); // Bottom padding
int dstWidth = dst.getWidth();
int dstHeight = dst.getHeight();
int dstBands = dst.getNumBands();
int lineStride = dst.getScanlineStride();
int pixelStride = dst.getPixelStride();
int[] bandOffsets = dst.getBandOffsets();
short[][] data = dst.getShortDataArrays();
float[] warpData = new float[2 * dstWidth];
int lineOffset = 0;
short[] backgroundUShort = new short[dstBands];
for (int i = 0; i < dstBands; i++)
backgroundUShort[i] = (short)backgroundValues[i];
for (int h = 0; h < dstHeight; h++) {
int pixelOffset = lineOffset;
lineOffset += lineStride;
warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
warpData);
int count = 0;
for (int w = 0; w < dstWidth; w++) {
float sx = warpData[count++];
float sy = warpData[count++];
int xint = floor(sx);
int yint = floor(sy);
float xfrac = sx - xint;
float yfrac = sy - yint;
if (xint < minX || xint >= maxX ||
yint < minY || yint >= maxY) {
/* Fill with a background color. */
if (setBackground) {
for (int b = 0; b < dstBands; b++) {
data[b][pixelOffset+bandOffsets[b]] =
backgroundUShort[b];
}
}
} else {
for (int b = 0; b < dstBands; b++) {
int s00 = iter.getSample(xint, yint, b) & 0xFFFF;
int s01 = iter.getSample(xint+1, yint, b) & 0xFFFF;
int s10 = iter.getSample(xint, yint+1, b) & 0xFFFF;
int s11 = iter.getSample(xint+1, yint+1, b) & 0xFFFF;
float s0 = (s01 - s00) * xfrac + s00;
float s1 = (s11 - s10) * xfrac + s10;
float s = (s1 - s0) * yfrac + s0;
data[b][pixelOffset+bandOffsets[b]] = (short)s;
}
}
pixelOffset += pixelStride;
}
}
}
示例14: computeRectShort
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
private void computeRectShort(PlanarImage src, RasterAccessor dst) {
RandomIter iter;
if(extender != null) {
Rectangle bounds = new Rectangle(src.getMinX(), src.getMinY(),
src.getWidth() + 1,
src.getHeight() + 1);
iter = RandomIterFactory.create(src.getExtendedData(bounds,
extender),
bounds);
} else {
iter = RandomIterFactory.create(src, src.getBounds());
}
int minX = src.getMinX();
int maxX = src.getMaxX() -
(extender != null ? 0 : 1); // Right padding
int minY = src.getMinY();
int maxY = src.getMaxY() -
(extender != null ? 0 : 1); // Bottom padding
int dstWidth = dst.getWidth();
int dstHeight = dst.getHeight();
int dstBands = dst.getNumBands();
int lineStride = dst.getScanlineStride();
int pixelStride = dst.getPixelStride();
int[] bandOffsets = dst.getBandOffsets();
short[][] data = dst.getShortDataArrays();
float[] warpData = new float[2 * dstWidth];
int lineOffset = 0;
short[] backgroundShort = new short[dstBands];
for (int i = 0; i < dstBands; i++)
backgroundShort[i] = (short)backgroundValues[i];
for (int h = 0; h < dstHeight; h++) {
int pixelOffset = lineOffset;
lineOffset += lineStride;
warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
warpData);
int count = 0;
for (int w = 0; w < dstWidth; w++) {
float sx = warpData[count++];
float sy = warpData[count++];
int xint = floor(sx);
int yint = floor(sy);
float xfrac = sx - xint;
float yfrac = sy - yint;
if (xint < minX || xint >= maxX ||
yint < minY || yint >= maxY) {
/* Fill with a background color. */
if (setBackground) {
for (int b = 0; b < dstBands; b++) {
data[b][pixelOffset+bandOffsets[b]] =
backgroundShort[b];
}
}
} else {
for (int b = 0; b < dstBands; b++) {
int s00 = iter.getSample(xint, yint, b);
int s01 = iter.getSample(xint+1, yint, b);
int s10 = iter.getSample(xint, yint+1, b);
int s11 = iter.getSample(xint+1, yint+1, b);
float s0 = (s01 - s00) * xfrac + s00;
float s1 = (s11 - s10) * xfrac + s10;
float s = (s1 - s0) * yfrac + s0;
data[b][pixelOffset+bandOffsets[b]] = (short)s;
}
}
pixelOffset += pixelStride;
}
}
}
示例15: computeRectInt
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
private void computeRectInt(PlanarImage src, RasterAccessor dst) {
RandomIter iter;
if(extender != null) {
Rectangle bounds = new Rectangle(src.getMinX(), src.getMinY(),
src.getWidth() + 1,
src.getHeight() + 1);
iter = RandomIterFactory.create(src.getExtendedData(bounds,
extender),
bounds);
} else {
iter = RandomIterFactory.create(src, src.getBounds());
}
int minX = src.getMinX();
int maxX = src.getMaxX() -
(extender != null ? 0 : 1); // Right padding
int minY = src.getMinY();
int maxY = src.getMaxY() -
(extender != null ? 0 : 1); // Bottom padding
int dstWidth = dst.getWidth();
int dstHeight = dst.getHeight();
int dstBands = dst.getNumBands();
int lineStride = dst.getScanlineStride();
int pixelStride = dst.getPixelStride();
int[] bandOffsets = dst.getBandOffsets();
int[][] data = dst.getIntDataArrays();
float[] warpData = new float[2 * dstWidth];
int lineOffset = 0;
int[] backgroundInt = new int[dstBands];
for (int i = 0; i < dstBands; i++)
backgroundInt[i] = (int)backgroundValues[i];
for (int h = 0; h < dstHeight; h++) {
int pixelOffset = lineOffset;
lineOffset += lineStride;
warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
warpData);
int count = 0;
for (int w = 0; w < dstWidth; w++) {
float sx = warpData[count++];
float sy = warpData[count++];
int xint = floor(sx);
int yint = floor(sy);
float xfrac = sx - xint;
float yfrac = sy - yint;
if (xint < minX || xint >= maxX ||
yint < minY || yint >= maxY) {
/* Fill with a background color. */
if (setBackground) {
for (int b = 0; b < dstBands; b++) {
data[b][pixelOffset+bandOffsets[b]] =
backgroundInt[b];
}
}
} else {
for (int b = 0; b < dstBands; b++) {
int s00 = iter.getSample(xint, yint, b);
int s01 = iter.getSample(xint+1, yint, b);
int s10 = iter.getSample(xint, yint+1, b);
int s11 = iter.getSample(xint+1, yint+1, b);
float s0 = (s01 - s00) * xfrac + s00;
float s1 = (s11 - s10) * xfrac + s10;
float s = (s1 - s0) * yfrac + s0;
data[b][pixelOffset+bandOffsets[b]] = (int)s;
}
}
pixelOffset += pixelStride;
}
}
}