Permalink
Browse files

cleanup seamcarving example

  • Loading branch information...
1 parent c051d47 commit 56283b5e59af411fbe63aa3d075a0817dc72b9fe Greg Borenstein committed Nov 5, 2012
Showing with 119 additions and 70 deletions.
  1. BIN distribution/DynamicProgramming-1/download/DynamicProgramming-1.zip
  2. BIN distribution/DynamicProgramming-1/download/DynamicProgramming.zip
  3. +30 −19 distribution/DynamicProgramming-1/examples/SeamCarvingExample/SeamCarvingExample.pde
  4. +14 −0 distribution/DynamicProgramming-1/examples/SequenceAlignmentExample/SequenceAlignmentExample.pde
  5. +5 −5 distribution/DynamicProgramming-1/examples/SubsequenceExample/SubsequenceExample.pde
  6. +1 −1 distribution/DynamicProgramming-1/reference/allclasses-frame.html
  7. +1 −1 distribution/DynamicProgramming-1/reference/allclasses-noframe.html
  8. +1 −1 distribution/DynamicProgramming-1/reference/constant-values.html
  9. +1 −1 distribution/DynamicProgramming-1/reference/deprecated-list.html
  10. +1 −1 distribution/DynamicProgramming-1/reference/dynamicprogramming/Cell.html
  11. +1 −1 distribution/DynamicProgramming-1/reference/dynamicprogramming/DynamicProgramming.html
  12. +1 −1 distribution/DynamicProgramming-1/reference/dynamicprogramming/LongestCommonSubsequence.html
  13. +1 −1 distribution/DynamicProgramming-1/reference/dynamicprogramming/SeamCarving.html
  14. +1 −1 distribution/DynamicProgramming-1/reference/dynamicprogramming/SequenceAlignment.html
  15. +1 −1 distribution/DynamicProgramming-1/reference/dynamicprogramming/SmithWaterman.html
  16. +1 −1 distribution/DynamicProgramming-1/reference/dynamicprogramming/package-frame.html
  17. +1 −1 distribution/DynamicProgramming-1/reference/dynamicprogramming/package-summary.html
  18. +1 −1 distribution/DynamicProgramming-1/reference/dynamicprogramming/package-tree.html
  19. +1 −1 distribution/DynamicProgramming-1/reference/help-doc.html
  20. +1 −1 distribution/DynamicProgramming-1/reference/index-all.html
  21. +1 −1 distribution/DynamicProgramming-1/reference/index.html
  22. +1 −1 distribution/DynamicProgramming-1/reference/overview-tree.html
  23. +30 −19 examples/SeamCarvingExample/SeamCarvingExample.pde
  24. +14 −0 examples/SequenceAlignmentExample/SequenceAlignmentExample.pde
  25. +5 −5 examples/SubsequenceExample/SubsequenceExample.pde
  26. +0 −1 src/dynamicprogramming/DynamicProgramming.java
  27. +2 −2 src/dynamicprogramming/LongestCommonSubsequence.java
  28. +2 −2 src/dynamicprogramming/SmithWaterman.java
