CDMS/src/CDMS/ImageNavigatorII
diff -u -r1.8 -r1.9
--- Stitcher.java 7 Aug 2010 18:29:20 -0000 1.8
+++ Stitcher.java 9 Sep 2010 16:11:11 -0000 1.9
@@ -36,7 +36,6 @@
String savePath = "/"+getArg(inFile, "save_path");
String autorunFile = getArg(inFile, "autorun_file");
String imageFileName = "/"+getArg(inFile, "image_name");
- double theta = 0; try {theta = Double.parseDouble(getArg(inFile,"theta")); } catch (Exception e) {}
double pxSize = 0.001397; try {pxSize = Double.parseDouble(getArg(inFile,"pixel_size")); } catch (Exception e) {}
String[] blanksList = getArg(inFile, "blanks").split(",");
int[] blanks = new int[blanksList.length];
@@ -45,7 +44,9 @@
}
int tileW = 2048; try{tileW = Integer.parseInt(getArg(inFile, "tile_width"));} catch (Exception e) {}
int tileH = 2048; try{tileH = Integer.parseInt(getArg(inFile, "tile_height"));} catch (Exception e) {}
-
+
+ String outFile = "";
+
//read in the file and create a list of command lines (split by SET_PART_REPEAT)(dont use arg 0)
String[] lines = getLines(imagePath+"/"+autorunFile,"SET_PART_REPEAT");
@@ -77,8 +78,8 @@
double dX = moveX.get(0)/pxSize;
double dY = (ymins.get(0)-ymins.get(1))/pxSize;
//find size of total stitched image
- double totalW = (maxCols-1)*dX + imgW*Math.cos(theta) + imgH*Math.sin(theta);
- double totalH = (lines.length-1)*dX + imgW*Math.sin(theta) + imgH*Math.cos(theta);
+ double totalW = (maxCols-1)*dX + imgW;
+ double totalH = (lines.length-1)*dX + imgH;
/*********************/
//make flat field matrix averaging matrix
@@ -131,6 +132,9 @@
int[][] layers = new int[tileW][tileH];
int lastImage = 0;
boolean draw = false;
+ boolean foundCenter = false;
+ String centerX = "n/a";
+ String centerY = "n/a";
//loop through all images using cols and rows from the autorun file
for (int r=0; r<lines.length-1; r++) {
int nCols = cols.get(r)+1;
@@ -140,13 +144,20 @@
double maxTileRenderX = (col+1)*tileW+imgW;
double minTileRenderY = row*tileW-imgH;
double maxTileRenderY = (row+1)*tileW+imgH;
- double drawX = c*dX*Math.cos(theta)+(xmins.get(r)-xMin)/pxSize;
- double drawY = r*dY+c*dX*Math.sin(theta);
+ double drawX = c*dX+(xmins.get(r)-xMin)/pxSize;
+ double drawY = r*dY;
lastImage++;
//if it is in the tile, make a square with the image tilted appropriately
if (drawX>minTileRenderX && drawX<maxTileRenderX && drawY>minTileRenderY && drawY<maxTileRenderY) {
image = ImageIO.read(new File(imagePath+"/"+imageFileName.replace("%",""+lastImage)));
WritableRaster imgRaster = image.getRaster();
+
+ //find coordinates of center of tile
+ if (foundCenter == false) {
+ centerX = ""+( (xmins.get(r)/pxSize+c*dX) - (drawX-col*tileW) + tileW/2 );
+ centerY = ""+( ymins.get(r) - (drawY-row*tileH) +tileH/2 );
+ foundCenter = true;
+ }
//write the image to toStore, averaging with any values already there (for each cell write to pixel)
for (int y=0; y < imgH; ++y) {
@@ -174,6 +185,7 @@
}
}
if (draw==true) ImageIO.write(toStore, "PNG", new File(savePath+"/stitched_images/"+row+"_"+col+".png"));
+ outFile += (""+row+"_"+col+"\t"+centerX+"\t"+centerY+"\n");
}
}
@@ -181,6 +193,11 @@
System.out.println("\nRuntime: "+(endDate.getTime()-startDate.getTime())/1000/60);
//writes data needed for Tiler.java to info.txt
try {
+ BufferedWriter outprint = new BufferedWriter(new FileWriter(savePath+"/out.txt"));
+ outprint.write(outFile);
+ outprint.close();
+ } catch (IOException e) {System.out.println("Could not create out.txt:\n"+e);}//writes stats about each tile to out.txt
+ try {
BufferedWriter outprint = new BufferedWriter(new FileWriter(savePath+"/info.txt"));
outprint.write(Math.ceil(totalW/tileW)+"\n"+Math.ceil(totalH/tileH)+"\n"+tileW+"\n"+tileH+"\n"+savePath);
outprint.close();