Skip to content

Commit

Permalink
Hadoop pipeline complete
Browse files Browse the repository at this point in the history
  • Loading branch information
mchow101 committed Aug 3, 2020
1 parent 309d169 commit 491e785
Show file tree
Hide file tree
Showing 76 changed files with 141 additions and 490 deletions.
8 changes: 0 additions & 8 deletions extract_detect/Hadoop/.goutputstream-MTYAO0

This file was deleted.

Binary file removed extract_detect/Hadoop/Box.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Calc.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Centroid.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Cluster.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/ColorEdit.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Constants$Stage.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Constants.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Convert.class
Binary file not shown.
6 changes: 6 additions & 0 deletions extract_detect/Hadoop/Convert.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public static double[][] convertImageCompress(String name, int scale) throws IOE
return out;
}

/**
* Returns a double array of an image with each cell representing a pixel
*
* @param image
* @return the 2D double array representing the image
*/
public static double[][] convertByte(byte[][] image) {
double[][] out = new double[image.length][image[0].length];
for (int x = 0; x < image.length; x++) {
Expand Down
Binary file removed extract_detect/Hadoop/Converter.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/DigitalPicture.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Extract.class
Binary file not shown.
31 changes: 17 additions & 14 deletions extract_detect/Hadoop/Extract.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Arrays;

/**
* Hadoop with MapReduce, image only version
* Extracts image and metadata from MSTIFF
*
*/
public class Extract {
Expand Down Expand Up @@ -63,7 +63,8 @@ public class Extract {
private static long[] Fatho_timestamp_sec;

// Save
public static byte[][] imTemp;
public static byte[][] imTempR;
public static byte[][] imTempL;
public static String[][] metaTemp;
private static String lastFile;

Expand Down Expand Up @@ -98,7 +99,8 @@ public static boolean init() {
fileHeader[0][6] = "WaterDepth";
fileHeader[0][7] = "TowfishDepth";

imTemp = new byte[0][0];
imTempR = new byte[0][0];
imTempL = new byte[0][0];
metaTemp = new String[0][0];
lastFile = "empty";
count = 0;
Expand Down Expand Up @@ -225,7 +227,7 @@ public static boolean fileProcess(String x) throws IOException {
Extract.metaInit();

// Check if first
if (imTemp == null)
if (imTempR == null)
init();

// Save if last of mission
Expand Down Expand Up @@ -254,14 +256,15 @@ public static boolean fileProcess(String x) throws IOException {
}

// Combine left and right channels, previous image
if (imTemp.length != 0) {
imTemp = Util.combineVertically(imTemp, Util.combineHorizontally(left, right));
if (imTempR.length != 0) {
imTempR = Util.combineVertically(imTempR, right);
imTempL = Util.combineVertically(imTempL, left);
saveIm();
System.out.println("saveIm should have ran");
imTemp = Util.combineHorizontally(left, right);
imTempR = right;
imTempL = left;
} else {
System.out.println("saveIm should have ran");
imTemp = Util.combineHorizontally(left, right);
imTempR = right;
imTempL = left;
}

// Add metadata to growing table
Expand All @@ -278,17 +281,17 @@ public static boolean fileProcess(String x) throws IOException {
* Save image
*/
public static void saveIm() {
Util.saveIm(imTemp, "im" + count, false);
System.out.println("saveIm" + count);
Util.saveIm(Util.combineHorizontally(imTempL, imTempR), "im" + count, false);
count++;
}

/**
* Save metadata as CSV
*/
public static void saveMeta() throws IOException {
// Util.saveIm(imTemp, "im" + count);
imTemp = new byte[0][0];
// Util.saveIm(imTempR, "im" + count);
imTempR = new byte[0][0];
imTempL = new byte[0][0];
String tempLabel = Util.remPath(lastFile);
Util.save(metaTemp, tempLabel + "META");
metaTemp = new String[0][0];
Expand Down
Binary file removed extract_detect/Hadoop/Format.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/ImageArrEdit.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/LightPoint.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/MacroMaster.class
Binary file not shown.
39 changes: 17 additions & 22 deletions extract_detect/Hadoop/MacroMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,51 @@
*
*/
public class MacroMaster {

static byte[][] im;
static String name;
static int dim = 200;

static boolean lastVal = false;

public static byte[][] findMine(byte[][] imTemp, String nameSet) throws IOException {
init(imTemp, nameSet);
static byte[][] imL;
static byte[][] imR;
static byte[][] im;
static int dim = 150;

public static boolean findMine(byte[][] imTemp, char side) throws IOException {
im = imTemp;
boolean[][][] layers;
boolean[][] bmap;

// find dark spots
Slide.init(im, dim, true);
layers = new boolean[2][Slide.bmap.length][Slide.bmap[0].length];

Slide.process();
layers[0] = Slide.bmap;

// find light spots
Slide.init(im, dim, false);
Slide.process();
layers[1] = Slide.bmap;

byte[][] imOut = new byte[imTemp.length][imTemp[0].length];

// find overlapping areas
bmap = new boolean[layers[0].length][layers[0][0].length];
for (int r = 0; r < bmap.length; r++) {
for (int c = 0; c < bmap[0].length; c++) {
bmap[r][c] = layers[0][r][c] && layers[1][r][c];
if(bmap[r][c]) System.out.println(r + ", " + c);

// identify bounds of frame on original image and highlight if needed
int[] temp = Util.refitRect(r, c, bmap[0].length, bmap.length, imTemp[0].length, imTemp.length);
for (int x = temp[1]; x < (temp[3] < imTemp.length ? temp[3] : imTemp.length); x++) {
for (int y = temp[0]; y < (temp[2] < imTemp[0].length ? temp[2] : imTemp[0].length); y++) {
if (bmap[r][c]) imOut[x][y] = (byte)(Util.getByteVal(imTemp[x][y]) > 150 ? 255 : Util.getByteVal(imTemp[x][y]) + 100);
if (bmap[r][c]) { imOut[x][y] = (byte)(Util.getByteVal(imTemp[x][y]) > 150 ? 255 : Util.getByteVal(imTemp[x][y]) + 100); }
else imOut[x][y] = imTemp[x][y];
// System.out.println(x + " " + y);
}
}
}
}
}

Util.saveIm(imOut, nameSet, false);
if (side == 'L') imL = imOut;
else imR = imOut;

lastVal = Calc.containsTrue(bmap);

return imOut;
}

public static void init(byte[][] imSet, String nameSet) {

im = imSet;
name = nameSet;
return Calc.containsTrue(bmap);
}
}
Binary file removed extract_detect/Hadoop/Master.class
Binary file not shown.
4 changes: 1 addition & 3 deletions extract_detect/Hadoop/Master.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.io.FileNotFoundException;

import java.io.IOException;

/**
Expand Down Expand Up @@ -49,7 +47,7 @@ public static boolean process(double[][] vals) {
int cenN;

tmap = Converter.convert(vals);
double minP = dark ? 28.3 : 20;
double minP = dark ? 28.1 : 22.5;
rmap = Scan(tmap, 3, minP);
rmap = ColorReduce(rmap, Scan.cenN);
bmap = Converter.convert(rmap);
Expand Down
Binary file removed extract_detect/Hadoop/Picture.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/PictureFrame.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Pixel.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Point.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Polish.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Radius.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed extract_detect/Hadoop/Runner$Sonar_Mapper.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Runner$Sonar_Reducer.class
Binary file not shown.
Binary file not shown.
Binary file removed extract_detect/Hadoop/Runner.class
Binary file not shown.
Binary file removed extract_detect/Hadoop/Runner.jar
Binary file not shown.
Loading

0 comments on commit 491e785

Please sign in to comment.