Skip to content

Jason0429/image-processing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Processing by Jason & Elvin

This is a program that processes .ppm, .bmp, .png, and .jpeg files and has the ability to load, manipulate, and export images.

Changes for Assignment 6

  • ImageProcessingGUIController
    • We created a new controller dedicated to the GUI since the models used were different as the GUI version doesn't need to track multiple images at a time.
    • The MVC for the GUI also utilizes features, whose methods are called via callbacks in the view.
  • ImageProcessingGUIView
    • The GUI view is based on Swing and makes use of features which get passed via action listeners to each component in the view.
    • We also created dedicated components for the histogram and the preview.
    • The GUI view follows a different interface than that of the text-based user interface so we made a new interface for the GUI view specifically.
  • Features
    • A features interface handles the available features for the GUI interface that serves as the middleman between the controller and view.
  • Downscaling
    • A new command was created to handle downscaling whose constructor took in two dimensions for the new image. To accommodate the two inputs, a new case was added in our switch statement in the Features implementation to request the user to provide the new dimensions.
    • This features is only available through the GUI.
  • Partial Image Processing
    • We created a new ImageMaskCommand to give users the ability to specify a mask and only alter a specific portion of an image. This new command falls under the ImageProcessingCommand interface and can only be called through the text-based program.
    • The mask must exactly match the dimensions of the image to be masked, and only the black areas in the mask will be altered in the final image.
  • CheckMaskDecorator
    • We created a decorator for our queries that support masking. This way, we can minimize changing much code by simply using composition to take in the existing query into the decorator and checking if the argument lengths match a normal query usage or a mask query usage.

Changes for Assignment 5

Model

  • Commands
    • Added new abstract classes FilterProcessingCommand and TransformationProcessingCommand to handle kernel image filtering and image matrix processing.
    • Created Kernel class with static methods that produce specific kernels
    • Created Transformation class with static methods that produce specific 3x3 matrices for image transformations
    • Added support for gaussian blur, sepia, sharpen
  • Pixel
    • Added support for aRGB to support transparency in .png images

Controller

  • Exporter
    • Created an ImageExporterInterface interface and abstracted the image exporter to allow for other formats of image export
    • Added new ImageIOExporter to handle .png, .bmp, .jpeg/jpg files
    • Created static export method in new final ImageExporter
  • Loader
    • Created an ImageLoaderInterface interface and abstracted the image importer to allow for other formats of image imports
    • Added new ImageIOLoader to handle .png, .bmp, .jpeg/jpg files
    • Created static import method in new final ImageLoader
  • Query
    • Created new QueryCommand interface to handle queries from the controller that executes actions given arguments and abstracted it in AbstractQueryCommand
    • Created queries for each type of query a user can provide to the program
  • ImageFilter
    • Created new class ImageFilter with static filter method to handle image kernel processing with support for kernels of varying odd dimensions.
  • ImageProcessingControllerImpl
    • Rewrote the start method to take advantage of new QueryCommands and utilizes a command pattern with a mapping of queries. This allows the controller to have more flexibility to add more command support in the future.

A Note About Our Images

Type each of these lines followed by Enter

  • You can call menu to get a list of all possible actions to perform.
  • You can call list to get a list of all the names of current images loaded/processed in the program.

Example Queries

  • load res/test3x4.ppm test
  • red-component test test-red
  • green-component test test-green
  • blue-component test test-blue
  • value-component test test-value
  • luma-component test test-luma
  • intensity-component test test-intensity
  • horizontal-flip test test-horizontal
  • vertical-flip test test-vertical
  • brighten test test-brighten 10
  • brighten test test-darken -10
  • gaussian-blur test test-gaussian
  • sepia test test-sepia
  • sharpen test test-sharpen
  • greyscale test test-greyscale
  • save res/test-red.ppm test-red
  • save res/test-green.ppm test-green
  • save res/test-blue.ppm test-blue
  • save res/test-value.ppm test-value
  • save res/test-intensity.ppm test-intensity
  • save res/test-horizontal.ppm test-horizontal
  • save res/test-vertical.ppm test-vertical
  • save res/test-brighten.ppm test-brighten
  • save res/test-darken.ppm test-darken
  • quit

