1+ /* Example for basic image processing algorithms.
2+ * Use the mouse wheel to switch the different algorithms
3+ * and press the left mouse button to see the original image.
4+ *
5+ * Author: Nick 'Milchreis' Müller
6+ */
7+
18import milchreis.imageprocessing.* ;
29
3- int numberOfAlgorithms = 7 ;
10+ int numberOfAlgorithms = 8 ;
411int currentAlgorithm = 0 ;
512
613PImage image;
@@ -52,13 +59,19 @@ void draw() {
5259 processedImage = AutoBalance . apply(image);
5360 }
5461
55- // Gaussian for blurred images
62+ // Pixelation
5663 if (currentAlgorithm == 5 ) {
64+ int pixelsize = (int ) map (mouseX , 0 , width , 0 , 100 );
65+ processedImage = Pixelation . apply(image, pixelsize);
66+ }
67+
68+ // Gaussian for blurred images
69+ if (currentAlgorithm == 6 ) {
5770 processedImage = Gaussian . apply(image, 7 , 0.84089642 );
5871 }
5972
6073 // Edge detection with Canny's algorithm
61- if (currentAlgorithm == 6 ) {
74+ if (currentAlgorithm == 7 ) {
6275 processedImage = CannyEdgeDetector . apply(image);
6376 }
6477 }
@@ -73,4 +86,4 @@ void mouseWheel(MouseEvent event) {
7386 if (currentAlgorithm >= numberOfAlgorithms) {
7487 currentAlgorithm = 0 ;
7588 }
76- }
89+ }
0 commit comments