Skip to content

Commit

Permalink
#6 perf short circuit for duplication processor
Browse files Browse the repository at this point in the history
  • Loading branch information
obriensystems committed Oct 1, 2018
1 parent d4e1545 commit 6e769e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

public class DuplicationProcessor extends ImageProcessor {

public static final int PIXEL_DIFF_THRESHOLD = 10;
@Override
public void run() {
}
Expand Down Expand Up @@ -148,14 +149,14 @@ public void process(String site, String anInputDir) {//, String anOutputDir) {
prev = input;
} else {
// need to solve interleaved out of order in ecan_2012_02_16_19_10_1070_100
int diff = isDifferent(prev, input,10);
int diff = isDifferent(prev, input,PIXEL_DIFF_THRESHOLD);
if(diff < 1) {
//System.out.println("Removing: " + filename);
System.out.print("x");
//deleteImage(outputPath,"jpg");
files[i].delete();
} else {
if(diff < 10) {
if(diff < PIXEL_DIFF_THRESHOLD) {
System.out.print("Z");
} else {
//writeImage(input, outputPath, "jpg");
Expand Down Expand Up @@ -235,7 +236,7 @@ public static void main(String[] args) {

DuplicationProcessor processor = new DuplicationProcessor();
//site = "xwl";
for(int i=0;i<sites.length;i++) {
/* for(int i=0;i<sites.length;i++) {
processor.merge(sites[i],
"/Volumes/8tb/_radar_unprocessed_image_to_persist", // to
// "/Volumes/ppro2/_radar_unprocessed_image_to_persist" // from
Expand All @@ -244,10 +245,10 @@ public static void main(String[] args) {
"/Volumes/Untitled/_to_process/biomos14/_radar_unprocessed_image_to_persist"
);
}
for(int i=0;i<sitesSat.length;i++) {
*/ for(int i=0;i<sitesSat.length;i++) {
////processor.process(site,"/_radar_unprocessed_image_to_persist", "/Users/michaelobrien/_filtered_data/");
//processor.process(sitesSat[i],"F:/_radar_unprocessed_image_to_persist");//, "/Volumes/gdrive2/_filtered_data/");
// processor.process(sitesSat[i],"/Users/michaelobrien/_radar_unprocessed_image_to_persist");//, "/Volumes/gdrive2/_filtered_data_mbp/");
processor.process(sitesSat[i],"e:/_radar_unprocessed_image_to_persist");//, "/Volumes/gdrive2/_filtered_data/");
//processor.process(sitesSat[i],"e:/Users/michaelobrien/_radar_unprocessed_image_to_persist");//, "/Volumes/gdrive2/_filtered_data_mbp/");
//processor.process(site,"/Volumes/Untitled/_to_process/biomos14/_radar_unprocessed_image_to_persist/", "/Volumes/8tb/_radar_unprocessed_image_to_persist/");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,10 @@ public int isDifferent(BufferedImage prevImage, BufferedImage nextImage, int pix
for(int x=0;x<prevImage.getWidth();x++) {
if(prevImage.getRGB(x, y) != nextImage.getRGB(x, y)) {
pixelsDifferent += 1;
/*if(pixelsDifferent > pixelDiffThreashold) {
// perf: short circuit
if(pixelsDifferent > pixelDiffThreashold) {
return pixelsDifferent;
}*/
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ public static void main(String[] args) {

// don't use use DuplicationProcessor
//processor.process(site,"/_radar_unprocessed_image_to_persist", "/Users/michaelobrien/_filtered_data/");
processor.process(site,"/Volumes/Untitled/_to_process/biomos14/_radar_unprocessed_image_to_persist/", "/Volumes/8tb/_radar_unprocessed_image_to_persist/");
processor.process(site,"/Volumes/Untitled/_to_process/biomos14/_radar_unprocessed_image_to_persist/",
"/Volumes/8tb/_radar_unprocessed_image_to_persist/");
}


Expand Down

0 comments on commit 6e769e0

Please sign in to comment.