本文整理汇总了Java中javax.media.jai.PlanarImage.getBounds方法的典型用法代码示例。如果您正苦于以下问题:Java PlanarImage.getBounds方法的具体用法?Java PlanarImage.getBounds怎么用?Java PlanarImage.getBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.jai.PlanarImage
的用法示例。
在下文中一共展示了PlanarImage.getBounds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toImagePlus
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public static ImagePlus toImagePlus(PlanarImage source, Rectangle roi, BorderExtender border) {
if (roi == null) roi = source.getBounds();
Raster r = source.getExtendedData(roi, border);
int numBands = source.getNumBands();
BufferedImage bi = new BufferedImage(roi.width, roi.height, numBands == 1 ? BufferedImage.TYPE_BYTE_GRAY : BufferedImage.TYPE_INT_RGB);
bi.setData(r);
ImagePlus ip = new ImagePlus("IJManipulation", bi);
return ip;
}
示例2: getROIData
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
private byte[] getROIData(ROI roi, Rectangle rectIMG) {
byte[] dataROI;
PlanarImage roiIMG = roi.getAsImage();
Rectangle rectROI = roiIMG.getBounds();
// Forcing to component colormodel in order to avoid packed bits
ImageWorker w = new ImageWorker();
w.setImage(roiIMG);
w.forceComponentColorModel();
RenderedImage img = w.getRenderedImage();
//
BufferedImage test = new BufferedImage(rectIMG.width, rectIMG.height,
BufferedImage.TYPE_BYTE_GRAY);
ImageLayout2 layout = new ImageLayout2(test);
layout.setMinX(img.getMinX());
layout.setMinY(img.getMinY());
layout.setWidth(img.getWidth());
layout.setHeight(img.getHeight());
// Lookup
byte[] lut = new byte[256];
lut[255] = 1;
lut[1] = 1;
LookupTableJAI table = new LookupTableJAI(lut);
RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
RenderedOp transformed = LookupDescriptor.create(img, table, hints);
Graphics2D gc2d = null;
// Translation parameters in order to position the ROI data correctly in the Raster Space
int trX = -rectIMG.x + rectROI.x - rectIMG.x;
int trY = -rectIMG.y + rectROI.y - rectIMG.y;
try {
gc2d = test.createGraphics();
gc2d.drawRenderedImage(transformed,
AffineTransform.getTranslateInstance(trX, trY));
} finally {
gc2d.dispose();
}
Rectangle testRect = new Rectangle(rectIMG.width, rectIMG.height);
DataBufferByte dbRoi = (DataBufferByte) test.getData(testRect).getDataBuffer();
dataROI = dbRoi.getData();
// BufferedImage is stored in memory so the planarImage chain before can be disposed
ImageUtilities.disposePlanarImageChain(transformed);
// Flush of the BufferedImage
test.flush();
return dataROI;
}
示例3: computeTile
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
* Computes a tile. This method overrides PointOpImage.computeTile()
*
* @param tileX The X index of the tile.
* @param tileY The Y index of the tile.
*/
public Raster computeTile(int tileX, int tileY) {
/* Create a new WritableRaster to represent this tile. */
WritableRaster dest = createTile(tileX, tileY);
/* Clip the raster bound to image bounds. */
Rectangle destRect = dest.getBounds().intersection(getBounds());
PlanarImage srcUnder = getSource(0);
PlanarImage srcOver = getSource(1);
Rectangle srcUnderBounds = srcUnder.getBounds();
Rectangle srcOverBounds = srcOver.getBounds();
/* In case of PointOpImage, mapDestRect(destRect, i) = destRect). */
Raster[] sources = new Raster[1];
if (srcOverBounds.contains(destRect)) {
/* Tile is entirely inside sourceOver. */
sources[0] = srcOver.getData(destRect);
computeRect(sources, dest, destRect);
// Recycle the source tile
if(srcOver.overlapsMultipleTiles(destRect)) {
recycleTile(sources[0]);
}
return dest;
} else if (srcUnderBounds.contains(destRect) &&
!srcOverBounds.intersects(destRect)) {
/* Tile is entirely inside sourceUnder. */
sources[0] = srcUnder.getData(destRect);
computeRect(sources, dest, destRect);
// Recycle the source tile
if(srcUnder.overlapsMultipleTiles(destRect)) {
recycleTile(sources[0]);
}
return dest;
} else {
/* Tile is inside both sources. */
Rectangle isectUnder = destRect.intersection(srcUnderBounds);
sources[0] = srcUnder.getData(isectUnder);
computeRect(sources, dest, isectUnder);
// Recycle the source tile
if(srcUnder.overlapsMultipleTiles(isectUnder)) {
recycleTile(sources[0]);
}
if (srcOverBounds.intersects(destRect)) {
Rectangle isectOver = destRect.intersection(srcOverBounds);
sources[0] = srcOver.getData(isectOver);
computeRect(sources, dest, isectOver);
// Recycle the source tile
if(srcOver.overlapsMultipleTiles(isectOver)) {
recycleTile(sources[0]);
}
}
return dest;
}
}
示例4: getProperty
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
* Returns the specified property in the rendered layer.
*
* @param name Property name.
* @param opNode Operation node.
*/
public Object getProperty(String name, Object opNode) {
validate(name, opNode);
if(opNode instanceof RenderedOp &&
name.equalsIgnoreCase("roi")) {
RenderedOp op = (RenderedOp)opNode;
ParameterBlock pb = op.getParameterBlock();
// Retrieve the rendered source image and its ROI.
PlanarImage src = (PlanarImage)pb.getRenderedSource(0);
Object roiProperty = src.getProperty("ROI");
if(roiProperty == null ||
roiProperty == java.awt.Image.UndefinedProperty ||
!(roiProperty instanceof ROI)) {
return java.awt.Image.UndefinedProperty;
}
ROI roi = (ROI)roiProperty;
// Determine the effective destination bounds.
Rectangle dstBounds = null;
PlanarImage dst = op.getRendering();
if(dst instanceof AreaOpImage &&
((AreaOpImage)dst).getBorderExtender() == null) {
AreaOpImage aoi = (AreaOpImage)dst;
dstBounds =
new Rectangle(aoi.getMinX() + aoi.getLeftPadding(),
aoi.getMinY() + aoi.getTopPadding(),
aoi.getWidth() -
aoi.getLeftPadding() -
aoi.getRightPadding(),
aoi.getHeight() -
aoi.getTopPadding() -
aoi.getBottomPadding());
} else {
dstBounds = dst.getBounds();
}
// If necessary, clip the ROI to the destination bounds.
// XXX Is this desirable?
if(!dstBounds.contains(roi.getBounds())) {
roi = roi.intersect(new ROIShape(dstBounds));
}
return roi;
}
return java.awt.Image.UndefinedProperty;
}
示例5: getProperty
import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
* Returns the specified property.
*
* @param name Property name.
* @param op Operation node.
*/
public Object getProperty(String name,
RenderedOp op) {
if(name == null || op == null) {
throw new IllegalArgumentException
(JaiI18N.getString("SubsampleAveragePropertyGenerator4"));
}
if (name.equals("roi")) {
ParameterBlock pb = op.getParameterBlock();
// Retrieve the rendered source image and its ROI.
PlanarImage src = (PlanarImage)pb.getRenderedSource(0);
Object property = src.getProperty("ROI");
if (property == null ||
property.equals(java.awt.Image.UndefinedProperty) ||
!(property instanceof ROI)) {
return null;
}
ROI srcROI = (ROI)property;
// Determine the effective source bounds.
Rectangle srcBounds = null;
PlanarImage dst = op.getRendering();
if(dst instanceof GeometricOpImage &&
((GeometricOpImage)dst).getBorderExtender() == null) {
GeometricOpImage geomIm = (GeometricOpImage)dst;
Interpolation interp = geomIm.getInterpolation();
srcBounds =
new Rectangle(src.getMinX() + interp.getLeftPadding(),
src.getMinY() + interp.getTopPadding(),
src.getWidth() - interp.getWidth() + 1,
src.getHeight() - interp.getHeight() + 1);
} else {
srcBounds = src.getBounds();
}
// If necessary, clip the ROI to the effective source bounds.
if(!srcBounds.contains(srcROI.getBounds())) {
srcROI = srcROI.intersect(new ROIShape(srcBounds));
}
// Retrieve the scale factors and translation values.
double sx = pb.getDoubleParameter(0);
double sy = pb.getDoubleParameter(1);
// Create an equivalent transform.
AffineTransform transform =
new AffineTransform(sx, 0.0, 0.0, sy, 0, 0);
// Create the scaled ROI.
ROI dstROI = srcROI.transform(transform);
// Retrieve the destination bounds.
Rectangle dstBounds = op.getBounds();
// If necessary, clip the warped ROI to the destination bounds.
if(!dstBounds.contains(dstROI.getBounds())) {
dstROI = dstROI.intersect(new ROIShape(dstBounds));
}
// Return the warped and possibly clipped ROI.
return dstROI;
} else {
return null;
}
}