diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5281b7c --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +.project +.metadata +bin/** +tmp/** +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath +distribution/Channels* + +*.svn* + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..70a38b5 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +## Processing-DynamicProgramming + +This is a Processing library that implements the Dynamic Programming optimized search technique along with a few of its fun applications. + +It mainly based on [this tutorial by Paul Reiners](http://www.ibm.com/developerworks/java/library/j-seqalign/index.html) and the accompanying code (with some modifications). + +So far, the coolest application (partially) implemented is Seam Carving, which is a technique for resizing images by removing their least interesting pixels. This isn't quite working yet but you can see the SeamCarvingExample for how it will work when it's done. \ No newline at end of file diff --git a/data/README b/data/README new file mode 100644 index 0000000..c8df238 --- /dev/null +++ b/data/README @@ -0,0 +1,7 @@ +the data folder: +If your library is using files like images, sound files, +any data file, etc., put them into the data folder. +When coding your library you can use processing's internal loading +functions like loadImage(), loadStrings(), etc. to load files +located inside the data folder into your library. + diff --git a/distribution/DynamicProgramming-1/INSTALL.txt b/distribution/DynamicProgramming-1/INSTALL.txt new file mode 100644 index 0000000..74ec61d --- /dev/null +++ b/distribution/DynamicProgramming-1/INSTALL.txt @@ -0,0 +1,46 @@ +How to install library DynamicProgramming + + +Install with the "Add Library..." tool + +New for Processing 2.0: Add contributed libraries by selecting "Add Library..." +from the "Import Library..." submenu within the Sketch menu. Not all available +libraries have been converted to show up in this menu. If a library isn't there, +it will need to be installed manually by following the instructions below. + + +Manual Install + +Contributed libraries may be downloaded separately and manually placed within +the "libraries" folder of your Processing sketchbook. To find (and change) the +Processing sketchbook location on your computer, open the Preferences window +from the Processing application (PDE) and look for the "Sketchbook location" +item at the top. + +Copy the contributed library's folder into the "libraries" folder at this +location. You will need to create the "libraries" folder if this is your first +contributed library. + +By default the following locations are used for your sketchbook folder: + For Mac users, the sketchbook folder is located inside ~/Documents/Processing. + For Windows users, the sketchbook folder is located inside + 'My Documents'/Processing. + +The folder structure for library DynamicProgramming should be as follows: + +Processing + libraries + DynamicProgramming + examples + library + DynamicProgramming.jar + reference + src + +Some folders like "examples" or "src" might be missing. After library +DynamicProgramming has been successfully installed, restart the Processing +application. + + +If you're having trouble, have a look at the Processing Wiki for more +information: http://wiki.processing.org/w/How_to_Install_a_Contributed_Library diff --git a/distribution/DynamicProgramming-1/download/DynamicProgramming-1.txt b/distribution/DynamicProgramming-1/download/DynamicProgramming-1.txt new file mode 100644 index 0000000..da79a93 --- /dev/null +++ b/distribution/DynamicProgramming-1/download/DynamicProgramming-1.txt @@ -0,0 +1,49 @@ +# More on this file here: http://code.google.com/p/processing/wiki/LibraryBasics +# UTF-8 supported. + +# The name of your library as you want it formatted. +name = DynamicProgramming + +# List of authors. Links can be provided using the syntax [author name](url). +authorList = [Greg Borenstein](http://makematics.com) + +# A web page for your library, NOT a direct link to where to download it. +url = http://makematics.com/code/DynamicProgramming + +# The category of your library, must be one (or many) of the following: +# "3D" "Animation" "Compilations" "Data" +# "Fabrication" "Geometry" "GUI" "Hardware" +# "I/O" "Language" "Math" "Simulation" +# "Sound" "Utilities" "Typography" "Video & Vision" +# +# If a value other than those listed is used, your library will listed as +# "Other". +category = Other + +# A short sentence (or fragment) to summarize the library's function. This will +# be shown from inside the PDE when the library is being installed. Avoid +# repeating the name of your library here. Also, avoid saying anything redundant +# like mentioning that it's a library. This should start with a capitalized +# letter, and end with a period. +sentence = An implementation of the Dynamic Programming optimized search technique as well as a series of applications that take advantage of it such as image seam carving and textual sequence alignment. + +# Additional information suitable for the Processing website. The value of +# 'sentence' always will be prepended, so you should start by writing the +# second sentence here. If your library only works on certain operating systems, +# mention it here. +paragraph = + +# Links in the 'sentence' and 'paragraph' attributes can be inserted using the +# same syntax as for authors. +# That is, [here is a link to Processing](http://processing.org/) + + +# A version number that increments once with each release. This is used to +# compare different versions of the same library, and check if an update is +# available. You should think of it as a counter, counting the total number of +# releases you've had. +version = 1 # This must be parsable as an int + +# The version as the user will see it. If blank, the version attribute will be +# used here. +prettyVersion = 0.1.1 # This is treated as a String diff --git a/distribution/DynamicProgramming-1/download/DynamicProgramming-1.zip b/distribution/DynamicProgramming-1/download/DynamicProgramming-1.zip new file mode 100644 index 0000000..9f96748 Binary files /dev/null and b/distribution/DynamicProgramming-1/download/DynamicProgramming-1.zip differ diff --git a/distribution/DynamicProgramming-1/download/DynamicProgramming.txt b/distribution/DynamicProgramming-1/download/DynamicProgramming.txt new file mode 100644 index 0000000..da79a93 --- /dev/null +++ b/distribution/DynamicProgramming-1/download/DynamicProgramming.txt @@ -0,0 +1,49 @@ +# More on this file here: http://code.google.com/p/processing/wiki/LibraryBasics +# UTF-8 supported. + +# The name of your library as you want it formatted. +name = DynamicProgramming + +# List of authors. Links can be provided using the syntax [author name](url). +authorList = [Greg Borenstein](http://makematics.com) + +# A web page for your library, NOT a direct link to where to download it. +url = http://makematics.com/code/DynamicProgramming + +# The category of your library, must be one (or many) of the following: +# "3D" "Animation" "Compilations" "Data" +# "Fabrication" "Geometry" "GUI" "Hardware" +# "I/O" "Language" "Math" "Simulation" +# "Sound" "Utilities" "Typography" "Video & Vision" +# +# If a value other than those listed is used, your library will listed as +# "Other". +category = Other + +# A short sentence (or fragment) to summarize the library's function. This will +# be shown from inside the PDE when the library is being installed. Avoid +# repeating the name of your library here. Also, avoid saying anything redundant +# like mentioning that it's a library. This should start with a capitalized +# letter, and end with a period. +sentence = An implementation of the Dynamic Programming optimized search technique as well as a series of applications that take advantage of it such as image seam carving and textual sequence alignment. + +# Additional information suitable for the Processing website. The value of +# 'sentence' always will be prepended, so you should start by writing the +# second sentence here. If your library only works on certain operating systems, +# mention it here. +paragraph = + +# Links in the 'sentence' and 'paragraph' attributes can be inserted using the +# same syntax as for authors. +# That is, [here is a link to Processing](http://processing.org/) + + +# A version number that increments once with each release. This is used to +# compare different versions of the same library, and check if an update is +# available. You should think of it as a counter, counting the total number of +# releases you've had. +version = 1 # This must be parsable as an int + +# The version as the user will see it. If blank, the version attribute will be +# used here. +prettyVersion = 0.1.1 # This is treated as a String diff --git a/distribution/DynamicProgramming-1/download/DynamicProgramming.zip b/distribution/DynamicProgramming-1/download/DynamicProgramming.zip new file mode 100644 index 0000000..9f96748 Binary files /dev/null and b/distribution/DynamicProgramming-1/download/DynamicProgramming.zip differ diff --git a/distribution/DynamicProgramming-1/examples/SeamCarvingExample/SeamCarvingExample.pde b/distribution/DynamicProgramming-1/examples/SeamCarvingExample/SeamCarvingExample.pde new file mode 100644 index 0000000..f33c9f5 --- /dev/null +++ b/distribution/DynamicProgramming-1/examples/SeamCarvingExample/SeamCarvingExample.pde @@ -0,0 +1,29 @@ +import dynamicprogramming.*; + +SeamCarving carver; +ArrayList seam; + +PImage img; + +void setup() { + img = loadImage("arch_sunset.jpg"); + size(img.width,img.height); + + println(img.width + " " + img.height); + + carver = new SeamCarving(this, img); + seam = carver.findMinSeam(); +} + +void draw() { + image(img, 0,0); + stroke(255,0,0); + for(PVector p : seam){ + point(p.x, p.y); + } +} + +void keyPressed(){ + img = carver.removeColumn(); + carver.setImage(img); +} diff --git a/distribution/DynamicProgramming-1/examples/SeamCarvingExample/arch_sunset.jpg b/distribution/DynamicProgramming-1/examples/SeamCarvingExample/arch_sunset.jpg new file mode 100644 index 0000000..c0099b6 Binary files /dev/null and b/distribution/DynamicProgramming-1/examples/SeamCarvingExample/arch_sunset.jpg differ diff --git a/distribution/DynamicProgramming-1/index.html b/distribution/DynamicProgramming-1/index.html new file mode 100644 index 0000000..097d085 --- /dev/null +++ b/distribution/DynamicProgramming-1/index.html @@ -0,0 +1,137 @@ + + + +DynamicProgramming + + + + + + + + + + + + + + +
+ + + + + +
+ +
+

DynamicProgramming

+

+ A library by Greg Borenstein for the Processing programming environment.
+ Last update, 10/23/2012. +

+

+ An implementation of the Dynamic Programming optimized search technique as well as a series of applications that take advantage of it such as image seam carving and textual sequence alignment.
+
+ Feel free to replace this paragraph with a description of the library.
+ Contributed libraries are developed, documented, and maintained by members of the Processing community. Further directions are included with each library. For feedback and support, please post to the Discourse. We strongly encourage all libraries to be open source, but not all of them are. +

+
+ + + +
+

Download

+

+ Download DynamicProgramming version 0.1.1 (1) in + .zip format. +

+

Installation

+

+ Unzip and put the extracted DynamicProgramming folder into the libraries folder of your Processing sketches. Reference and examples are included in the DynamicProgramming folder. +

+
+ + +
+

Keywords. ?

+

Reference. Have a look at the javadoc reference here. A copy of the reference is included in the .zip as well.

+

Source. The source code of DynamicProgramming is available at Github, and its repository can be browsed here.

+
+ + +
+

Examples

+

Find a list of examples in the current distribution of DynamicProgramming, or have a look at them by following the links below.

+ +
+ + +
+

Tested

+

+ + Platform osx + + +
Processing 2.0b5 + + +
Dependencies ? +

+
+ + + + + + + + + + + + +
+
+ + +
+ + \ No newline at end of file diff --git a/distribution/DynamicProgramming-1/reference/allclasses-frame.html b/distribution/DynamicProgramming-1/reference/allclasses-frame.html new file mode 100644 index 0000000..07a57ed --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/allclasses-frame.html @@ -0,0 +1,35 @@ + + + + + + +All Classes (Javadocs: DynamicProgramming) + + + + + + + + + + + +All Classes +
+ + + + + +
Cell +
+DynamicProgramming +
+SeamCarving +
+
+ + + diff --git a/distribution/DynamicProgramming-1/reference/allclasses-noframe.html b/distribution/DynamicProgramming-1/reference/allclasses-noframe.html new file mode 100644 index 0000000..b6b0c21 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/allclasses-noframe.html @@ -0,0 +1,35 @@ + + + + + + +All Classes (Javadocs: DynamicProgramming) + + + + + + + + + + + +All Classes +
+ + + + + +
Cell +
+DynamicProgramming +
+SeamCarving +
+
+ + + diff --git a/distribution/DynamicProgramming-1/reference/constant-values.html b/distribution/DynamicProgramming-1/reference/constant-values.html new file mode 100644 index 0000000..fdbeb81 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/constant-values.html @@ -0,0 +1,170 @@ + + + + + + +Constant Field Values (Javadocs: DynamicProgramming) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Constant Field Values

+
+
+Contents + + + + + + +
+dynamicprogramming.*
+ +

+ + + + + + + + + + + + +
dynamicprogramming.DynamicProgramming
+public static final StringVERSION"0.1.1"
+ +

+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Processing library DynamicProgramming by Greg Borenstein. (C) 2012 + + diff --git a/distribution/DynamicProgramming-1/reference/deprecated-list.html b/distribution/DynamicProgramming-1/reference/deprecated-list.html new file mode 100644 index 0000000..8206258 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/deprecated-list.html @@ -0,0 +1,142 @@ + + + + + + +Deprecated List (Javadocs: DynamicProgramming) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Deprecated API

+
+
+Contents + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Processing library DynamicProgramming by Greg Borenstein. (C) 2012 + + diff --git a/distribution/DynamicProgramming-1/reference/dynamicprogramming/Cell.html b/distribution/DynamicProgramming-1/reference/dynamicprogramming/Cell.html new file mode 100644 index 0000000..86213b4 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/dynamicprogramming/Cell.html @@ -0,0 +1,447 @@ + + + + + + +Cell (Javadocs: DynamicProgramming) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +dynamicprogramming +
+Class Cell

+
+java.lang.Object
+  extended by dynamicprogramming.Cell
+
+
+
+
public class Cell
extends Object
+ + +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
Cell(int row, + int col) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intgetCol() + +
+           
+ CellgetPrevCell() + +
+           
+ intgetRow() + +
+           
+ intgetScore() + +
+           
+ booleanisLeftEdge() + +
+           
+ booleanisRightEdge() + +
+           
+ voidsetLeftEdge(boolean e) + +
+           
+ voidsetPrevCell(Cell prevCell) + +
+           
+ voidsetRightEdge(boolean e) + +
+           
+ voidsetScore(int score) + +
+           
+ StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+Cell

+
+public Cell(int row,
+            int col)
+
+
+ + + + + + + + +
+Method Detail
+ +

+isLeftEdge

+
+public boolean isLeftEdge()
+
+
+
+
+
+
+ +

+isRightEdge

+
+public boolean isRightEdge()
+
+
+
+
+
+
+ +

+setLeftEdge

+
+public void setLeftEdge(boolean e)
+
+
+
+
+
+
+ +

+setRightEdge

+
+public void setRightEdge(boolean e)
+
+
+
+
+
+
+ +

+setScore

+
+public void setScore(int score)
+
+
+
Parameters:
score - the score to set
+
+
+
+ +

+getScore

+
+public int getScore()
+
+
+ +
Returns:
the score
+
+
+
+ +

+setPrevCell

+
+public void setPrevCell(Cell prevCell)
+
+
+
Parameters:
prevCell - the prevCell to set
+
+
+
+ +

+getRow

+
+public int getRow()
+
+
+ +
Returns:
the row
+
+
+
+ +

+getCol

+
+public int getCol()
+
+
+ +
Returns:
the col
+
+
+
+ +

+getPrevCell

+
+public Cell getPrevCell()
+
+
+ +
Returns:
the prevCell
+
+
+
+ +

+toString

+
+public String toString()
+
+
+
Overrides:
toString in class Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Processing library DynamicProgramming by Greg Borenstein. (C) 2012 + + diff --git a/distribution/DynamicProgramming-1/reference/dynamicprogramming/DynamicProgramming.html b/distribution/DynamicProgramming-1/reference/dynamicprogramming/DynamicProgramming.html new file mode 100644 index 0000000..25cc0d1 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/dynamicprogramming/DynamicProgramming.html @@ -0,0 +1,295 @@ + + + + + + +DynamicProgramming (Javadocs: DynamicProgramming) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +dynamicprogramming +
+Class DynamicProgramming

+
+java.lang.Object
+  extended by dynamicprogramming.DynamicProgramming
+
+
+
Direct Known Subclasses:
SeamCarving
+
+
+
+
public abstract class DynamicProgramming
extends Object
+ + +

+This is a template class and can be used to start a new processing library or tool. + Make sure you rename this class as well as the name of the example package 'template' + to your own library or tool naming convention. +

+ +

+


+ +

+ + + + + + + + + + + +
+Field Summary
+static StringVERSION + +
+           
+  + + + + + + + + + + +
+Constructor Summary
DynamicProgramming(int tableWidth, + int tableHeight) + +
+           
+  + + + + + + + + + + + +
+Method Summary
+ int[][]getScoreTable() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+VERSION

+
+public static final String VERSION
+
+
+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+DynamicProgramming

+
+public DynamicProgramming(int tableWidth,
+                          int tableHeight)
+
+
+ + + + + + + + +
+Method Detail
+ +

+getScoreTable

+
+public int[][] getScoreTable()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Processing library DynamicProgramming by Greg Borenstein. (C) 2012 + + diff --git a/distribution/DynamicProgramming-1/reference/dynamicprogramming/SeamCarving.html b/distribution/DynamicProgramming-1/reference/dynamicprogramming/SeamCarving.html new file mode 100644 index 0000000..557204a --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/dynamicprogramming/SeamCarving.html @@ -0,0 +1,377 @@ + + + + + + +SeamCarving (Javadocs: DynamicProgramming) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +dynamicprogramming +
+Class SeamCarving

+
+java.lang.Object
+  extended by dynamicprogramming.DynamicProgramming
+      extended by dynamicprogramming.SeamCarving
+
+
+
+
public class SeamCarving
extends DynamicProgramming
+ + +

+


+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from class dynamicprogramming.DynamicProgramming
VERSION
+  + + + + + + + + + + +
+Constructor Summary
SeamCarving(PApplet parent, + PImage img) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ ArrayList<PVector>findMinSeam() + +
+           
+ float[][]getWeights() + +
+           
+ floatpixelGradient(PImage img, + int x, + int y) + +
+           
+ float[][]pixelGradients(PImage original) + +
+           
+ PImageremoveColumn() + +
+           
+ voidsetImage(PImage img) + +
+           
+ + + + + + + +
Methods inherited from class dynamicprogramming.DynamicProgramming
getScoreTable
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+SeamCarving

+
+public SeamCarving(PApplet parent,
+                   PImage img)
+
+
+ + + + + + + + +
+Method Detail
+ +

+setImage

+
+public void setImage(PImage img)
+
+
+
+
+
+
+ +

+removeColumn

+
+public PImage removeColumn()
+
+
+
+
+
+
+ +

+findMinSeam

+
+public ArrayList<PVector> findMinSeam()
+
+
+
+
+
+
+ +

+getWeights

+
+public float[][] getWeights()
+
+
+
+
+
+
+ +

+pixelGradients

+
+public float[][] pixelGradients(PImage original)
+
+
+
+
+
+
+ +

+pixelGradient

+
+public float pixelGradient(PImage img,
+                           int x,
+                           int y)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Processing library DynamicProgramming by Greg Borenstein. (C) 2012 + + diff --git a/distribution/DynamicProgramming-1/reference/dynamicprogramming/package-frame.html b/distribution/DynamicProgramming-1/reference/dynamicprogramming/package-frame.html new file mode 100644 index 0000000..5a82793 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/dynamicprogramming/package-frame.html @@ -0,0 +1,36 @@ + + + + + + +dynamicprogramming (Javadocs: DynamicProgramming) + + + + + + + + + + + +dynamicprogramming + + + + +
+Classes  + +
+Cell +
+DynamicProgramming +
+SeamCarving
+ + + + diff --git a/distribution/DynamicProgramming-1/reference/dynamicprogramming/package-summary.html b/distribution/DynamicProgramming-1/reference/dynamicprogramming/package-summary.html new file mode 100644 index 0000000..f9a7a13 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/dynamicprogramming/package-summary.html @@ -0,0 +1,161 @@ + + + + + + +dynamicprogramming (Javadocs: DynamicProgramming) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package dynamicprogramming +

+ + + + + + + + + + + + + + + + + +
+Class Summary
Cell 
DynamicProgrammingThis is a template class and can be used to start a new processing library or tool.
SeamCarving 
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Processing library DynamicProgramming by Greg Borenstein. (C) 2012 + + diff --git a/distribution/DynamicProgramming-1/reference/dynamicprogramming/package-tree.html b/distribution/DynamicProgramming-1/reference/dynamicprogramming/package-tree.html new file mode 100644 index 0000000..317eda1 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/dynamicprogramming/package-tree.html @@ -0,0 +1,148 @@ + + + + + + +dynamicprogramming Class Hierarchy (Javadocs: DynamicProgramming) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package dynamicprogramming +

+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Processing library DynamicProgramming by Greg Borenstein. (C) 2012 + + diff --git a/distribution/DynamicProgramming-1/reference/help-doc.html b/distribution/DynamicProgramming-1/reference/help-doc.html new file mode 100644 index 0000000..858dcff --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/help-doc.html @@ -0,0 +1,209 @@ + + + + + + +API Help (Javadocs: DynamicProgramming) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

+
+

+Class/Interface

+
+ +

+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+ +

+Annotation Type

+
+ +

+Each annotation type has its own separate page with the following sections:

+
+ +

+Enum

+
+ +

+Each enum has its own separate page with the following sections:

+
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object. +
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+

+Constant Field Values

+The Constant Field Values page lists the static final fields and their values. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Processing library DynamicProgramming by Greg Borenstein. (C) 2012 + + diff --git a/distribution/DynamicProgramming-1/reference/index-all.html b/distribution/DynamicProgramming-1/reference/index-all.html new file mode 100644 index 0000000..dec1f92 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/index-all.html @@ -0,0 +1,249 @@ + + + + + + +Index (Javadocs: DynamicProgramming) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +C D F G I P R S T V
+

+C

+
+
Cell - Class in dynamicprogramming
 
Cell(int, int) - +Constructor for class dynamicprogramming.Cell +
  +
+
+

+D

+
+
dynamicprogramming - package dynamicprogramming
 
DynamicProgramming - Class in dynamicprogramming
This is a template class and can be used to start a new processing library or tool.
DynamicProgramming(int, int) - +Constructor for class dynamicprogramming.DynamicProgramming +
  +
+
+

+F

+
+
findMinSeam() - +Method in class dynamicprogramming.SeamCarving +
  +
+
+

+G

+
+
getCol() - +Method in class dynamicprogramming.Cell +
  +
getPrevCell() - +Method in class dynamicprogramming.Cell +
  +
getRow() - +Method in class dynamicprogramming.Cell +
  +
getScore() - +Method in class dynamicprogramming.Cell +
  +
getScoreTable() - +Method in class dynamicprogramming.DynamicProgramming +
  +
getWeights() - +Method in class dynamicprogramming.SeamCarving +
  +
+
+

+I

+
+
isLeftEdge() - +Method in class dynamicprogramming.Cell +
  +
isRightEdge() - +Method in class dynamicprogramming.Cell +
  +
+
+

+P

+
+
pixelGradient(PImage, int, int) - +Method in class dynamicprogramming.SeamCarving +
  +
pixelGradients(PImage) - +Method in class dynamicprogramming.SeamCarving +
  +
+
+

+R

+
+
removeColumn() - +Method in class dynamicprogramming.SeamCarving +
  +
+
+

+S

+
+
SeamCarving - Class in dynamicprogramming
 
SeamCarving(PApplet, PImage) - +Constructor for class dynamicprogramming.SeamCarving +
  +
setImage(PImage) - +Method in class dynamicprogramming.SeamCarving +
  +
setLeftEdge(boolean) - +Method in class dynamicprogramming.Cell +
  +
setPrevCell(Cell) - +Method in class dynamicprogramming.Cell +
  +
setRightEdge(boolean) - +Method in class dynamicprogramming.Cell +
  +
setScore(int) - +Method in class dynamicprogramming.Cell +
  +
+
+

+T

+
+
toString() - +Method in class dynamicprogramming.Cell +
  +
+
+

+V

+
+
VERSION - +Static variable in class dynamicprogramming.DynamicProgramming +
  +
+
+C D F G I P R S T V + + + + + + + + + + + + + + +
+ +
+ + + +
+Processing library DynamicProgramming by Greg Borenstein. (C) 2012 + + diff --git a/distribution/DynamicProgramming-1/reference/index.html b/distribution/DynamicProgramming-1/reference/index.html new file mode 100644 index 0000000..f266c94 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/index.html @@ -0,0 +1,36 @@ + + + + + + +Javadocs: DynamicProgramming + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to<A HREF="dynamicprogramming/package-summary.html">Non-frame version.</A> + + + diff --git a/distribution/DynamicProgramming-1/reference/overview-tree.html b/distribution/DynamicProgramming-1/reference/overview-tree.html new file mode 100644 index 0000000..8329a78 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/overview-tree.html @@ -0,0 +1,150 @@ + + + + + + +Class Hierarchy (Javadocs: DynamicProgramming) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
dynamicprogramming
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Processing library DynamicProgramming by Greg Borenstein. (C) 2012 + + diff --git a/distribution/DynamicProgramming-1/reference/package-list b/distribution/DynamicProgramming-1/reference/package-list new file mode 100644 index 0000000..2d5e31e --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/package-list @@ -0,0 +1 @@ +dynamicprogramming diff --git a/distribution/DynamicProgramming-1/reference/resources/inherit.gif b/distribution/DynamicProgramming-1/reference/resources/inherit.gif new file mode 100644 index 0000000..c814867 Binary files /dev/null and b/distribution/DynamicProgramming-1/reference/resources/inherit.gif differ diff --git a/distribution/DynamicProgramming-1/reference/stylesheet.css b/distribution/DynamicProgramming-1/reference/stylesheet.css new file mode 100644 index 0000000..54998c2 --- /dev/null +++ b/distribution/DynamicProgramming-1/reference/stylesheet.css @@ -0,0 +1,310 @@ +/* Javadoc style sheet */ +/* Define colors, fonts and other style attributes here to override the defaults */ +/* processingLibs style by andreas schlegel, sojamo */ + + +body { + margin : 0; + padding : 0; + padding-left : 10px; + padding-right : 8px; + background-color : #FFFFFF; + font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size : 100%; + font-size : 0.7em; + font-weight : normal; + line-height : normal; + margin-bottom:30px; +} + + + + +/* Headings */ +h1, h2, h3, h4, h5, th { + font-family :Arial, Helvetica, sans-serif; + font-size:1.2em; +} + + +p { + font-size : 1em; + width:80%; +} + +pre, code { + font-family : "Courier New", Courier, monospace; + font-size : 12px; + line-height : normal; +} + + + +table { + border:0; + margin-bottom:10px; + margin-top:10px; +} + + +tr, td { + border-top: 0px solid; + border-left: 0px solid; + padding-top:8px; + padding-bottom:8px; +} + + + +hr { + border:0; + height:1px; + padding:0; + margin:0; + margin-bottom:4px; + +} + + + +dd, th, td, font { + font-size:1.0em; + line-height:1.0em; +} + + + +dt { + margin-bottom:0px; +} + + + +dd { + margin-top:2px; + margin-bottom:4px; +} + + + +a { + text-decoration: underline; + font-weight: normal; +} + +a:hover, +a:active { + text-decoration: underline; + font-weight: normal; +} + +a:visited, +a:link:visited { + text-decoration: underline; + font-weight: normal; +} + + +img { + border: 0px solid #000000; +} + + + +/* Navigation bar fonts */ +.NavBarCell1 { + border:0; +} + +.NavBarCell1Rev { + border:0; +} + +.NavBarFont1 { + font-family: Arial, Helvetica, sans-serif; + font-size:1.1em; +} + + +.NavBarFont1 b { + font-weight:normal; +} + + + +.NavBarFont1:after, .NavBarFont1Rev:after { + font-weight:normal; + content: " \\"; +} + + +.NavBarFont1Rev { + font-family: Arial, Helvetica, sans-serif; + font-size:1.1em; +} + +.NavBarFont1Rev b { + font-family: Arial, Helvetica, sans-serif; + font-size:1.1em; + font-weight:normal; +} + +.NavBarCell2 { + font-family: Arial, Helvetica, sans-serif; +} + +.NavBarCell3 { + font-family: Arial, Helvetica, sans-serif; +} + + + +font.FrameItemFont { + font-family: Helvetica, Arial, sans-serif; + font-size:1.1em; + line-height:1.1em; +} + +font.FrameHeadingFont { + font-family: Helvetica, Arial, sans-serif; + line-height:32px; +} + +/* Font used in left-hand frame lists */ +.FrameTitleFont { + font-family: Helvetica, Arial, sans-serif +} + + +.toggleList { + padding:0; + margin:0; + margin-top:12px; +} + +.toggleList dt { + font-weight:bold; + font-size:12px; + font-family:arial,sans-serif; + padding:0px; + margin:10px 0px 10px 0px; +} + +.toggleList dt span { + font-family: monospace; + padding:0; + margin:0; +} + + +.toggleList dd { + margin:0; + padding:0; +} + +html.isjs .toggleList dd { + display: none; +} + +.toggleList pre { + padding: 4px 4px 4px 4px; +} + + + + + +/* COLORS */ + +pre, code { + color: #000000; +} + + +body { + color : #333333; + background-color :#FFFFFF; +} + + +h1, h2, h3, h4, h5, h6 { + color:#555; +} + +a, +.toggleList dt { + color: #1a7eb0; +} + +a:hover, +a:active { + color: #1a7eb0; +} + +a:visited, +a:link:visited { + color: #1a7eb0; +} + +td,tr { + border-color: #999999; +} + +hr { + color:#999999; + background:#999999; +} + + +.TableHeadingColor { + background: #dcdcdc; + color: #555; +} + + +.TableSubHeadingColor { + background: #EEEEFF +} + +.TableRowColor { + background: #FFFFFF +} + + +.NavBarCell1 { + background-color:#dcdcdc; + color:#000; +} + +.NavBarCell1 a { + color:#333; +} + + +.NavBarCell1Rev { + background-color:transparent; +} + +.NavBarFont1 { + color:#333; +} + + +.NavBarFont1Rev { + color:#fff; +} + +.NavBarCell2 { + background-color:#999; +} + +.NavBarCell2 a { + color:#fff; +} + + + +.NavBarCell3 { + background-color:#dcdcdc; +} + diff --git a/distribution/DynamicProgramming-1/stylesheet.css b/distribution/DynamicProgramming-1/stylesheet.css new file mode 100644 index 0000000..4348b38 --- /dev/null +++ b/distribution/DynamicProgramming-1/stylesheet.css @@ -0,0 +1,203 @@ +/* processingLibs style by andreas schlegel, sojamo. */ + + +* { + margin:0; + padding:0; + border:0; +} + + +body { + font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size : 100%; + font-size : 0.70em; + font-weight : normal; + line-height : normal; +} + + + +#container { + margin-left:64px; + background-color:#fff; +} + +#header { + float:left; + padding-top:24px; + padding-bottom:48px; +} + +#menu { + margin-top:16px; + float:left; + margin-bottom:64px; +} + + +#about, +#download, +#examples, +#demos, +#misc { + width:480px; + float:left; + margin-right:24px; +} + + +#resources, #info { + width:320px; + float:left; +} + + +.clear { + clear:both; +} + +#footer { + margin-top:300px; + height:20px; + margin-bottom:32px; +} + + +ul { + list-style:none; + padding:0; + margin:0; +} + + +#menu ul li, #subMenu ul li { + float:left; + padding-right:6px; +} + + + + + + +/* Headings */ + +h1 { + font-size:2em; + font-weight:normal; +} + + +h2, h3, h4, h5, th { + font-size:1.3em; + font-weight:normal; + margin-bottom:4px; +} + + + +p { + font-size:1em; + width:90%; + margin-bottom:32px; +} + + +pre, code { + font-family:"Courier New", Courier, monospace; + font-size:1em; + line-height:normal; +} + + + + +hr { + border:0; + height:1px; + margin-bottom:24px; +} + + +a { + text-decoration: underline; + font-weight: normal; +} + + +a:hover, +a:active { + text-decoration: underline; + font-weight: normal; +} + + +a:visited, +a:link:visited { + text-decoration: underline; + font-weight: normal; +} + + + +img { + border: 0px solid #000000; +} + + + + + +/* COLORS */ + + +body { + color : #333; + background-color :#fff; +} + + +#header { + background-color:#fff; + color:#333; +} + + + +h1, h2, h3, h4, h5, h6 { + color:#666; +} + + +pre, code { + color: #000000; +} + + +a,strong { + color: #333; +} + + +a:hover, +a:active { + color: #333; +} + + +a:visited, +a:link:visited { + color: #333; +} + + +#footer, #menu { + background-color:#fff; + color:#333; +} + + +#footer a, #menu a { + color:#333; +} diff --git a/examples/README b/examples/README new file mode 100644 index 0000000..6dfb9ca --- /dev/null +++ b/examples/README @@ -0,0 +1 @@ +add examples for your library here. \ No newline at end of file diff --git a/examples/SeamCarvingExample/SeamCarvingExample.pde b/examples/SeamCarvingExample/SeamCarvingExample.pde new file mode 100644 index 0000000..f33c9f5 --- /dev/null +++ b/examples/SeamCarvingExample/SeamCarvingExample.pde @@ -0,0 +1,29 @@ +import dynamicprogramming.*; + +SeamCarving carver; +ArrayList seam; + +PImage img; + +void setup() { + img = loadImage("arch_sunset.jpg"); + size(img.width,img.height); + + println(img.width + " " + img.height); + + carver = new SeamCarving(this, img); + seam = carver.findMinSeam(); +} + +void draw() { + image(img, 0,0); + stroke(255,0,0); + for(PVector p : seam){ + point(p.x, p.y); + } +} + +void keyPressed(){ + img = carver.removeColumn(); + carver.setImage(img); +} diff --git a/examples/SeamCarvingExample/arch_sunset.jpg b/examples/SeamCarvingExample/arch_sunset.jpg new file mode 100644 index 0000000..c0099b6 Binary files /dev/null and b/examples/SeamCarvingExample/arch_sunset.jpg differ diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..780d577 --- /dev/null +++ b/lib/README @@ -0,0 +1,6 @@ +The lib folder: +In case your library requires 3rd party libraries, which need to be +added to the distribution, put them into the lib folder. +These 3rd party libraries will be added to your distribution and are +located next to your library's jar file. +This does not apply to .jar files that are considered core processing libraries. \ No newline at end of file diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..6702d06 --- /dev/null +++ b/license.txt @@ -0,0 +1,20 @@ +A code template to build libraries for the Processing programming environment. + +Part of the Processing project - http://processing.org + +Copyright (c) 2011-12 Elie Zananiri +Copyright (c) 2008-11 Andreas Schlegel + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. \ No newline at end of file diff --git a/resources/ChangeLog.txt b/resources/ChangeLog.txt new file mode 100644 index 0000000..27dcc55 --- /dev/null +++ b/resources/ChangeLog.txt @@ -0,0 +1,67 @@ +2012-10-05 Elie Zananiri + * version 0.4.8 + * updated default classpath on OS X + +2012-02-16 Elie Zananiri + * version 0.4.7 + * fixed up formatting to match new tool template + +2011-12-23 Elie Zananiri + * version 0.4.6 + * changed the default Java compile version to 1.6 + * added a "library.paragraph" to build.properties, used in the library.properties file + * added "library.sentence" and "library.paragraph" fields to index.html + +2011-11-17 Elie Zananiri + * version 0.4.5 + * updated the library categories + +2011-11-10 Elie Zananiri + * version 0.4.4 + * updated the build script to use the correct delimiter based on the OS when parsing source files + +2011-11-09 Elie Zananiri + * version 0.4.3 + * removed the "-latest" suffix from the generated file names as it could lead to confusion when unzipping the library + * added the version number to the download link text to avoid confusion with the pretty version string + +2011-11-07 Elie Zananiri + * version 0.4.2 + * fixed some warnings in the Ant build script + +2011-11-03 Elie Zananiri + * version 0.4.1 + * added the library.properties file, used for the library engine in Processing 2.0 + * added new fields to build.properties to fill in the library.properties file + * the script now generates two copies of the zip and properties file: one with the version number appended and another with "latest" appended (for the Processing 2.0 library engine) + +2010-05-07 Andreas Schlegel + * version 0.3.2 + * build.xml: removing delete tag for bin folder, did cause issues with class referencing inside eclipse + * build.xml: for users using 0.3.1, comment out inside target clean + +2010-05-01 Andreas Schlegel + * version 0.3.1 + * the option to create a tool with the library template has been excluded. to create tools for processing see http://code.google.com/p/processing-tool-template + * build.properties and build.xml files have been adjusted accordingly + * modified: src, examples + +2010-04-25 Andreas Schlegel + * version 0.2.1 + * build.xml: zip method adjusted, tested on osx 10.x and windows xp + * screencasts available for both library and tool, see wiki. + +2010-04-12 Andreas Schlegel + * version 0.2.0 + * the template now support both, processing libraries and tools + * added an install file for a library/tool distribution included in the .zip file. + * data: adding data folder, see README file for details + * lib: adding lib folder, see README file for details + * resources: excluding project related properties from build.xml, now located inside build.properties + * distribution: distributions are now archived with a version number + * bin: folder removed + * build.xml: ant build file has been mostly rewritten, now supports tool and library + * build.properties: adding properties file for build.xml. please read comments inside build.properties. + * changeLog: adding ChangeLog file + + \ No newline at end of file diff --git a/resources/build.properties b/resources/build.properties new file mode 100644 index 0000000..8928a76 --- /dev/null +++ b/resources/build.properties @@ -0,0 +1,168 @@ +# Create libraries for the Processing open source programming language and +# environment (http://www.processing.org) +# +# Customize the build properties to make the ant-build-process work for your +# environment. How? Please read the comments below. +# +# The default properties are set for OSX, for Windows-settings please refer to +# comments made under (1) and (2). + + + +# (1) +# Where is your Processing sketchbook located? +# If you are not sure, check the sketchbook location in your Processing +# application preferences. +# ${user.home} points the compiler to your home directory. +# For windows the default path to your sketchbook would be +# ${user.home}/My Documents/Processing (make adjustments below). + +sketchbook.location=${user.home}/Documents/Processing + + + +# (2) +# Where are the jar files located that are required for compiling your library +# such as e.g. core.jar? +# By default the local classpath location points to folder libs inside Eclipse's +# workspace (by default found in your home directory). +# For Windows the default path would be ${user.home}/workspace/libs (make +# adjustments below). + +classpath.local.location=${user.home}/Documents/eclipse/workspace/libs + + +# For OSX users. +# The following path will direct you into Processing's application source code +# folder in case you put Processing inside your Applications folder. +# Uncommenting the line below will overwrite the classpath.local.location from +# above. + +#classpath.local.location=/Applications/Processing.app/Contents/Resources/Java/core/library/ + + +# Add all jar files that are required for compiling your project to the local +# and project classpath, use a comma as delimiter. These jar files must be +# inside your classpath.local.location folder. + +classpath.local.include=core.jar + + +# Add processing's libraries folder to the classpath. +# If you don't need to include the libraries folder to your classpath, comment +# out the following line. + +classpath.libraries.location=${sketchbook.location}/libraries + + + +# (3) +# Set the java version that should be used to compile your library. + +java.target.version=1.6 + + +# Set the description of the Ant build.xml file. + +ant.description=ProcessingLibs Ant build file. + + + +# (4) +# Project details. +# Give your library a name. + +project.name=DynamicProgramming + + +# Use 'normal' or 'fast' as value for project.compile. +# 'fast' will only compile the project into your sketchbook. +# 'normal' will compile the distribution including the javadoc-reference and all +# web-files (the compile process here takes longer). + +project.compile=normal + +# All files compiled with project.compile=normal are stored +# in the distribution folder. + + + +# (5) +# The following items are properties that will be used to make changes to the +# web document templates. Values of properties will be inserted into the +# documents automatically. +# If you need more control, you can edit web/index.html and +# web/library.properties directly. + +author.name=Greg Borenstein +author.url=http://makematics.com + + +# Set the web page for your library. +# This is NOT a direct link to where to download it. + +library.url=http://makematics.com/code/DynamicProgramming + + +# Set the category of your library. This must be one (or many) of the following: +# "3D" "Animation" "Compilations" "Data" +# "Fabrication" "Geometry" "GUI" "Hardware" +# "I/O" "Language" "Math" "Simulation" +# "Sound" "Utilities" "Typography" "Video & Vision" +# If a value other than those listed is used, your library will listed as +# "Other". + +library.category=Other + + +# A short sentence (or fragment) to summarize the library's function. This will +# be shown from inside the PDE when the library is being installed. Avoid +# repeating the name of your library here. Also, avoid saying anything redundant +# like mentioning that it's a library. This should start with a capitalized +# letter, and end with a period. + +library.sentence=An implementation of the Dynamic Programming optimized search technique as well as a series of applications that take advantage of it such as image seam carving and textual sequence alignment. + + +# Additional information suitable for the Processing website. The value of +# 'sentence' always will be prepended, so you should start by writing the +# second sentence here. If your library only works on certain operating systems, +# mention it here. + +library.paragraph= + + +# Set the source code repository for your project. +# Recommendations for storing your source code online are Google Code or GitHub. + +source.host=Github +source.url=http://github.com/atduskgreg/Processing-DynamicProgramming +source.repository=http://github.com/atduskgreg/Processing-DynamicProgramming + + +# The current version of your library. +# This number must be parsable as an int. It increments once with each release. +# This is used to compare different versions of the same library, and check if +# an update is available. + +library.version=1 + + +# The version as the user will see it. +# If blank, the library.version attribute will be used here. + +library.prettyVersion=0.1.1 + + +library.copyright=(C) 2012 +library.dependencies=? +library.keywords=? + +tested.platform=osx +tested.processingVersion=2.0b5 + + +# Include javadoc references into your project's javadocs. + +javadoc.java.href=http://java.sun.com/javase/6/docs/api/ +javadoc.processing.href=http://processing.googlecode.com/svn/trunk/processing/build/javadoc/core/ diff --git a/resources/build.xml b/resources/build.xml new file mode 100644 index 0000000..c074378 --- /dev/null +++ b/resources/build.xml @@ -0,0 +1,384 @@ + + + + + + + + + + + ${ant.description} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${line} + Building the Processing library ${project.name} ${library.version} +${line} + src path ${project.src} + bin path ${project.bin} + classpath.local ${classpath.local.location} + sketchbook ${sketchbook.location} + java version ${java.target.version} +${line} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${exampleDir} + + + + + + + + + + + + + + + + + + + + + + +${line} +Name ${project.name} +Version ${library.prettyVersion} (${library.version}) +Compiled ${project.compile} +Sketchbook ${sketchbook.location} +${line} +done, finished. +${line} + + + + + diff --git a/resources/code/ExampleTaglet.class b/resources/code/ExampleTaglet.class new file mode 100644 index 0000000..b17c64e Binary files /dev/null and b/resources/code/ExampleTaglet.class differ diff --git a/resources/code/ExampleTaglet.java b/resources/code/ExampleTaglet.java new file mode 100644 index 0000000..461ea08 --- /dev/null +++ b/resources/code/ExampleTaglet.java @@ -0,0 +1,231 @@ +/* + * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * -Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * -Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any + * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY + * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY + * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR + * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR + * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE + * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, + * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER + * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF + * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that Software is not designed, licensed or + * intended for use in the design, construction, operation or + * maintenance of any nuclear facility. + */ + +import com.sun.tools.doclets.Taglet; +import com.sun.javadoc.*; +import java.util.Map; +import java.io.*; +/** + * A sample Taglet representing @example. This tag can be used in any kind of + * {@link com.sun.javadoc.Doc}. It is not an inline tag. The text is displayed + * in yellow to remind the developer to perform a task. For + * example, "@example Hello" would be shown as: + *
+ *
+ * To Do: + *
Fix this! + *
+ *
+ * + * @author Jamie Ho + * @since 1.4 + */ + +public class ExampleTaglet implements Taglet { + + private static final String NAME = "example"; + private static final String HEADER = "example To Do:"; + + /** + * Return the name of this custom tag. + */ + public String getName() { + return NAME; + } + + /** + * Will return true since @example + * can be used in field documentation. + * @return true since @example + * can be used in field documentation and false + * otherwise. + */ + public boolean inField() { + return true; + } + + /** + * Will return true since @example + * can be used in constructor documentation. + * @return true since @example + * can be used in constructor documentation and false + * otherwise. + */ + public boolean inConstructor() { + return true; + } + + /** + * Will return true since @example + * can be used in method documentation. + * @return true since @example + * can be used in method documentation and false + * otherwise. + */ + public boolean inMethod() { + return true; + } + + /** + * Will return true since @example + * can be used in method documentation. + * @return true since @example + * can be used in overview documentation and false + * otherwise. + */ + public boolean inOverview() { + return true; + } + + /** + * Will return true since @example + * can be used in package documentation. + * @return true since @example + * can be used in package documentation and false + * otherwise. + */ + public boolean inPackage() { + return true; + } + + /** + * Will return true since @example + * can be used in type documentation (classes or interfaces). + * @return true since @example + * can be used in type documentation and false + * otherwise. + */ + public boolean inType() { + return true; + } + + /** + * Will return false since @example + * is not an inline tag. + * @return false since @example + * is not an inline tag. + */ + + public boolean isInlineTag() { + return false; + } + + /** + * Register this Taglet. + * @param tagletMap the map to register this tag to. + */ + public static void register(Map tagletMap) { + ExampleTaglet tag = new ExampleTaglet(); + Taglet t = (Taglet) tagletMap.get(tag.getName()); + if (t != null) { + tagletMap.remove(tag.getName()); + } + tagletMap.put(tag.getName(), tag); + } + + /** + * Given the Tag representation of this custom + * tag, return its string representation. + * @param tag the Tag representation of this custom tag. + */ + public String toString(Tag tag) { + return createHTML(readFile(tag.text())); + } + + + /** + * Given an array of Tags representing this custom + * tag, return its string representation. + * @param tags the array of Tags representing of this custom tag. + */ + public String toString(Tag[] tags) { + if (tags.length == 0) { + return null; + } + return createHTML(readFile(tags[0].text())); + } + + + + String createHTML(String theString) { + if(theString!=null) { + String dd = ""; + + return dd+"\n
" + + "
+Example
" + + "
"+theString+"
" + + "
"; + } + return ""; + } + + + /** + * check if the examples directory exists and return the example as given in the tag. + * @param theExample the name of the example + */ + String readFile(String theExample) { + String record = ""; + String myResult = ""; + int recCount = 0; + String myDir = "../examples"; + File file=new File(myDir); + if(file.exists()==false) { + myDir = "./examples"; + } + try { + FileReader fr = new FileReader(myDir+"/"+theExample+"/"+theExample+".pde"); + BufferedReader br = new BufferedReader(fr); + record = new String(); + while ((record = br.readLine()) != null) { + myResult += record+"\n"; + } + } catch (IOException e) { + System.out.println(e); + return null; + } + return myResult; + } +} + + diff --git a/resources/code/ant-contrib-1.0b3.jar b/resources/code/ant-contrib-1.0b3.jar new file mode 100644 index 0000000..0625376 Binary files /dev/null and b/resources/code/ant-contrib-1.0b3.jar differ diff --git a/resources/code/doc.sh b/resources/code/doc.sh new file mode 100644 index 0000000..1db9a92 --- /dev/null +++ b/resources/code/doc.sh @@ -0,0 +1,18 @@ +# a shell script to create a java documentation +# for a processing library. +# +# make changes to the variables below so they +# fit the structure of your library + +# the package name of your library +package=template; + +# source folder location +src=../src; + +# the destination folder of your documentation +dest=../documentation; + + +# compile the java documentation +javadoc -d $dest -stylesheetfile ./stylesheet.css -sourcepath ${src} ${package} diff --git a/resources/install_instructions.txt b/resources/install_instructions.txt new file mode 100644 index 0000000..693bf1f --- /dev/null +++ b/resources/install_instructions.txt @@ -0,0 +1,46 @@ +How to install library ##library.name## + + +Install with the "Add Library..." tool + +New for Processing 2.0: Add contributed libraries by selecting "Add Library..." +from the "Import Library..." submenu within the Sketch menu. Not all available +libraries have been converted to show up in this menu. If a library isn't there, +it will need to be installed manually by following the instructions below. + + +Manual Install + +Contributed libraries may be downloaded separately and manually placed within +the "libraries" folder of your Processing sketchbook. To find (and change) the +Processing sketchbook location on your computer, open the Preferences window +from the Processing application (PDE) and look for the "Sketchbook location" +item at the top. + +Copy the contributed library's folder into the "libraries" folder at this +location. You will need to create the "libraries" folder if this is your first +contributed library. + +By default the following locations are used for your sketchbook folder: + For Mac users, the sketchbook folder is located inside ~/Documents/Processing. + For Windows users, the sketchbook folder is located inside + 'My Documents'/Processing. + +The folder structure for library ##library.name## should be as follows: + +Processing + libraries + ##library.name## + examples + library + ##library.name##.jar + reference + src + +Some folders like "examples" or "src" might be missing. After library +##library.name## has been successfully installed, restart the Processing +application. + + +If you're having trouble, have a look at the Processing Wiki for more +information: http://wiki.processing.org/w/How_to_Install_a_Contributed_Library diff --git a/resources/library.properties b/resources/library.properties new file mode 100644 index 0000000..cdc23e9 --- /dev/null +++ b/resources/library.properties @@ -0,0 +1,49 @@ +# More on this file here: http://code.google.com/p/processing/wiki/LibraryBasics +# UTF-8 supported. + +# The name of your library as you want it formatted. +name = ##library.name## + +# List of authors. Links can be provided using the syntax [author name](url). +authorList = [##author.name##](##author.url##) + +# A web page for your library, NOT a direct link to where to download it. +url = ##library.url## + +# The category of your library, must be one (or many) of the following: +# "3D" "Animation" "Compilations" "Data" +# "Fabrication" "Geometry" "GUI" "Hardware" +# "I/O" "Language" "Math" "Simulation" +# "Sound" "Utilities" "Typography" "Video & Vision" +# +# If a value other than those listed is used, your library will listed as +# "Other". +category = ##library.category## + +# A short sentence (or fragment) to summarize the library's function. This will +# be shown from inside the PDE when the library is being installed. Avoid +# repeating the name of your library here. Also, avoid saying anything redundant +# like mentioning that it's a library. This should start with a capitalized +# letter, and end with a period. +sentence = ##library.sentence## + +# Additional information suitable for the Processing website. The value of +# 'sentence' always will be prepended, so you should start by writing the +# second sentence here. If your library only works on certain operating systems, +# mention it here. +paragraph = ##library.paragraph## + +# Links in the 'sentence' and 'paragraph' attributes can be inserted using the +# same syntax as for authors. +# That is, [here is a link to Processing](http://processing.org/) + + +# A version number that increments once with each release. This is used to +# compare different versions of the same library, and check if an update is +# available. You should think of it as a counter, counting the total number of +# releases you've had. +version = ##library.version## # This must be parsable as an int + +# The version as the user will see it. If blank, the version attribute will be +# used here. +prettyVersion = ##library.prettyVersion## # This is treated as a String diff --git a/resources/stylesheet.css b/resources/stylesheet.css new file mode 100644 index 0000000..54998c2 --- /dev/null +++ b/resources/stylesheet.css @@ -0,0 +1,310 @@ +/* Javadoc style sheet */ +/* Define colors, fonts and other style attributes here to override the defaults */ +/* processingLibs style by andreas schlegel, sojamo */ + + +body { + margin : 0; + padding : 0; + padding-left : 10px; + padding-right : 8px; + background-color : #FFFFFF; + font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size : 100%; + font-size : 0.7em; + font-weight : normal; + line-height : normal; + margin-bottom:30px; +} + + + + +/* Headings */ +h1, h2, h3, h4, h5, th { + font-family :Arial, Helvetica, sans-serif; + font-size:1.2em; +} + + +p { + font-size : 1em; + width:80%; +} + +pre, code { + font-family : "Courier New", Courier, monospace; + font-size : 12px; + line-height : normal; +} + + + +table { + border:0; + margin-bottom:10px; + margin-top:10px; +} + + +tr, td { + border-top: 0px solid; + border-left: 0px solid; + padding-top:8px; + padding-bottom:8px; +} + + + +hr { + border:0; + height:1px; + padding:0; + margin:0; + margin-bottom:4px; + +} + + + +dd, th, td, font { + font-size:1.0em; + line-height:1.0em; +} + + + +dt { + margin-bottom:0px; +} + + + +dd { + margin-top:2px; + margin-bottom:4px; +} + + + +a { + text-decoration: underline; + font-weight: normal; +} + +a:hover, +a:active { + text-decoration: underline; + font-weight: normal; +} + +a:visited, +a:link:visited { + text-decoration: underline; + font-weight: normal; +} + + +img { + border: 0px solid #000000; +} + + + +/* Navigation bar fonts */ +.NavBarCell1 { + border:0; +} + +.NavBarCell1Rev { + border:0; +} + +.NavBarFont1 { + font-family: Arial, Helvetica, sans-serif; + font-size:1.1em; +} + + +.NavBarFont1 b { + font-weight:normal; +} + + + +.NavBarFont1:after, .NavBarFont1Rev:after { + font-weight:normal; + content: " \\"; +} + + +.NavBarFont1Rev { + font-family: Arial, Helvetica, sans-serif; + font-size:1.1em; +} + +.NavBarFont1Rev b { + font-family: Arial, Helvetica, sans-serif; + font-size:1.1em; + font-weight:normal; +} + +.NavBarCell2 { + font-family: Arial, Helvetica, sans-serif; +} + +.NavBarCell3 { + font-family: Arial, Helvetica, sans-serif; +} + + + +font.FrameItemFont { + font-family: Helvetica, Arial, sans-serif; + font-size:1.1em; + line-height:1.1em; +} + +font.FrameHeadingFont { + font-family: Helvetica, Arial, sans-serif; + line-height:32px; +} + +/* Font used in left-hand frame lists */ +.FrameTitleFont { + font-family: Helvetica, Arial, sans-serif +} + + +.toggleList { + padding:0; + margin:0; + margin-top:12px; +} + +.toggleList dt { + font-weight:bold; + font-size:12px; + font-family:arial,sans-serif; + padding:0px; + margin:10px 0px 10px 0px; +} + +.toggleList dt span { + font-family: monospace; + padding:0; + margin:0; +} + + +.toggleList dd { + margin:0; + padding:0; +} + +html.isjs .toggleList dd { + display: none; +} + +.toggleList pre { + padding: 4px 4px 4px 4px; +} + + + + + +/* COLORS */ + +pre, code { + color: #000000; +} + + +body { + color : #333333; + background-color :#FFFFFF; +} + + +h1, h2, h3, h4, h5, h6 { + color:#555; +} + +a, +.toggleList dt { + color: #1a7eb0; +} + +a:hover, +a:active { + color: #1a7eb0; +} + +a:visited, +a:link:visited { + color: #1a7eb0; +} + +td,tr { + border-color: #999999; +} + +hr { + color:#999999; + background:#999999; +} + + +.TableHeadingColor { + background: #dcdcdc; + color: #555; +} + + +.TableSubHeadingColor { + background: #EEEEFF +} + +.TableRowColor { + background: #FFFFFF +} + + +.NavBarCell1 { + background-color:#dcdcdc; + color:#000; +} + +.NavBarCell1 a { + color:#333; +} + + +.NavBarCell1Rev { + background-color:transparent; +} + +.NavBarFont1 { + color:#333; +} + + +.NavBarFont1Rev { + color:#fff; +} + +.NavBarCell2 { + background-color:#999; +} + +.NavBarCell2 a { + color:#fff; +} + + + +.NavBarCell3 { + background-color:#dcdcdc; +} + diff --git a/src/dynamicprogramming/Cell.java b/src/dynamicprogramming/Cell.java new file mode 100644 index 0000000..5bc553f --- /dev/null +++ b/src/dynamicprogramming/Cell.java @@ -0,0 +1,95 @@ +package dynamicprogramming; + +/* + * + * Based on work by Paul Reiners + * http://www.ibm.com/developerworks/java/library/j-seqalign/index.html + * + */ + +public class Cell { + private Cell prevCell; + private int score; + private int row; + private int col; + + private boolean isLeftEdge; + private boolean isRightEdge; + + public Cell(int row, int col) { + this.row = row; + this.col = col; + } + + public boolean isLeftEdge(){ + return isLeftEdge; + } + + public boolean isRightEdge(){ + return isRightEdge; + } + + public void setLeftEdge(boolean e){ + isLeftEdge = e; + } + + public void setRightEdge(boolean e){ + isRightEdge = e; + } + + + /** + * @param score + * the score to set + */ + public void setScore(int score) { + this.score = score; + } + + /** + * @return the score + */ + public int getScore() { + return score; + } + + /** + * @param prevCell + * the prevCell to set + */ + public void setPrevCell(Cell prevCell) { + this.prevCell = prevCell; + } + + /** + * @return the row + */ + public int getRow() { + return row; + } + + /** + * @return the col + */ + public int getCol() { + return col; + } + + /** + * @return the prevCell + */ + public Cell getPrevCell() { + return prevCell; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Cell(" + row + ", " + col + "): score=" + score + ", prevCell=" + + prevCell + "]"; + } +} diff --git a/src/dynamicprogramming/DynamicProgramming.java b/src/dynamicprogramming/DynamicProgramming.java new file mode 100644 index 0000000..357b981 --- /dev/null +++ b/src/dynamicprogramming/DynamicProgramming.java @@ -0,0 +1,156 @@ +/** + * ##library.name## + * ##library.sentence## + * ##library.url## + * + * Copyright ##copyright## ##author## + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author ##author## + * @modified ##date## + * @version ##library.prettyVersion## (##library.version##) + */ + +package dynamicprogramming; + + +import processing.core.*; + +/** + * This is a template class and can be used to start a new processing library or tool. + * Make sure you rename this class as well as the name of the example package 'template' + * to your own library or tool naming convention. + * + * @example Hello + * + * (the tag @example followed by the name of an example included in folder 'examples' will + * automatically include the example in the javadoc.) + * + */ + + + +public abstract class DynamicProgramming { + public final static String VERSION = "##library.prettyVersion##"; + + protected int tableWidth; + protected int tableHeight; + protected Cell[][] scoreTable; + protected boolean tableIsFilledIn; + protected boolean isInitialized; + + public DynamicProgramming(int tableWidth, int tableHeight) { + this.tableWidth = tableWidth; + this.tableHeight = tableHeight; + scoreTable = new Cell[tableHeight][tableWidth]; + } + + public int[][] getScoreTable() { + ensureTableIsFilledIn(); + + int[][] matrix = new int[scoreTable.length][scoreTable[0].length]; + for (int i = 0; i < matrix.length; i++) { + for (int j = 0; j < matrix[i].length; j++) { + matrix[i][j] = scoreTable[i][j].getScore(); + } + } + + return matrix; + } + + protected void initializeScores() { + for (int i = 0; i < scoreTable.length; i++) { + for (int j = 0; j < scoreTable[i].length; j++) { + scoreTable[i][j].setScore(getInitialScore(i, j)); + } + } + } + + protected void initializePointers() { + for (int i = 0; i < scoreTable.length; i++) { + for (int j = 0; j < scoreTable[i].length; j++) { + scoreTable[i][j].setPrevCell(getInitialPointer(i, j)); + } + } + } + + protected void initialize() { + for (int i = 0; i < scoreTable.length; i++) { + for (int j = 0; j < scoreTable[i].length; j++) { + Cell c = new Cell(i, j); + + if(j == 0){ + c.isLeftEdge(); + } + + if(j == scoreTable[i].length-1){ + c.isRightEdge(); + } + + scoreTable[i][j] = c; + + } + } + initializeScores(); + initializePointers(); + + isInitialized = true; + } + + protected abstract Cell getInitialPointer(int row, int col); + + protected abstract int getInitialScore(int row, int col); + + protected abstract void fillInCell(Cell currentCell, Cell cellAbove, + Cell cellToLeft, Cell cellAboveLeft, Cell cellAboveRight); + + protected void fillIn() { + for (int row = 1; row < scoreTable.length; row++) { + for (int col = 1; col < scoreTable[row].length; col++) { + Cell currentCell = scoreTable[row][col]; + Cell cellAbove = scoreTable[row - 1][col]; + Cell cellToLeft = scoreTable[row][col - 1]; + Cell cellAboveLeft = scoreTable[row - 1][col - 1]; + Cell cellAboveRight = new Cell(0,0); //f-this + if(col < scoreTable[row].length-1){ + cellAboveRight = scoreTable[row - 1][col + 1]; + } + fillInCell(currentCell, cellAbove, cellToLeft, cellAboveLeft, cellAboveRight); + } + } + + tableIsFilledIn = true; + } + + protected void resetTable(int tableWidth, int tableHeight){ + this.tableWidth = tableWidth; + this.tableHeight = tableHeight; + scoreTable = new Cell[tableHeight][tableWidth]; + + initialize(); + fillIn(); + } + + protected void ensureTableIsFilledIn() { + if (!isInitialized) { + initialize(); + } + if (!tableIsFilledIn) { + fillIn(); + } + } + } diff --git a/src/dynamicprogramming/SeamCarving.java b/src/dynamicprogramming/SeamCarving.java new file mode 100644 index 0000000..4dfeea0 --- /dev/null +++ b/src/dynamicprogramming/SeamCarving.java @@ -0,0 +1,263 @@ +package dynamicprogramming; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; + +import processing.core.*; + + +public class SeamCarving extends DynamicProgramming { + private PApplet parent; + private PImage img; + private float[][] weights; + + public SeamCarving(PApplet parent, PImage img){ + super(img.width, img.height); + + this.parent = parent; + this.img = img; + this.weights = pixelGradients(img); + } + + public void setImage(PImage img){ + this.img = img; + weights = pixelGradients(img); + resetTable(img.width, img.height); + } + + public PImage removeColumn(){ + PImage result = parent.createImage(img.width - 1, img.height, parent.RGB); + ArrayList seam = findMinSeam(); + for(PVector p : seam){ + + int origRowBeginning = (int)p.y * img.width; + int destRowBeginning = (int)p.y * result.width; + + // if there are pixels to copy to the left of the seam + // copy them into the new image + if(p.x > 0){ + + + System.arraycopy(img.pixels, origRowBeginning, result.pixels, destRowBeginning, (int)p.x); + } + + // if there are pixels to copy to the right of the seam + // copy them in as well + if(p.x < img.width - 1){ + System.arraycopy(img.pixels, origRowBeginning + (int)p.x+1, result.pixels, destRowBeginning + (int)p.x, result.width - (int)p.x - 1); + } + + } + + return result; + } + + public ArrayList findMinSeam(){ + ArrayList result = new ArrayList(); + + int[][] scoreTable = getScoreTable(); + + int[] seamIndices = new int[img.height]; + int firstIndex = findMinSeamIndex(scoreTable); + + //seamIndices[img.height - 1] = firstIndex; + + result.add(new PVector(firstIndex, img.height - 1)); + + + int nextCol = firstIndex; + + for (int row = scoreTable.length - 1; row > 0; row--) { + //seamIndices[row] = nextCol; + + result.add(new PVector(nextCol, row)); + + nextCol = findNextCol(scoreTable, row, nextCol); + } + + //seamIndices[0] = nextCol; + result.add(new PVector(nextCol, 0)); + + //return seamIndices; + return result; + } + + private int findMinSeamIndex(int[][] table) { + int lastRow = table.length - 1; + + int minIndex = 0; + float minValue = table[lastRow][0]; + + for (int j = 1; j < table[0].length; j++) { + if (table[lastRow][j] < minValue) { + minIndex = j; + minValue = table[lastRow][j]; + } + } + + return minIndex; + } + + /** + * From a certain (row,col) in the DP table, determines the previous smallest + * path and returns which column it is in. + */ + private int findNextCol(int[][] table, int row, int col) { + // Checks for DP table of width 1 + if (table[0].length == 1) + return 0; + + // if at the left border only considers above and above to the right + if (col == 0) { + if (table[row - 1][0] < table[row - 1][1]) + return 0; + else + return 1; + } + + // if at the right border only considers above and above to the left + if (col == table[0].length - 1) { + if (table[row - 1][table[0].length - 2] < table[row - 1][table[0].length - 1]) + return table[0].length - 2; + else + return table[0].length - 1; + } + + // otherwise looks at above left, center, and right + return scanThreeAbove(table, row, col); + + } + + /** + * Determines which column leads to smallest Cell for a certain + * (row,col) and returns the column + */ + private int scanThreeAbove(int[][] table, int row, int col) { + int minIndex = col - 1; + float minValue = table[row - 1][col - 1]; + + for (int k = 0; k < 3; k++) { + if (table[row - 1][col - 1 + k] < minValue) { + minValue = table[row - 1][col - 1 + k]; + minIndex = col - 1 + k; + } + } + + return minIndex; + } + + /* BEGIN DynamicProgramming methods */ + + protected Cell getInitialPointer(int row, int col){ + return new Cell(0,0); // i.e. who cares? + } + + protected int getInitialScore(int row, int col){ + return (int)weights[row][col]; + } + + protected void fillInCell(Cell currentCell, Cell cellAbove, Cell cellToLeft, Cell cellAboveLeft, Cell cellAboveRight){ + + if(currentCell.isRightEdge()){ + // // + Math.min(table[i - 1][j], table[i - 1][j - 1]); + + currentCell.setScore(currentCell.getScore() + Math.min(cellAbove.getScore(), cellAboveLeft.getScore())); + + } else { + + currentCell.setScore(currentCell.getScore() + Collections.min(Arrays.asList(cellAboveLeft.getScore(), cellAbove.getScore(), cellAboveRight.getScore()))); + } + //Collections.min(Arrays.asList(table[i - 1][j - 1],table[i - 1][j], table[i - 1][j + 1])); + + //return (int)(weights[col][row] + Collections.min(Arrays.asList(weights[col-1][row-1], weights[col-1][row], weights[col-1][row+1]))); + + + // checks for single col image + /*if (row == 0 && row == weights[0].length - 1) { + return (int)(weights[col][row] + weights[col - 1][row]); + // return image.get(i, j) + table[i - 1][j]; + } + + // if on the left edge does not consider going to the left + if (row == 0) { + //return image.get(i, j) + // + Math.min(table[i - 1][j], table[i - 1][j + 1]); + + return (int)(weights[col][row] + Math.min(weights[col-1][row], weights[col-1][row+1])); + } + + // if on the right edge does not consider going to the right + if (row == weights[0].length - 1) { + //return image.get(i, j) + // + Math.min(table[i - 1][j], table[i - 1][j - 1]); + return (int)(weights[col][row] + Math.min(weights[col-1][row], weights[col-1][row-1])); + } + + // otherwise looks at the left, center, and right possibilities as mins + return (int)(weights[col][row] + Collections.min(Arrays.asList(weights[col-1][row-1], weights[col-1][row], weights[col-1][row+1]))); + //return image.get(i, j) + // + Collections.min(Arrays.asList(table[i - 1][j - 1], + // table[i - 1][j], table[i - 1][j + 1])); + */ + + } + + /* END DynamicProgramming methods */ + + + + public float[][] getWeights(){ + return weights; + } + + public float[][] pixelGradients(PImage original){ + float[][] result = new float[original.height][original.width]; + for (int y = 0; y < original.height; y++) { + for (int x = 0; x < original.width; x++) { + result[y][x] = parent.color(pixelGradient(original, x, y)); + } + } + + return result; + } + + public float pixelGradient(PImage img, int x, int y) { + float point = parent.brightness(img.pixels[x + y*img.width]); + float p1, p2 = 0; + + if (y == img.height - 1 && x == img.width - 1) { + p1 = (float) Math.pow(point, 2); + p2 = (float) Math.pow(point, 2); + return (float) Math.sqrt(p1 + p2); + } + + if (y == img.height - 1) { + p1 = (float) Math.pow((parent.brightness(img.pixels[x+1 + y*img.width]) - point), 2); + p2 = (float) Math.pow(point, 2); + return (float) Math.sqrt(p1 + p2); + } + + if (x == img.width - 1) { + p1 = (float) Math.pow(point, 2); + p2 = (float) Math.pow((parent.brightness(img.pixels[x + (y+1)*img.width]) - point), 2); + return (float) Math.sqrt(p1 + p2); + } + + if (x == img.width - 1) { + p1 = (float) Math.pow(point, 2); + + + p2 = (float) Math.pow((parent.brightness(img.pixels[x+(y+1)*img.width]) - point), 2); + return (float) Math.sqrt(p1 + p2); + } + + + p1 = (float) Math.pow((parent.brightness(img.pixels[x+1 + y*img.width]) - point), 2); + p2 = (float) Math.pow((parent.brightness(img.pixels[x+(y+1)*img.width]) - point), 2); + + return (float) Math.sqrt(p1 + p2); + } + + +} diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..f20764a --- /dev/null +++ b/web/index.html @@ -0,0 +1,137 @@ + + + +##library.name## + + + + + + + + + + + + + + +
+ + + + + +
+ +
+

##library.name##

+

+ A library by ##author.name## for the Processing programming environment.
+ Last update, ##date##. +

+

+ ##library.sentence##
+ ##library.paragraph##
+ Feel free to replace this paragraph with a description of the library.
+ Contributed libraries are developed, documented, and maintained by members of the Processing community. Further directions are included with each library. For feedback and support, please post to the Discourse. We strongly encourage all libraries to be open source, but not all of them are. +

+
+ + + +
+

Download

+

+ Download ##library.name## version ##library.prettyVersion## (##library.version##) in + .zip format. +

+

Installation

+

+ Unzip and put the extracted ##library.name## folder into the libraries folder of your Processing sketches. Reference and examples are included in the ##library.name## folder. +

+
+ + +
+

Keywords. ##library.keywords##

+

Reference. Have a look at the javadoc reference here. A copy of the reference is included in the .zip as well.

+

Source. The source code of ##library.name## is available at ##source.host##, and its repository can be browsed here.

+
+ + +
+

Examples

+

Find a list of examples in the current distribution of ##library.name##, or have a look at them by following the links below.

+
    + ##examples## +
+
+ + +
+

Tested

+

+ + Platform ##tested.platform## + + +
Processing ##tested.processingVersion## + + +
Dependencies ##library.dependencies## +

+
+ + + + + + + + + + + + +
+
+ + +
+ + \ No newline at end of file diff --git a/web/stylesheet.css b/web/stylesheet.css new file mode 100644 index 0000000..4348b38 --- /dev/null +++ b/web/stylesheet.css @@ -0,0 +1,203 @@ +/* processingLibs style by andreas schlegel, sojamo. */ + + +* { + margin:0; + padding:0; + border:0; +} + + +body { + font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size : 100%; + font-size : 0.70em; + font-weight : normal; + line-height : normal; +} + + + +#container { + margin-left:64px; + background-color:#fff; +} + +#header { + float:left; + padding-top:24px; + padding-bottom:48px; +} + +#menu { + margin-top:16px; + float:left; + margin-bottom:64px; +} + + +#about, +#download, +#examples, +#demos, +#misc { + width:480px; + float:left; + margin-right:24px; +} + + +#resources, #info { + width:320px; + float:left; +} + + +.clear { + clear:both; +} + +#footer { + margin-top:300px; + height:20px; + margin-bottom:32px; +} + + +ul { + list-style:none; + padding:0; + margin:0; +} + + +#menu ul li, #subMenu ul li { + float:left; + padding-right:6px; +} + + + + + + +/* Headings */ + +h1 { + font-size:2em; + font-weight:normal; +} + + +h2, h3, h4, h5, th { + font-size:1.3em; + font-weight:normal; + margin-bottom:4px; +} + + + +p { + font-size:1em; + width:90%; + margin-bottom:32px; +} + + +pre, code { + font-family:"Courier New", Courier, monospace; + font-size:1em; + line-height:normal; +} + + + + +hr { + border:0; + height:1px; + margin-bottom:24px; +} + + +a { + text-decoration: underline; + font-weight: normal; +} + + +a:hover, +a:active { + text-decoration: underline; + font-weight: normal; +} + + +a:visited, +a:link:visited { + text-decoration: underline; + font-weight: normal; +} + + + +img { + border: 0px solid #000000; +} + + + + + +/* COLORS */ + + +body { + color : #333; + background-color :#fff; +} + + +#header { + background-color:#fff; + color:#333; +} + + + +h1, h2, h3, h4, h5, h6 { + color:#666; +} + + +pre, code { + color: #000000; +} + + +a,strong { + color: #333; +} + + +a:hover, +a:active { + color: #333; +} + + +a:visited, +a:link:visited { + color: #333; +} + + +#footer, #menu { + background-color:#fff; + color:#333; +} + + +#footer a, #menu a { + color:#333; +}