Skip to content

Commit

Permalink
InterController: manually removed inters now reveal and merge their u…
Browse files Browse the repository at this point in the history
…nderlying glyphs
  • Loading branch information
hbitteur committed Jan 21, 2024
1 parent 7588503 commit 0bb035c
Show file tree
Hide file tree
Showing 37 changed files with 858 additions and 338 deletions.
11 changes: 6 additions & 5 deletions src/main/org/audiveris/omr/glyph/GlyphIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public class GlyphIndex
// Persistent data
//----------------

/*
/**
* See {@link #getEntities()} and {@link #setEntities(java.util.ArrayList)} methods
* which are called by private methods
* Sheet#getGlyphIndexContent() and Sheet#setGlyphIndexContent()
* {@link Sheet#getGlyphIndexContent()} and {@link Sheet#setGlyphIndexContent()}
* triggered by JAXB (un)marshalling.
*/

Expand Down Expand Up @@ -399,16 +399,17 @@ public int register (Glyph glyph)
*/
public synchronized Glyph registerOriginal (Glyph glyph)
{
WeakGlyph weak = new WeakGlyph(glyph);
WeakGlyph orgWeak = originals.putIfAbsent(weak, weak);
Glyph orgGlyph = (orgWeak != null) ? orgWeak.get() : null;
final WeakGlyph weak = new WeakGlyph(glyph);
final WeakGlyph orgWeak = originals.putIfAbsent(weak, weak);
final Glyph orgGlyph = (orgWeak != null) ? orgWeak.get() : null;

if (orgGlyph == null) {
privateRegister(glyph);

return glyph;
} else {
logger.debug("Reuse original {}", orgGlyph);
weakIndex.insert(orgWeak); // Safer if original has been removed from index

return orgGlyph;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/org/audiveris/omr/glyph/Glyphs.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// </editor-fold>
package org.audiveris.omr.glyph;

import static org.audiveris.omr.image.PixelSource.BACKGROUND;
import org.audiveris.omr.util.Entities;
import org.audiveris.omr.util.Table;

Expand Down Expand Up @@ -491,7 +492,7 @@ public static boolean intersect (Glyph one,

// More precise test
Table.UnsignedByte table = new Table.UnsignedByte(clip.width, clip.height);
table.fill(255); // All white
table.fill(BACKGROUND); // All white
one.fillTable(table, clip.getLocation(), fat);

return two.intersects(table, clip.getLocation());
Expand Down
26 changes: 26 additions & 0 deletions src/main/org/audiveris/omr/image/ImageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.Raster;
Expand Down Expand Up @@ -280,6 +282,30 @@ public static void saveOnDisk (BufferedImage image,
saveOnDisk(image, "", name);
}

//------------//
// saveOnDisk //
//------------//
/**
* Convenient method to save a BufferedImage to disk (in application temp area)
*
* @param s applied scaling
* @param image the image to save
* @param name file name, without extension
*/
public static void saveOnDisk (int s,
BufferedImage image,
String name)
{
final BufferedImage scaledImg = new BufferedImage(
s * image.getWidth(),
s * image.getHeight(),
image.getType());
final AffineTransform at = AffineTransform.getScaleInstance(s, s);
AffineTransformOp scaleOp = new AffineTransformOp(at, null);
scaleOp.filter(image, scaledImg);
saveOnDisk(scaledImg, "", name);
}

//------------//
// saveOnDisk //
//------------//
Expand Down
19 changes: 16 additions & 3 deletions src/main/org/audiveris/omr/image/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ public List<Point> getForegroundPixels (Rectangle tplBox,
* Collect the image foreground pixels located under the template foreground areas,
* with some additional margin.
*
* @param tplBox absolute positioning of template box in global image
* @param image global image to be read
* @param dilated true for applying dilation before processing
* @param tplBox positioning of template box in provided image
* @param image the provided image to be read
* @param dilated true for applying dilation on foreground areas
* @return the collection of foreground pixels, relative to template box.
*/
public List<Point> getForegroundPixels (Rectangle tplBox,
Expand Down Expand Up @@ -643,6 +643,19 @@ private Point upperLeft (int x,

//~ Static Methods -----------------------------------------------------------------------------

//----------//
// dilation //
//----------//
/**
* Report the erasing dilation value applied on templates.
*
* @return the dilation fraction
*/
public static Scale.Fraction dilation ()
{
return constants.dilation;
}

//----------//
// impactOf //
//----------//
Expand Down
Loading

0 comments on commit 0bb035c

Please sign in to comment.