Search in sources :

Example 16 with Shape

use of com.joliciel.jochre.graphics.Shape in project jochre by urieli.

the class UpperLefthandOpeningFeature method checkInternal.

@Override
public FeatureResult<Boolean> checkInternal(ShapeWrapper shapeWrapper, RuntimeEnvironment env) {
    Shape shape = shapeWrapper.getShape();
    int lowerPoint = (int) ((double) shape.getHeight() * (2.0 / 3.0));
    int upperPoint = shape.getHeight() / 8;
    int openingThreshold = shape.getWidth() / 2;
    int wallThreshold = shape.getWidth() / 4;
    if (LOG.isTraceEnabled()) {
        LOG.trace("lowerPoint: " + lowerPoint);
        LOG.trace("upperPoint: " + upperPoint);
        LOG.trace("openingThreshold: " + openingThreshold);
        LOG.trace("wallThreshold: " + wallThreshold);
    }
    boolean foundWall = false;
    boolean foundOpening = false;
    boolean foundAnotherWall = false;
    for (int y = lowerPoint; y >= upperPoint; y--) {
        for (int x = 0; x <= openingThreshold; x++) {
            if (!foundWall && x > wallThreshold) {
                break;
            } else if (!foundWall && shape.isPixelBlack(x, y, shape.getJochreImage().getBlackThreshold())) {
                foundWall = true;
                if (LOG.isTraceEnabled())
                    LOG.trace("foundWall y=" + y + ", x=" + x);
                break;
            } else if (foundWall && !foundOpening && shape.isPixelBlack(x, y, shape.getJochreImage().getBlackThreshold())) {
                break;
            } else if (foundWall && !foundOpening && x == openingThreshold) {
                foundOpening = true;
                if (LOG.isTraceEnabled())
                    LOG.trace("foundOpening y=" + y + ", x=" + x);
                break;
            } else if (foundOpening && !foundAnotherWall && x >= wallThreshold) {
                break;
            } else if (foundOpening && !foundAnotherWall && shape.isPixelBlack(x, y, shape.getJochreImage().getBlackThreshold())) {
                foundAnotherWall = true;
                if (LOG.isTraceEnabled())
                    LOG.trace("foundAnotherWall y=" + y + ", x=" + x);
                break;
            }
        }
        if (foundAnotherWall)
            break;
    }
    FeatureResult<Boolean> outcome = this.generateResult(foundAnotherWall);
    return outcome;
}
Also used : Shape(com.joliciel.jochre.graphics.Shape)

Example 17 with Shape

use of com.joliciel.jochre.graphics.Shape in project jochre by urieli.

the class VerticalSizeFeature method checkInternal.

@Override
public FeatureResult<Double> checkInternal(ShapeWrapper shapeWrapper, RuntimeEnvironment env) {
    Shape shape = shapeWrapper.getShape();
    double ratio = (double) shape.getHeight() / (double) (shape.getBaseLine() - shape.getMeanLine());
    FeatureResult<Double> outcome = this.generateResult(ratio);
    return outcome;
}
Also used : Shape(com.joliciel.jochre.graphics.Shape)

Example 18 with Shape

use of com.joliciel.jochre.graphics.Shape in project jochre by urieli.

the class WidthFeature method checkInternal.

@Override
public FeatureResult<Double> checkInternal(ShapeWrapper shapeWrapper, RuntimeEnvironment env) {
    Shape shape = shapeWrapper.getShape();
    double ratio = (double) shape.getWidth() / (double) (shape.getBaseLine() - shape.getMeanLine());
    FeatureResult<Double> outcome = this.generateResult(ratio);
    return outcome;
}
Also used : Shape(com.joliciel.jochre.graphics.Shape)

Example 19 with Shape

use of com.joliciel.jochre.graphics.Shape in project jochre by urieli.

the class AbstractShapeFeature method putInCache.

@Override
protected void putInCache(ShapeWrapper shapeWrapper, FeatureResult<Y> featureResult, RuntimeEnvironment env) {
    Shape shape = shapeWrapper.getShape();
    shape.putResultInCache(this, featureResult, env);
}
Also used : Shape(com.joliciel.jochre.graphics.Shape)

Example 20 with Shape

use of com.joliciel.jochre.graphics.Shape in project jochre by urieli.

the class BaselineDistanceFeature method checkInternal.

@Override
public FeatureResult<Double> checkInternal(ShapeWrapper shapeWrapper, RuntimeEnvironment env) {
    Shape shape = shapeWrapper.getShape();
    int lineHeight = shape.getBaseLine() - shape.getMeanLine();
    int zeroPoint = (shape.getTop() + shape.getBaseLine());
    int onePoint = (shape.getTop() + shape.getBaseLine()) + lineHeight;
    double relativeBottom = 0;
    if (shape.getBottom() <= zeroPoint)
        relativeBottom = 0;
    else if (shape.getBottom() >= onePoint)
        relativeBottom = 1;
    else {
        relativeBottom = ((double) (shape.getBottom() - zeroPoint) / (onePoint - zeroPoint));
    }
    FeatureResult<Double> outcome = this.generateResult(relativeBottom);
    return outcome;
}
Also used : Shape(com.joliciel.jochre.graphics.Shape)

Aggregations

Shape (com.joliciel.jochre.graphics.Shape)74 ArrayList (java.util.ArrayList)22 GroupOfShapes (com.joliciel.jochre.graphics.GroupOfShapes)14 JochreImage (com.joliciel.jochre.graphics.JochreImage)13 Paragraph (com.joliciel.jochre.graphics.Paragraph)9 RowOfShapes (com.joliciel.jochre.graphics.RowOfShapes)9 Decision (com.joliciel.talismane.machineLearning.Decision)8 Test (org.junit.Test)8 JochreSession (com.joliciel.jochre.JochreSession)7 JochrePage (com.joliciel.jochre.doc.JochrePage)7 Config (com.typesafe.config.Config)7 TreeSet (java.util.TreeSet)7 JochreDocument (com.joliciel.jochre.doc.JochreDocument)6 BufferedImage (java.awt.image.BufferedImage)6 ShapeInSequence (com.joliciel.jochre.boundaries.ShapeInSequence)5 ShapeSequence (com.joliciel.jochre.boundaries.ShapeSequence)5 GraphicsDao (com.joliciel.jochre.graphics.GraphicsDao)5 RuntimeEnvironment (com.joliciel.talismane.machineLearning.features.RuntimeEnvironment)5 SplitFeature (com.joliciel.jochre.boundaries.features.SplitFeature)4 JochreException (com.joliciel.jochre.utils.JochreException)4