use of com.joliciel.jochre.graphics.JochreImage in project jochre by urieli.
the class JochrePage method segment.
/**
* For any Image on this page, segments it by converting to a JochreImage.
*/
public void segment() {
int i = 0;
for (JochreImage image : this.getImages()) {
SourceImage sourceImage = (SourceImage) image;
Segmenter segmenter = new Segmenter(sourceImage, jochreSession);
segmenter.segment();
LOG.debug("Image " + i + " segmented: " + sourceImage.getName());
i++;
}
}
use of com.joliciel.jochre.graphics.JochreImage in project jochre by urieli.
the class JochrePage method save.
@Override
public void save() {
if (this.document != null && this.documentId == 0)
this.documentId = this.document.getId();
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
documentDao.saveJochrePage(this);
if (this.jochreImages != null) {
for (JochreImage jochreImage : this.jochreImages) {
jochreImage.save();
}
}
}
use of com.joliciel.jochre.graphics.JochreImage in project jochre by urieli.
the class JochrePage method segmentAndShow.
/**
* Segment any image on this page and output the segmentation into PNG files
* so that they can be viewed by the user.
*/
public void segmentAndShow(String outputDirectory) {
int i = 0;
for (JochreImage image : this.getImages()) {
SourceImage sourceImage = (SourceImage) image;
Segmenter segmenter = new Segmenter(sourceImage, jochreSession);
segmenter.setDrawSegmentation(true);
segmenter.segment();
BufferedImage segmentedImage = segmenter.getSegmentedImage();
try {
ImageIO.write(segmentedImage, "PNG", new File(outputDirectory + "/" + image.getName() + "_seg.png"));
} catch (IOException e) {
throw new JochreException(e);
}
LOG.debug("Image " + i + " segmented: " + sourceImage.getName());
i++;
}
}
use of com.joliciel.jochre.graphics.JochreImage in project jochre by urieli.
the class TextController method onTimer$startRenderTimer.
@Listen("onTimer = #startRenderTimer")
public void onTimer$startRenderTimer(Event event) {
try {
progressBox.setVisible(true);
if (currentImage != null) {
Html html = new Html();
StringWriter out = new StringWriter();
DocumentObserver textGetter = new TextGetter(out, TextFormat.XHTML);
textGetter.onImageComplete(currentImage);
html.setContent(out.toString());
htmlContent.appendChild(html);
progressMeter1.setValue(100);
// progressBox.setVisible(false);
} else {
if (currentPageIndex < currentDoc.getPages().size()) {
JochrePage page = currentDoc.getPages().get(currentPageIndex);
for (JochreImage image : page.getImages()) {
Html html = new Html();
StringWriter out = new StringWriter();
DocumentObserver textGetter = new TextGetter(out, TextFormat.XHTML);
textGetter.onImageComplete(image);
out.append("<HR/>");
html.setContent(out.toString());
htmlContent.appendChild(html);
}
page.clearMemory();
currentPageIndex++;
double percentComplete = ((double) currentPageIndex / (double) currentDoc.getPages().size()) * 100;
progressMeter1.setValue(new Double(percentComplete).intValue());
startRenderTimer.setRunning(true);
} else {
progressMeter1.setValue(100);
// progressBox.setVisible(false);
}
}
} catch (Exception e) {
LOG.error("Failure in onTimer$startRenderTimer", e);
throw new RuntimeException(e);
}
}
use of com.joliciel.jochre.graphics.JochreImage in project jochre by urieli.
the class JochreDocument method deletePage.
public void deletePage(JochrePage page) {
if (!page.getDocument().equals(this)) {
throw new RuntimeException("Cannot delete page from document - page is on another document");
}
for (JochreImage image : page.getImages()) {
this.graphicsDao.deleteJochreImage(image);
}
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
documentDao.deleteJochrePage(page);
this.getPages().remove(page);
}
Aggregations