@@ -3,48 +3,60 @@ import dynamicprogramming.*;
SeamCarving carver;
ArrayList<PVector> seam;
-PImage img, demoImage, weightImage, scoreImage;
+PImage img, energyImage, scoreImage;
void setup() {
img = loadImage("arch_sunset.jpg");
- demoImage = loadImage("arch_sunset.jpg");
- size(img.width*4,img.height);
+ size(img.width*3,img.height);
println(img.width + " " + img.height);
carver = new SeamCarving(this, img);
seam = carver.findMinSeam();
- println("calculating gradient image");
- weightImage = carver.getGradientImage();
- println("calculating image");
+ println("calculating energy image");
+ energyImage = carver.getGradientImage();
+
+ println("calculating score image");
scoreImage = carver.getScoreImage();
- image(scoreImage,0,0);
+ image(scoreImage,img.width,0);
}
boolean newSeam = false;
void draw() {
- // background(255,0,0);
- image(weightImage,demoImage.width*2,0);
-
+ // draw a white "background"
+ // behind the final result (since it shrinks)
fill(255);
noStroke();
- rect(demoImage.width,0, demoImage.width, demoImage.height);
- image(img, demoImage.width,0);
- stroke(255,0,0);
+ rect(energyImage.width*2, 0, energyImage.width, img.height);
+
+ image(energyImage, 0, 0);
+ image(img, energyImage.width*2, 0);
+
if(newSeam){
- //image(scoreImage, 0,0 );
+ pushMatrix();
+ translate(energyImage.width,0);
+ // draw a white "background"
+ // behind the energy image (since it also shrinks)
+ fill(255);
+ noStroke();
+ rect(0, 0, energyImage.width, img.height);
+
+ // draw the score image
+ image(scoreImage, 0,0 );
+
+ // draw the next seam to remove
+ stroke(255,0,0);
for(PVector p : seam){
point(p.x, p.y);
}
-
+ popMatrix();
newSeam = false;
}
-
}
void keyPressed(){
@@ -56,8 +68,7 @@ void keyPressed(){
seam = carver.findMinSeam();
newSeam = true;
-
- //println("calculating score image");
- //scoreImage = carver.getScoreImage();
+ println("calculating score image");
+ scoreImage = carver.getScoreImage();
}
@@ -0,0 +1,14 @@
+import dynamicprogramming.*;
+
+SmithWaterman align;
+String text1 = "GCCCTAGCG";
+String text2 = "GCGC-AATG";
+
+void setup(){
+ align = new SmithWaterman(text1, text2);
+ println(align.getAlignment());
+ println(align.getAlignmentScore());
+}
+
+void draw(){
+}
@@ -6,12 +6,12 @@ String text2 = "GCGCAATG";
LongestCommonSubsequence lcs;
-void setup(){
- size(500,500);
+void setup() {
+ size(500, 500);
lcs = new LongestCommonSubsequence(text1, text2);
- println(lcs.getLongestCommonSubsequence);
+ println(lcs.getLongestCommonSubsequence());
}
-void draw(){
-
+void draw() {
}
+
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:08 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:22 EST 2012 -->
<TITLE>
All Classes (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:08 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:22 EST 2012 -->
<TITLE>
All Classes (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:07 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
Constant Field Values (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:08 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:22 EST 2012 -->
<TITLE>
Deprecated List (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:04 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
Cell (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:06 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
DynamicProgramming (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:06 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
LongestCommonSubsequence (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:07 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
SeamCarving (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:07 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
SequenceAlignment (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:07 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
SmithWaterman (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:07 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
dynamicprogramming (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:07 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
dynamicprogramming (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:07 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
dynamicprogramming Class Hierarchy (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:08 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:22 EST 2012 -->
<TITLE>
API Help (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:07 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
Index (Javadocs: DynamicProgramming)
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc on Mon Nov 05 04:42:08 EST 2012-->
+<!-- Generated by javadoc on Mon Nov 05 12:04:22 EST 2012-->
<TITLE>
Javadocs: DynamicProgramming
</TITLE>
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 04:42:07 EST 2012 -->
+<!-- Generated by javadoc (build 1.6.0_33) on Mon Nov 05 12:04:21 EST 2012 -->
<TITLE>
Class Hierarchy (Javadocs: DynamicProgramming)
</TITLE>
@@ -3,48 +3,60 @@ import dynamicprogramming.*;
SeamCarving carver;
ArrayList<PVector> seam;
-PImage img, demoImage, weightImage, scoreImage;
+PImage img, energyImage, scoreImage;
void setup() {
img = loadImage("arch_sunset.jpg");
- demoImage = loadImage("arch_sunset.jpg");
- size(img.width*4,img.height);
+ size(img.width*3,img.height);
println(img.width + " " + img.height);
carver = new SeamCarving(this, img);
seam = carver.findMinSeam();
- println("calculating gradient image");
- weightImage = carver.getGradientImage();
- println("calculating image");
+ println("calculating energy image");
+ energyImage = carver.getGradientImage();
+
+ println("calculating score image");
scoreImage = carver.getScoreImage();
- image(scoreImage,0,0);
+ image(scoreImage,img.width,0);
}
boolean newSeam = false;
void draw() {
- // background(255,0,0);
- image(weightImage,demoImage.width*2,0);
-
+ // draw a white "background"
+ // behind the final result (since it shrinks)
fill(255);
noStroke();
- rect(demoImage.width,0, demoImage.width, demoImage.height);
- image(img, demoImage.width,0);
- stroke(255,0,0);
+ rect(energyImage.width*2, 0, energyImage.width, img.height);
+
+ image(energyImage, 0, 0);
+ image(img, energyImage.width*2, 0);
+
if(newSeam){
- //image(scoreImage, 0,0 );
+ pushMatrix();
+ translate(energyImage.width,0);
+ // draw a white "background"
+ // behind the energy image (since it also shrinks)
+ fill(255);
+ noStroke();
+ rect(0, 0, energyImage.width, img.height);
+
+ // draw the score image
+ image(scoreImage, 0,0 );
+
+ // draw the next seam to remove
+ stroke(255,0,0);
for(PVector p : seam){
point(p.x, p.y);
}
-
+ popMatrix();
newSeam = false;
}
-
}
void keyPressed(){
@@ -56,8 +68,7 @@ void keyPressed(){
seam = carver.findMinSeam();
newSeam = true;
-
- //println("calculating score image");
- //scoreImage = carver.getScoreImage();
+ println("calculating score image");
+ scoreImage = carver.getScoreImage();
}
@@ -0,0 +1,14 @@
+import dynamicprogramming.*;
+
+SmithWaterman align;
+String text1 = "GCCCTAGCG";
+String text2 = "GCGC-AATG";
+
+void setup(){
+ align = new SmithWaterman(text1, text2);
+ println(align.getAlignment());
+ println(align.getAlignmentScore());
+}
+
+void draw(){
+}
@@ -6,12 +6,12 @@ String text2 = "GCGCAATG";
LongestCommonSubsequence lcs;
-void setup(){
- size(500,500);
+void setup() {
+ size(500, 500);
lcs = new LongestCommonSubsequence(text1, text2);
- println(lcs.getLongestCommonSubsequence);
+ println(lcs.getLongestCommonSubsequence());
}
-void draw(){
-
+void draw() {
}
+
Oops, something went wrong.

0 comments on commit 56283b5

Please sign in to comment.