Course:Cpsc312:/image-proc.hs

From UBC Wiki

CLI Image Processing Tool Proposal

Overview

Idea -> CLI tool for image processing.  This tool will enable users to perform three image manipulations from the command line: image resizing, applying mosaic effects, and edge detection.

Why
  • Haskell has advanced compiler optimizations, like lazy evaluation and concurrency support, which can achieve high image processing performance.
  • We have some image processing knowledge from our past experiences (E.g CPSC425, hackathon, etc..)
Expected behaviour
  • Run our haskell code
  • Haskell wait for our input
  • User enters a command

resize width=800,height=600 --input /path/to/image.png --output /path/to/resized_image.png

  • Generate the image

Features

Image Resizing

  • Description: Adjust the dimensions of an image to a specified size, maintaining aspect ratio or stretching to fit.
  • Usage:
    • e.g resize width=800,height=600 --input /path/to/image.png --output /path/to/resized_image.png

Mosaic Effect

  • Description: Apply a mosaic effect to an image, pixelating it to give the appearance of being composed of small tiles.
  • Usage:
    • mosaic size=10 --input /path/to/image.png --output /path/to/mosaic_image.png

Edge Detection

  • Description: Detect and highlight the edges within an image, useful for identifying shapes and boundaries.
  • Usage:
    • edge-detection --input /path/to/image.png --output /path/to/edge_image.png

Implementation

For image reading and writing, we will use the JuicyPixels library, with our own custom algorithms developed for each processing effect. https://hackage.haskell.org/package/JuicyPixels

Something extra

We developed our own Gaussian filter to smooth out images, effectively reducing noise and mitigating issues like aliasing in our outputs. Additionally, we implemented functionality to display messages that indicate where the image is saved, as well as to provide feedback in case of errors during the image reading or writing process.

What did we learn from doing this?

The importance of Cabal for building and packaging Haskell applications. Cabal's sandbox feature was particularly useful for creating isolated environments, preventing library version conflicts across the teams environment.

Getting more used to the syntax and applying what we learned in class has made concepts, especially array manipulation using foldr and list comprehensions, more concrete.

Haskell introduce some complexity to tasks that are straightforward in imperative languages, it provides substantial performance advantages. For example, by using lazy evaluation, Haskell can be more memory-efficient, as it doesn't need to store intermediate results unless they are explicitly used. (e.g KernelIndices list is generated lazily and will only be fully realized when foldr iterates over it to apply the Gaussian filter to each pixel.)

Work division

Kenshin - setup environment, implemented ProcessMosaic and ProcessEdge

Ryota - implemented FindArgValue, GaussianOperation, ProcessResize GitHub Link: https://github.com/Billy1106/HaskImageTool