本文整理汇总了Java中ij.process.Blitter类的典型用法代码示例。如果您正苦于以下问题:Java Blitter类的具体用法?Java Blitter怎么用?Java Blitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Blitter类属于ij.process包,在下文中一共展示了Blitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParts
import ij.process.Blitter; //导入依赖的package包/类
/**
* Retrieve all glyph instances that could be part of clef.
*
* @param isFirstPass true for first pass
* @return clef possible parts
*/
private List<Glyph> getParts (boolean isFirstPass)
{
final Rectangle rect = isFirstPass ? outerRect : innerRect;
// Grab pixels out of staff-free source
ByteProcessor source = sheet.getPicture().getSource(Picture.SourceKey.NO_STAFF);
ByteProcessor buf = new ByteProcessor(rect.width, rect.height);
buf.copyBits(source, -rect.x, -rect.y, Blitter.COPY);
// Extract parts
RunTable runTable = new RunTableFactory(VERTICAL).createTable(buf);
List<Glyph> parts = GlyphFactory.buildGlyphs(runTable, rect.getLocation());
// Keep only interesting parts
purgeParts(parts, isFirstPass);
system.registerGlyphs(parts, Group.CLEF_PART);
logger.debug("{} parts: {}", this, parts.size());
return parts;
}
示例2: imposeMinima
import ij.process.Blitter; //导入依赖的package包/类
public static void imposeMinima(final FloatProcessor fp, final Roi roi) {
final ImageProcessor fpOrig = fp.duplicate();
// ImageStatistics stats = fp.getStatistics();
fp.setValue(Float.NEGATIVE_INFINITY);
fp.fill(roi);
ROILabeling.fillOutside(fp, roi, Float.POSITIVE_INFINITY);
fpOrig.copyBits(fp, 0, 0, Blitter.MIN);
fpOrig.multiply(-1);
fp.multiply(-1);
morphologicalReconstruction(fp, fpOrig);
fp.multiply(-1);
}
示例3: imposeMaxima
import ij.process.Blitter; //导入依赖的package包/类
public static void imposeMaxima(final FloatProcessor fp, final ImageProcessor ipMask) {
final ImageProcessor fpOrig = fp.duplicate();
final ImageStatistics stats = fp.getStatistics();
final int w = fp.getWidth();
final int h = fp.getHeight();
for (int i = 0; i < w * h; i++) {
if (ipMask.getf(i) == 0)
fp.setf(i, Float.NEGATIVE_INFINITY);
else
fp.setf(i, Float.POSITIVE_INFINITY);
}
fpOrig.copyBits(fp, 0, 0, Blitter.MAX);
morphologicalReconstruction(fp, fpOrig);
for (int i = 0; i < w * h; i++) {
if (ipMask.getf(i) != 0)
fp.setf(i, (float)stats.max);
}
}
示例4: fillOutside
import ij.process.Blitter; //导入依赖的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: dilate
import ij.process.Blitter; //导入依赖的package包/类
private void dilate(ByteProcessor ip, int[][] H) {
if (H == null) {
IJ.error("no structuring element");
return;
}
//assume that the hot spot of se is at its center (ic,jc)
int ic = (H[0].length - 1) / 2;
int jc = (H.length - 1) / 2;
int N = H.length * H[0].length;
ImageProcessor tmp = ip.createProcessor(ip.getWidth(), ip.getHeight());
int k = 0;
IJ.showProgress(k, N);
for (int j = 0; j < H.length; j++) {
for (int i = 0; i < H[j].length; i++) {
if (H[j][i] > 0) { // this element is set
// copy image into position (u-ch,v-cv)
tmp.copyBits(ip, i - ic, j - jc, Blitter.MAX);
}
IJ.showProgress(k++, N);
}
}
ip.copyBits(tmp, 0, 0, Blitter.COPY);
}
示例6: outline
import ij.process.Blitter; //导入依赖的package包/类
public void outline(ByteProcessor ip) {
int[][] H = {
{ 0, 1, 0 },
{ 1, 1, 1 },
{ 0, 1, 0 } };
ByteProcessor foreground = (ByteProcessor) ip.duplicate();
erode(foreground, H);
ip.copyBits(foreground, 0, 0, Blitter.DIFFERENCE);
}
示例7: dilate
import ij.process.Blitter; //导入依赖的package包/类
void dilate(ImageProcessor ip, int[][] H){
if (H == null) {
IJ.error("no structuring element");
return;
}
//assume that the hot spot of se is at its center (ic,jc)
int ic = (H[0].length - 1) / 2;
int jc = (H.length - 1) / 2;
int N = H.length * H[0].length;
ImageProcessor tmp = ip.createProcessor(ip.getWidth(),ip.getHeight());
int k = 0;
IJ.showProgress(k,N);
for (int j = 0; j < H.length; j++) {
for (int i = 0; i < H[j].length; i++) {
if (H[j][i] > 0) { // this pixel is set
// copy image into position (u-ch,v-cv)
tmp.copyBits(ip, i - ic, j - jc, Blitter.MAX);
}
IJ.showProgress(k++, N);
}
}
ip.copyBits(tmp, 0, 0, Blitter.COPY);
}
示例8: outline
import ij.process.Blitter; //导入依赖的package包/类
void outline(ImageProcessor ip){
int[][] H = {{0,1,0},
{1,1,1},
{0,1,0}
};
ImageProcessor foreground = ip.duplicate();
erode(foreground,H);
ip.copyBits(foreground,0,0,Blitter.DIFFERENCE);
}
示例9: getBuffer
import ij.process.Blitter; //导入依赖的package包/类
/**
* Compute the scaled buffer for the provided glyph, using related staff interline
* value.
*
* @param glyph the source glyph
* @param interline the related staff interline
* @return the computed buffer using 0 for black (foreground) and 255 for white (background)
*/
public static ByteProcessor getBuffer (Glyph glyph,
int interline)
{
final RunTable runTable = glyph.getRunTable();
final ByteProcessor glyphBuffer = runTable.getBuffer();
final double scale = (double) INTERLINE / interline;
// Build scaled buffer, filled by (scaled) glyph
final int scaledWidth = (int) Math.ceil(runTable.getWidth() * scale);
final int scaledHeight = (int) Math.ceil(runTable.getHeight() * scale);
final ByteProcessor scaledBuffer = (ByteProcessor) glyphBuffer.resize(
scaledWidth,
scaledHeight,
true); // True => use averaging when down-scaling
// Copy scaledBuffer into a WIDTH*HEIGHT target buffer centered on glyph centroid
final Point centroid = glyph.getCentroid();
final Point center = glyph.getCenter();
final int dx = centroid.x - center.x; // X shift of centroid WRT center
final int dy = centroid.y - center.y; // Y shift of centroid WRT center
final int targetDx = (int) Math.rint(dx * scale); // Scaled x shift
final int targetDy = (int) Math.rint(dy * scale); // Scaled y shift
final ByteProcessor buffer = new ByteProcessor(WIDTH, HEIGHT); // Same dim for any symbol
ByteUtil.raz(buffer); // Correct
///ByteUtil.fill(targetBuffer, 100); // Not correct, just meant to visualize limits...
final int xOffset = ((WIDTH - scaledWidth) / 2) - targetDx;
final int yOffset = ((HEIGHT - scaledHeight) / 2) - targetDy;
buffer.copyBits(scaledBuffer, xOffset, yOffset, Blitter.COPY);
return buffer;
}
示例10: getAreaPixels
import ij.process.Blitter; //导入依赖的package包/类
/**
* Report the pixels buffer for the whole key area
*
* @param source pixel source (staff free)
* @param range start/stop values for key area
* @return the buffer of area pixels
*/
public ByteProcessor getAreaPixels (ByteProcessor source,
StaffHeader.Range range)
{
Rectangle keyRect = new Rectangle(range.getStart(), y, range.getWidth(), height);
ByteProcessor keyBuffer = new ByteProcessor(keyRect.width, height);
keyBuffer.copyBits(source, -keyRect.x, -y, Blitter.COPY);
return keyBuffer;
}
示例11: getParts
import ij.process.Blitter; //导入依赖的package包/类
/**
* Retrieve all glyph instances that could be part of time sig.
*
* @return time sig possible parts
*/
private List<Glyph> getParts (Rectangle rect)
{
final Sheet sheet = system.getSheet();
// Grab pixels out of staff-free source
ByteProcessor source = sheet.getPicture().getSource(Picture.SourceKey.NO_STAFF);
ByteProcessor buf = new ByteProcessor(rect.width, rect.height);
buf.copyBits(source, -rect.x, -rect.y, Blitter.COPY);
// Extract parts
RunTable runTable = new RunTableFactory(VERTICAL).createTable(buf);
List<Glyph> parts = GlyphFactory.buildGlyphs(runTable, rect.getLocation());
// Keep only interesting parts
purgeParts(parts, rect);
final GlyphIndex glyphIndex = sheet.getGlyphIndex();
for (ListIterator<Glyph> li = parts.listIterator(); li.hasNext();) {
final Glyph part = li.next();
Glyph glyph = glyphIndex.registerOriginal(part);
glyph.addGroup(Group.TIME_PART); // For debug?
system.addFreeGlyph(glyph);
li.set(glyph);
}
return parts;
}
示例12: clearBoundary
import ij.process.Blitter; //导入依赖的package包/类
/**
* Starting from all white pixels (value = 255) on a ROI's boundary,
* fill the pixels with black
*
* @param bp
* @param roi
* @param clearValue
*/
public static void clearBoundary(ByteProcessor bp, Roi roi, double clearValue) {
ByteProcessor bpEdgeMask = new ByteProcessor(bp.getWidth(), bp.getHeight());
bpEdgeMask.setValue(255);
if (roi == null)
bpEdgeMask.fill();
else {
bpEdgeMask.fill(roi);
}
bpEdgeMask.filter(ByteProcessor.MIN);
bpEdgeMask.invert();
bpEdgeMask.copyBits(bp, 0, 0, Blitter.AND);
bpEdgeMask = MorphologicalReconstruction.binaryReconstruction(bpEdgeMask, bp, false);
bp.copyBits(bpEdgeMask, 0, 0, Blitter.SUBTRACT);
//
// ImagePlus imp = new ImagePlus("Edge", bp.duplicate());
// imp.setRoi(roi);
// imp.show();
// ByteProcessor bpEdgeMask = new ByteProcessor(bp.getWidth(), bp.getHeight());
// bpEdgeMask.setValue(255);
// bpEdgeMask.setLineWidth(2);
// if (roi == null)
// bpEdgeMask.draw(new Roi(0, 0, bp.getWidth(), bp.getHeight()));
// else
// bpEdgeMask.draw(roi);
// bpEdgeMask.copyBits(bp, 0, 0, Blitter.AND);
// bpEdgeMask = MorphologicalReconstruction.binaryReconstruction(bpEdgeMask, bp, false);
// bp.copyBits(bpEdgeMask, 0, 0, Blitter.SUBTRACT);
// new ImagePlus("Edge", bp.duplicate()).show();
}
示例13: convertToOpticalDensitySum
import ij.process.Blitter; //导入依赖的package包/类
public static FloatProcessor convertToOpticalDensitySum(ColorProcessor cp, double maxRed, double maxGreen, double maxBlue) {
FloatProcessor fp = cp.toFloat(0, null);
ColorDeconvolutionHelper.convertPixelsToOpticalDensities((float[])fp.getPixels(), maxRed, true);
FloatProcessor fpTemp = cp.toFloat(1, null);
ColorDeconvolutionHelper.convertPixelsToOpticalDensities((float[])fpTemp.getPixels(), maxGreen, true);
fp.copyBits(fpTemp, 0, 0, Blitter.ADD);
fpTemp = cp.toFloat(2, fpTemp);
ColorDeconvolutionHelper.convertPixelsToOpticalDensities((float[])fpTemp.getPixels(), maxBlue, true);
fp.copyBits(fpTemp, 0, 0, Blitter.ADD);
return fp;
}
示例14: setPasteMode
import ij.process.Blitter; //导入依赖的package包/类
/** Sets the transfer mode used by the <i>Edit/Paste</i> command, where mode is "Copy", "Blend", "Average", "Difference",
"Transparent", "Transparent2", "AND", "OR", "XOR", "Add", "Subtract", "Multiply", or "Divide". */
public static void setPasteMode(String mode) {
mode = mode.toLowerCase(Locale.US);
int m = Blitter.COPY;
if (mode.startsWith("ble") || mode.startsWith("ave"))
m = Blitter.AVERAGE;
else if (mode.startsWith("diff"))
m = Blitter.DIFFERENCE;
else if (mode.indexOf("zero")!=-1)
m = Blitter.COPY_ZERO_TRANSPARENT;
else if (mode.startsWith("tran"))
m = Blitter.COPY_TRANSPARENT;
else if (mode.startsWith("and"))
m = Blitter.AND;
else if (mode.startsWith("or"))
m = Blitter.OR;
else if (mode.startsWith("xor"))
m = Blitter.XOR;
else if (mode.startsWith("sub"))
m = Blitter.SUBTRACT;
else if (mode.startsWith("add"))
m = Blitter.ADD;
else if (mode.startsWith("div"))
m = Blitter.DIVIDE;
else if (mode.startsWith("mul"))
m = Blitter.MULTIPLY;
else if (mode.startsWith("min"))
m = Blitter.MIN;
else if (mode.startsWith("max"))
m = Blitter.MAX;
Roi.setPasteMode(m);
}
示例15: copyBits
import ij.process.Blitter; //导入依赖的package包/类
private void copyBits(ImageProcessor ip, FloatProcessor fp, int lowerX, int lowerY, double weight)
{
if (weight > 0)
{
fp = (FloatProcessor) fp.duplicate();
fp.multiply(weight);
ip.copyBits(fp, lowerX, lowerY, Blitter.ADD);
}
}