本文整理汇总了Java中ij.process.ByteProcessor.getBufferedImage方法的典型用法代码示例。如果您正苦于以下问题:Java ByteProcessor.getBufferedImage方法的具体用法?Java ByteProcessor.getBufferedImage怎么用?Java ByteProcessor.getBufferedImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.ByteProcessor
的用法示例。
在下文中一共展示了ByteProcessor.getBufferedImage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImage
import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
* Report the sheet image, or a sub-image of it if rectangle area is specified.
* <p>
* We use the initial image if it is still available.
* Otherwise we use the binary source.
*
* @param rect rectangular area desired, null for whole image
* @return the (sub) image
*/
public BufferedImage getImage (Rectangle rect)
{
BufferedImage img = initialImage;
if (img == null) {
ByteProcessor buffer = getSource(SourceKey.BINARY);
img = buffer.getBufferedImage();
}
if (rect == null) {
return img;
} else {
return img.getSubimage(rect.x, rect.y, rect.width, rect.height);
}
}
示例2: getCleanImage
import ij.process.ByteProcessor; //导入方法依赖的package包/类
private BufferedImage getCleanImage ()
{
Picture picture = sheet.getPicture();
ByteProcessor buf = picture.getSource(Picture.SourceKey.NO_STAFF);
BufferedImage img = buf.getBufferedImage();
buffer = new ByteProcessor(img);
TextsCleaner cleaner = new TextsCleaner(buffer, img.createGraphics(), sheet);
cleaner.eraseInters();
// Display for visual check?
if (constants.displayTexts.isSet() && (OMR.gui != null)) {
sheet.getStub().getAssembly().addViewTab(
"Texts",
new ScrollImageView(
sheet,
new ImageView(img)
{
@Override
protected void renderItems (Graphics2D g)
{
sheet.renderItems(g); // Apply registered sheet renderers
}
}),
new BoardsPane(new PixelBoard(sheet)));
}
// Keep a copy on disk?
if (constants.keepTextsBuffer.isSet()) {
ImageUtil.saveOnDisk(img, sheet.getId() + ".text");
}
return img;
}
示例3: buildNoStaffBuffer
import ij.process.ByteProcessor; //导入方法依赖的package包/类
private ByteProcessor buildNoStaffBuffer ()
{
boolean linesErased = false;
ByteProcessor src = getSource(SourceKey.BINARY);
ByteProcessor buf = (ByteProcessor) src.duplicate();
BufferedImage img = buf.getBufferedImage();
Graphics2D g = img.createGraphics();
g.setColor(Color.WHITE);
for (SystemInfo system : sheet.getSystems()) {
for (Staff staff : system.getStaves()) {
for (LineInfo li : staff.getLines()) {
StaffLine line = (StaffLine) li;
Glyph glyph = line.getGlyph();
if (glyph == null) {
logger.warn("glyph is null for line " + line + " staff:" + staff);
} else if (glyph.getRunTable() == null) {
logger.warn("glyph runtable is null");
}
linesErased = true;
glyph.getRunTable().render(g, glyph.getTopLeft());
}
}
}
g.dispose();
if (!linesErased) {
logger.warn("No system lines to build NO_STAFF buffer"); // Should not happen!
return null;
}
return new ByteProcessor(img);
}
示例4: process
import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
* Start from the staff-free image, remove all good inters, and from the remaining
* pixels build the symbols glyphs put in SYMBOL group.
* <p>
* For not good inters (some "weak" inters have already survived the first REDUCTION step)
* we put them aside as optional glyphs that can take part of the symbols glyphs clustering and
* thus compete for valuable compounds.
*
* @param optionalsMap (output) all weak glyphs gathered per system
*/
public void process (Map<SystemInfo, List<Glyph>> optionalsMap)
{
logger.debug("SymbolsFilter running...");
ByteProcessor rawBuf = sheet.getPicture().getSource(Picture.SourceKey.NO_STAFF);
BufferedImage img = rawBuf.getBufferedImage();
ByteProcessor buffer = new ByteProcessor(img);
// Prepare the ground for symbols retrieval, noting optional (weak) glyphs per system
Graphics2D g = img.createGraphics();
SymbolsCleaner eraser = new SymbolsCleaner(buffer, g, sheet);
eraser.eraseInters(optionalsMap);
buffer.threshold(127);
// Keep a copy on disk?
if (constants.keepSymbolsBuffer.isSet()) {
ImageUtil.saveOnDisk(img, sheet.getId() + ".sym");
}
// Display for visual check?
if (constants.displaySymbols.isSet() && (OMR.gui != null)) {
sheet.getStub().getAssembly().addViewTab(
"Symbols",
new ScrollImageView(sheet, new MyView(img, optionalsMap)),
new BoardsPane(new PixelBoard(sheet)));
}
buildSymbolsGlyphs(buffer);
}
示例5: MyView
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public MyView (ByteProcessor filtered)
{
super(filtered.getBufferedImage());
setModelSize(new Dimension(sheet.getWidth(), sheet.getHeight()));
// Inject dependency of pixel location
setLocationService(sheet.getLocationService());
// Listen to all painting parameters
PaintingParameters.getInstance()
.addPropertyChangeListener(new WeakPropertyChangeListener(this));
}
示例6: computeRatios
import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
* Compute ratios related to negative, positive and false positive
* pixels computed between input and output images.
*/
public void computeRatios ()
{
final int total = sheet.getWidth() * sheet.getHeight();
StopWatch watch = new StopWatch("computeRatios");
watch.start("input");
final ByteProcessor source = sheet.getPicture().getSource(Picture.SourceKey.BINARY);
final BufferedImage input = source.getBufferedImage();
watch.start("inputCount");
getInputCount();
logger.info(
"INPUT count: {} ratio: {}% (out of {} image pixels)",
inputCount,
String.format("%.1f", (100d * inputCount) / total),
total);
watch.start("output");
output = getOutput();
watch.start("xor");
BufferedImage xor = ImageUtil.invert(ImageUtil.xor(input, output));
///ImageUtil.saveOnDisk(xor, sheet.getPage().getId() + ".XOR");
for (DiffKind kind : DiffKind.values()) {
watch.start(kind.toString());
int count = getCount(kind);
logger.info(
"{}% ({} wrt {} input pixels)",
String.format("%15s ratio: %4.1f", kind, (100d * count) / inputCount),
count,
inputCount);
}
if (constants.printWatch.isSet()) {
watch.print();
}
}