Difference between revisions of "Floodfill Application"
Line 3: | Line 3: | ||
=Background= | =Background= | ||
− | In this studio, you will be using a parallel and recursive method to create an app that fills in a space with color, much like the paint bucket in | + | In this studio, you will be using a parallel and recursive method to create an app that fills in a space with color, much like the paint bucket in [https://www.gimp.org/ GNU Image Manipulation Program]. |
+ | |||
+ | [[File:FloodFillTool.png]] [[File:FloodFillShape.png]] | ||
==References== | ==References== |
Revision as of 09:39, 1 February 2018
Contents
Motivation
Floodfill is an problem that is well-solved recursively. It allows us an opportunity to think about the similarities and differences between creating a task for each sub-problem and wrapping all of your recursive calls in a single async. Further, we will harken back to this studio later in the semester when we discuss determinism.
Background
In this studio, you will be using a parallel and recursive method to create an app that fills in a space with color, much like the paint bucket in GNU Image Manipulation Program.
References
https://en.wikipedia.org/wiki/Flood_fill
Video
https://wustl.app.box.com/s/d800l5t04y2dthi4q3t4pddph9ms1d8p
Setup
In order to run the visualization app you will need to setup e(fx)clipse.
Mistakes to Avoid
Warning: Do NOT use == to compare Colors. Use Objects.equals(a,b) |
Sequential Implementation Increased Stack Size Requirement
For this project, if you decide to first build a sequential version, you will need to change your VM Arguments slightly. In addition to the normal argument that needs to be pasted in for every assignment, you need to add -Xss4m
. This will increase the size of the call stack, essentially increasing the maximum depth of your recursion.
Code To Use
Code To Implement
class: | FloodFiller.java | |
methods: | floodFillKernel | |
package: | floodfill.studio | |
source folder: | student/src/main/java |
method: floodFillKernel
(parallel implementation required)
The Kernel
The class is composed of two methods: floodFill and floodFillKernel. As you will be implementing FloodFill recursively and in parallel. Carefully consider where to put your asyncs and/or finishes. The entire process in the kernel is triggered from the floodFill method. This is so that the kernel can run recursively and asynchronously so the floodFill method can wrap the kernel in an all-inclusive finish.
The kernel should check if the given pixel is in bounds. If it is, it should check if the given pixel matches the targetColor (the color we wish to change). If it is, it should then replace the color with the replacementColor and asynchronously call the method again to repeat the process for the surrounding pixels. The purpose of the assignment is to understand recursion and how to make it work in parallel.
Testing Your Solution
In order to test this application, please refer to the floodfill.viz
package in the src/visualization/java
folder. More specifically, check out the FloodFillVizApp.java
class. Otherwise, the only class you will need to modify is FloodFiller.java
, which can be found int the floodfill.studio
package in the src/main/java
folder.
There is also an albeit limited test suite FloodFillTestSuite
.
Visualization
Correctness
class: | MergeSortTestSuite.java | |
package: | sort.studio.merge | |
source folder: | testing/src/test/java |