1. petermr
  2. imageanalysis

Commits

petermr  committed e3dde57

more commandline options

  • Participants
  • Parent commits ae239b2
  • Branches default

Comments (0)

Files changed (3)

File src/main/java/org/xmlcml/image/ImageProcessor.java

View file
 
 	public ImageProcessor() {
 		setDefaults();
+		clearVariables();
 	}
 	
 	public ImageProcessor(BufferedImage image) {
+		this();
 		this.image = image;
-		setDefaults();
 	}
 
 	public void setDefaults() {
 		ensurePixelProcessor();
+		
 		pixelProcessor.setDefaults();
 		this.setThreshold(getDefaultThreshold());
 		this.setThinning(new ZhangSuenThinning());
 		this.setBinarize(true);
 		this.setThreshold(DEFAULT_THRESHOLD);
 	}
-	
+
+	public void clearVariables() {
+		pixelProcessor.clearVariables();
+		
+		image = null;
+		inputFile = null;
+//		outputDir = null;
+	}
 
 	public void setBase(String base) {
 		this.base = base;
 			}
 			try {
 				image = ImageIO.read(inputFile);
+				LOG.trace("read image "+image);
 			} catch (Exception e) {
 				throw new RuntimeException("Cannot find/read imagefile: "+inputFile, e);
 			}
 		if (image != null) {
 			image = processImage(image);
 		}
+		LOG.trace("image "+image);
 		return image;
 	}
 
 		// this is messy - the super thinning should have been done earlier
 		PixelIslandList pixelIslandList = pixelProcessor.getOrCreatePixelIslandList(thinning != null);
 		pixelIslandList.setParameters(this.parameters);
+		LOG.trace("pil "+pixelIslandList);
 		return pixelIslandList;
 	}
 
 		ensureParameterObject();
 		if (pixelProcessor == null) {
 			pixelProcessor = new PixelProcessor(this);
+//			new Exception("ppex ").printStackTrace();
 			pixelProcessor.setParameters(this.parameters);
 		}
 		return pixelProcessor;

File src/main/java/org/xmlcml/image/pixel/PixelGraph.java

View file
 		PixelEdge extremeEdge = null;
 		double extreme = Double.MAX_VALUE;
 		for (PixelEdge edge : edges) {
-			LOG.debug(edge);
+			LOG.trace(edge);
 			SVGPolyline polyLine = edge.getOrCreateSegmentedPolyline(parameters.getSegmentTolerance());
-			LOG.debug("PL "+polyLine.size()+"  /  "+polyLine.getReal2Array());
+			LOG.trace("PL "+polyLine.size()+"  /  "+polyLine.getReal2Array());
 			// look for goal post edge
 			if (polyLine.size() != 3) {
 				continue;
 				if (midPoint.getX() < extreme) {
 					extreme = midPoint.getX();
 					extremeEdge = edge;
-					LOG.debug("edge "+midPoint);
+					LOG.trace("edge "+midPoint);
 				}
 			// RHS
 			} else if (ComparatorType.RIGHT.equals(comparatorType) && crossbar.isVertical(ANGLE_EPS)) {

File src/main/java/org/xmlcml/image/pixel/PixelProcessor.java

View file
 	private PixelIslandList pixelIslandList;
 	private int maxIsland;
 	private List<PixelGraph> pixelGraphList;
-//	private boolean superThinning;
 	private boolean debug;
 	private ImageProcessor imageProcessor;
 	private BufferedImage image;
 	public void setDefaults() {
 		this.setMaxIsland(getDefaultMaxIsland());
 		this.setIsland(-1); // because 0 is a valid island
+		
 	}
 	
+	public void clearVariables() {
+		pixelIslandList = null;
+		pixelGraphList = null;
+		image = null;
+	}
+
 	private int getDefaultMaxIsland() {
 		return 3;
 	}
 
 	private void setIsland(int island) {
 		this.selectedIsland = island;
+		LOG.trace("PPxx "+this.hashCode()+" "+island);
 	}
 
 	public int getSelectedIsland() {