Difference between revisions of "ForkLoop Images Assignment"

From CSE231 Wiki
Jump to navigation Jump to search
Line 10: Line 10:
  
 
==PixelFilters==
 
==PixelFilters==
<nowiki>public class PixelFilters {
+
{| class="mw-collapsible wikitable"
 +
!| PixelFilters &nbsp;
 +
|-
 +
| <pre>public class PixelFilters {
 
private static class HueSettingPixelFilter implements PixelFilter {
 
private static class HueSettingPixelFilter implements PixelFilter {
 
private final double hue;
 
private final double hue;
Line 63: Line 66:
 
};
 
};
 
}
 
}
}</nowiki>
+
}</pre>|}
  
 
=Code To Implement=
 
=Code To Implement=

Revision as of 04:45, 3 February 2023

Motivation

We gain experience using a parallel fork loop. Image processing often presents the opportunity for a lot of parallelism. Here we will operate on a single image, making a parallel task for each row.

Background

Revisit the Image Batch Race Condition Exercise's Background section for information on pixels and images.

Code To Investigate

Image Batch Race Condition Exercise

Image Batch Race Condition Code To Investigate

PixelFilters

PixelFilters  
}

Code To Implement

ParallelTaskPerRowImageFilter

class: ParallelTaskPerRowImageFilter.java Java.png
methods: apply
package: imagefilter.exercise
source folder: student/src/main/java

apply

method: public HsvImage apply(HsvImage src, PixelFilter pixelFilter) Parallel.svg (parallel implementation required)

Attention niels epting.svg Warning: When saving the result of pixelFilter.apply(), always put the result in a new array. Don't overwrite values of the source array.

To complete this method we must return a new instance of the interface HsvImage. The provided class DefaultHsvImage implements HsvImage so should serve well.

Nicely, DefaultHsvImage provides both:

These two constructors match up well with the two different return types of the many incantations of join_fork_loop:

where R is the return type of the TaskFunction<T, R> passed to the join_fork_loop.

What should the return type from the this TaskFunction be?


Visualization

class: ImageFilterApp.java VIZ
package: imagefilter.viz
source folder: student/src/main/java

Image filter app.png

Testing Your Solution

class: __ParallelTaskPerRowImageFilterTestSuite.java Junit.png
package: imagefilter.exercise
source folder: testing/src/test/java

Pledge, Acknowledgments, Citations

file: exercise-fork-loop-images-pledge-acknowledgments-citations.txt

More info about the Honor Pledge