package edu.tamu.tcat.dia.morphological;

import edu.tamu.tcat.dia.binarization.BinaryImage;
import edu.tamu.tcat.dia.binarization.BooleanArrayBinaryImage;

public final class ExpansionOperator {

	private BinaryImage input;
	private int scaleFactor;
	private int width;
	private int height;
	private int scaledWidth;
	private int scaledHeight;
	private BooleanArrayBinaryImage output;

	public ExpansionOperator(BinaryImage source, int scaleFactor) {
		this.input = source;

		this.scaleFactor = scaleFactor;
		
		this.width = source.getWidth();
		this.height = source.getHeight();
		
		System.out.println("Expander Input: Height: "+height+", Width: "+width);
		//this.width = 2;
		//this.height =2;

		this.scaledWidth = (int) (width * Math.sqrt(scaleFactor));
		this.scaledHeight = (int) (height * Math.sqrt(scaleFactor));
		
		this.output = new BooleanArrayBinaryImage(scaledWidth, scaledHeight);
	}

	public BinaryImage run() {
		
		int pixelX = 0;
		int pixelY = 0;
		for (int rowIx = 0; rowIx < height; rowIx++) {
			//System.out.println("Processing row: "+rowIx);
			
			for (int colIx = 0; colIx < width; colIx++){
				//System.out.println("Processing col: "+colIx);
				if(input.isForeground(colIx, rowIx)){
					//Set foreground for 4 pixels
					pixelX = rowIx*2;
					pixelY = colIx*2;
					//System.out.println("Setting pixelX, pixelY: "+pixelX+","+pixelY+" index: "+(pixelX*scaledWidth+pixelY));
					output.setForeground(pixelX*scaledWidth+pixelY);
					pixelX = rowIx*2;
					pixelY = colIx*2+1;
					//System.out.println("Setting pixelX, pixelY: "+pixelX+","+pixelY+" index: "+((pixelX*scaledWidth+pixelY)));
					output.setForeground(pixelX*scaledWidth+pixelY);
					pixelX = rowIx*2+1;
					pixelY = colIx*2;	
					//System.out.println("Setting pixelX, pixelY: "+pixelX+","+pixelY+" index: "+((pixelX*scaledWidth)+pixelY));
					output.setForeground(pixelX*scaledWidth+pixelY);
					pixelX = rowIx*2+1;
					pixelY = colIx*2+1;	
					//System.out.println("Setting pixelX, pixelY: "+pixelX+","+pixelY+" index: "+((pixelX*scaledWidth)+pixelY));
					output.setForeground(pixelX*scaledWidth+pixelY);
					
				}
				
				
			}
			//System.out.println("=========================");
			
		}
		System.out.println("Expanded Height: "+output.getHeight()+", width: "+output.getWidth());
		return output;

	}
}

@@ -37,16 +37,52 @@
 cal;%0D%0A%0D%0A
+import java.util.logging.Logger;%0D%0A%0D%0A
 import e
@@ -429,16 +429,112 @@
 utput;%0D%0A
+%09private final static Logger logger = Logger.getLogger(%22edu.tamu.tcat.dia.morph.expansion%22);%0D%0A%0D%0A
 %0D%0A%09publi
@@ -736,34 +736,27 @@
 %0D%0A%09%09%0D%0A%09%09
-System.out.println
+logger.fine
 (%22Expand
@@ -807,52 +807,8 @@
 );%0D%0A
-%09%09//this.width = 2;%0D%0A%09%09//this.height =2;%0D%0A%0D%0A
 %09%09th
@@ -1138,34 +1138,27 @@
 %7B%0D%0A%09%09%09//
-System.out.println
+logger.fine
 (%22Proces
@@ -1238,34 +1238,29 @@
 %0D%0A%09%09%09%09//
-System.out.println
+logger.finest
 (%22Proces
@@ -1414,34 +1414,29 @@
 %0A%09%09%09%09%09//
-System.out.println
+logger.finest
 (%22Settin
@@ -1627,34 +1627,29 @@
 %0A%09%09%09%09%09//
-System.out.println
+logger.finest
 (%22Settin
@@ -1843,34 +1843,29 @@
 %0A%09%09%09%09%09//
-System.out.println
+logger.finest
 (%22Settin
@@ -2061,34 +2061,29 @@
 %0A%09%09%09%09%09//
-System.out.println
+logger.finest
 (%22Settin
@@ -2258,90 +2258,28 @@
 %0A%09%09%09
-//System.out.println(%22=========================%22);%0D%0A%09%09%09%0D%0A%09%09%7D%0D%0A%09%09System.out.println
+%0D%0A%09%09%7D%0D%0A%09%09logger.fine
 (%22Ex

Set up logging