Search in sources :

Example 6 with CoordsType

use of eu.transkribus.core.model.beans.pagecontent.CoordsType in project TranskribusCore by Transkribus.

the class BeanCopyUtils method copyCoordsType.

public static CoordsType copyCoordsType(CoordsType coords) {
    if (coords == null)
        return null;
    CoordsType copy = new CoordsType();
    copy.setPoints(coords.getPoints());
    return copy;
}
Also used : CoordsType(eu.transkribus.core.model.beans.pagecontent.CoordsType)

Example 7 with CoordsType

use of eu.transkribus.core.model.beans.pagecontent.CoordsType in project TranskribusCore by Transkribus.

the class ImgUtilsTest method testBorderRemoval.

private static void testBorderRemoval() throws IOException, JAXBException {
    File testImg = new File("/mnt/dea_scratch/TRP/test/I._ZvS_1902_4.Q/ZS-I-1902-198 (1).jpg");
    File testXml = new File("/mnt/dea_scratch/TRP/test/I._ZvS_1902_4.Q/page/ZS-I-1902-198 (1).xml");
    // Open the image.
    // BufferedImage baseImage = ImageIO.read(testImg);
    PcGtsType pc = PageXmlUtils.unmarshal(testXml);
    final CoordsType coords = pc.getPage().getPrintSpace().getCoords();
    // build printspace polygon
    Polygon p = PageXmlUtils.buildPolygon(coords);
    String outPng = "/tmp/output.png";
    File out = ImgUtils.killBorder(testImg, p, outPng);
// File bin = NcsrTools.binarize(out, new File("/tmp/bin.tiff"));
// 
// File reg = NcsrTools.segmentRegions(out, bin, new File("/tmp/reg.xml"));
// File lines = NcsrTools.segmentLines(bin, reg, new File("/tmp/output.xml"));
}
Also used : CoordsType(eu.transkribus.core.model.beans.pagecontent.CoordsType) Polygon(java.awt.Polygon) File(java.io.File) PcGtsType(eu.transkribus.core.model.beans.pagecontent.PcGtsType)

Example 8 with CoordsType

use of eu.transkribus.core.model.beans.pagecontent.CoordsType in project TranskribusCore by Transkribus.

the class PageXmlUtils method cutPolysAtImgBorder.

/**
 * If regions overlap the img border, reset offlimit coordinates to min/max
 *
 * @param pc
 */
public static void cutPolysAtImgBorder(PcGtsType pc) {
    final int maxX = pc.getPage().getImageWidth();
    final int maxY = pc.getPage().getImageHeight();
    List<TrpRegionType> regions = pc.getPage().getTextRegionOrImageRegionOrLineDrawingRegion();
    if (regions == null || regions.isEmpty()) {
        return;
    }
    StringBuilder sb;
    for (RegionType r : regions) {
        sb = new StringBuilder();
        CoordsType c = r.getCoords();
        final String pointsStr = c.getPoints();
        if (pointsStr == null || pointsStr.isEmpty()) {
            continue;
        }
        final String[] coordsArr = pointsStr.split(" ");
        for (int i = 0; i < coordsArr.length; i++) {
            final String[] xy = coordsArr[i].split(",");
            final int x = Integer.parseInt(xy[0]);
            final int y = Integer.parseInt(xy[1]);
            sb.append(x < 0 ? 0 : (x > maxX ? maxX : x));
            sb.append(",");
            sb.append(y < 0 ? 0 : (y > maxY ? maxY : y));
            sb.append(" ");
        }
        c.setPoints(sb.toString().trim());
    }
}
Also used : TrpTextRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType) TrpRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType) RegionType(eu.transkribus.core.model.beans.pagecontent.RegionType) TextRegionType(eu.transkribus.core.model.beans.pagecontent.TextRegionType) TableRegionType(eu.transkribus.core.model.beans.pagecontent.TableRegionType) TrpRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType) CoordsType(eu.transkribus.core.model.beans.pagecontent.CoordsType)

Example 9 with CoordsType

use of eu.transkribus.core.model.beans.pagecontent.CoordsType in project TranskribusCore by Transkribus.

the class TrpTableCellType method setCoordinates.

@Override
public void setCoordinates(String value, Object who) {
    CoordsType coords = new CoordsType();
    coords.setPoints(value);
    setCoords(coords);
    observable.setChangedAndNotifyObservers(new TrpCoordsChangedEvent(who));
}
Also used : CoordsType(eu.transkribus.core.model.beans.pagecontent.CoordsType) TrpCoordsChangedEvent(eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpCoordsChangedEvent)

Example 10 with CoordsType

use of eu.transkribus.core.model.beans.pagecontent.CoordsType in project TranskribusCore by Transkribus.

the class TrpRegionType method setCoordinates.

@Override
public void setCoordinates(String value, Object who) {
    CoordsType coords = new CoordsType();
    coords.setPoints(value);
    setCoords(coords);
    observable.setChangedAndNotifyObservers(new TrpCoordsChangedEvent(who));
}
Also used : CoordsType(eu.transkribus.core.model.beans.pagecontent.CoordsType) TrpCoordsChangedEvent(eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpCoordsChangedEvent)

Aggregations

CoordsType (eu.transkribus.core.model.beans.pagecontent.CoordsType)10 TrpCoordsChangedEvent (eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpCoordsChangedEvent)5 PcGtsType (eu.transkribus.core.model.beans.pagecontent.PcGtsType)1 RegionType (eu.transkribus.core.model.beans.pagecontent.RegionType)1 TableRegionType (eu.transkribus.core.model.beans.pagecontent.TableRegionType)1 TextRegionType (eu.transkribus.core.model.beans.pagecontent.TextRegionType)1 TrpRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType)1 TrpTextRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType)1 Polygon (java.awt.Polygon)1 File (java.io.File)1