Difference between revisions of "ForkLoop Images Assignment"

From CSE231 Wiki
Jump to navigation Jump to search
Line 4: Line 4:
  
 
=Code To Investigate=
 
=Code To Investigate=
==Image Batch==
+
==Image Batch Race Condition Exercise==
 
[[Race_Condition_Image_Batch_Assignment#Code_To_Investigate|Image Batch Race Condition Code To Investigate]]
 
[[Race_Condition_Image_Batch_Assignment#Code_To_Investigate|Image Batch Race Condition Code To Investigate]]
 +
 
==PixelFilters==
 
==PixelFilters==
 
  <nowiki>public class PixelFilters {
 
  <nowiki>public class PixelFilters {

Revision as of 18:19, 26 January 2023

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

public class PixelFilters {
	private static class HueSettingPixelFilter implements PixelFilter {
		private final double hue;

		public HueSettingPixelFilter(double hue) {
			this.hue = hue;
		}

		@Override
		public HsvColor apply(HsvColor src) {
			double saturation = src.saturation();
			double value = src.value();
			return new HsvColor(hue, saturation, value);
		}
	}

	public static PixelFilter hueSettingPixelFilterOf(double hue) {
		// return new instance of named class HueSettingPixelFilter
		return new HueSettingPixelFilter(hue);
	}

	public static PixelFilter hueAdjustingPixelFilterOf(double deltaHue) {
		// return new instance of anonymous class
		return new PixelFilter() {
			@Override
			public HsvColor apply(HsvColor src) {
				double hue = src.hue();
				double saturation = src.saturation();
				double value = src.value();
				return new HsvColor(hue + deltaHue, saturation, value);
			}
		};
	}

	public static PixelFilter saturationAdjustingPixelFilterOf(double deltaSaturation) {
		// return anonymous function (also known as a lambda) with parameter type
		return (HsvColor src) -> {
			double hue = src.hue();
			double saturation = src.saturation();
			double value = src.value();
			return new HsvColor(hue, saturation + deltaSaturation, value);
		};
	}

	public static PixelFilter valueAdjustingPixelFilterOf(double deltaValue) {
		// return anonymous function (also known as a lambda) without parameter type
		return src -> {
			double hue = src.hue();
			double saturation = src.saturation();
			double value = src.value();
			return new HsvColor(hue, saturation, value + deltaValue);
		};
	}
}

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)

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