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;
}
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"));
}
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());
}
}
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));
}
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));
}
Aggregations