Design

Model

  • ImageInterface: an interface that represents an RGB representation of an image.
    • Image: holds a 2D array of pixels that represents the image, and specifies the maximum RGB value.
  • ImageProcessingModel: an interface that represents a model that handles storing/loading images.
    • ImageProcessingModelImpl: holds a map of images corresponding to their names.
  • Pixel: represents a pixel with RGB values.
  • Kernel: represents an image processing kernel.
  • Transformation: represents a transformation to be applied on an image
  • ImageProcessingCommand: an interface that represents different types of processing that can be performed on images
    • BrightenCommand: takes in an Image and produces a new brightened/darkened Image.
    • PixelInPlaceProcessingCommand: an abstract class that represents image processing commands that do not alter the location of pixels.
      • BlueComponentGreyscaleCommand: takes in an Image and produces a new greyscale Image based on the blue component of the pixels.
      • GreenComponentGreyscaleCommand: takes in an Image and produces a new greyscale Image based on the green component of the pixels.
      • RedComponentGreyscaleCommand: takes in an Image and produces a new greyscale Image based on the red component of the pixels.
      • FlipHorizontalCommand: takes in an Image and produces a new horizontally flipped version of the image.
      • FlipVerticalCommand: takes in an Image and produces a new vertically flipped version of the image.
      • IntensityComponentGreyscaleCommand: takes in an Image and produces creates greyscale versions of images based on the intensity of each pixel.
      • ValueComponentGreyscaleCommand: takes in an Image and produces a new greyscale Image based on the value component of the pixels.
    • FilterProcessingCommand: an abstract class that represents image processing commands that apply a filter
      • GaussianBlurCommand: takes in an Image and produces a version with gaussian blur
      • SharpenCommand: takes in an Image and produces a sharpened version
    • TransformationProcessingCommand: an abstract class that represents image processing commands that apply a transformation
      • SepiaProcessingCommand: takes in an Image and produces a sepia version
      • LumaComponentCommand: takes in an Image and produces a new greyscale Image based on the luma component of the pixels.

View

  • ImageProcessingView: an interface that represents a view for the image processing program.
    • ImageProcessingTextView: text-based implementation that can handle rendering messages.

Controller

  • ImageLoader: loads images of type PPM, PNG, BMP, JPEG, and JPG as Image objects.
  • ImageExporter: converts Image objects to their String PPM representation and saves them as type PPM, PNG, BMP, JPEG, or JPG files.
  • ImageProcessingController: represents a controller for the image processing program.
    • ImageProcessingControllerImpl: implementation of the controller that interacts with a text-based view.
  • QueryCommand: interface that represents a potential query a user might make
    • AbstractQueryCommand: an abstract class that represents the queries used for the text-based controller
      • BlueComponentQuery: handles queries for blue-component processing
      • BrightenQuery: handles queries for brightening/darkening processing
      • FlipHorizontalQuery: handles queries for horizontal flip
      • FlipVerticalQuery: handles queries for vertical flip
      • GaussianBlurQuery: handles queries for gaussian blur
      • GreenComponentQuery: handles queries for green-component processing
      • IntensityQuery: handles queries for intensity processing
      • ListQuery: handles queries to list all images
      • LoadQuery: handles queries to load an image
      • LumaQuery: handles queries for luma component processing
      • MenuQuery: handles queries to return the menu
      • QuitQuery: handles queries to quit
      • RedComponentQuery: handles queries for red-component processing
      • SaveQuery: handles queries to save images
      • SepiaQuery: handles queries to apply sepia
      • SharpenQuery: handles queries to sharpen images
      • ValueQuery: handles queries for value component processing
  • ImageFilter: handles applying filters to images

Other

  • ExceptionMessage: enumeration for common exception messages throughout our program. Helps us not have to remember the exact message to write.

Decision Making

  • We tried to make all components as separate and independent as possible, and tried to create our implementation for our models as immutable as possible.
  • We did not want our command implementations to take in models or Scanners and wanted it to solely handle manipulating a given Image and producing a new processed version.
  • We had to rewrite a majority of our controller to make it more versatile for more functionality down the line.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages