diff --git a/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosCanvasToImageConverter.java b/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosCanvasToImageConverter.java
index 7804503c23fb2b54ce7dc735e784af2386c34aa4..f5290a490d05baa3f6c1692b8ee40c5623d56081 100644
--- a/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosCanvasToImageConverter.java
+++ b/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosCanvasToImageConverter.java
@@ -64,6 +64,11 @@ public class ChaosCanvasToImageConverter {
       }
     }
 
+    // If maxIntensity is zero, we avoid division by zero.
+    if (maxIntensity == 0) {
+      maxIntensity = 1;
+    }
+
     // Create a pixel buffer
     int[] pixelBuffer = new int[width * height];