This is a program that processes .ppm, .bmp, .png, and .jpeg files and has the ability to load, manipulate, and export images.
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.
- 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
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 theImageProcessingCommand
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.
- We created a new
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.
Commands
- Added new abstract classes
FilterProcessingCommand
andTransformationProcessingCommand
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
- Added new abstract classes
Pixel
- Added support for aRGB to support transparency in .png images
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
- Created an
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
- Created an
Query
- Created new
QueryCommand
interface to handle queries from the controller that executes actions given arguments and abstracted it inAbstractQueryCommand
- Created queries for each type of query a user can provide to the program
- Created new
ImageFilter
- Created new class
ImageFilter
with static filter method to handle image kernel processing with support for kernels of varying odd dimensions.
- Created new class
ImageProcessingControllerImpl
- Rewrote the
start
method to take advantage of newQueryCommands
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.
- Rewrote the
- We created and processed our own test .ppm files.
- https://freepngimg.com/png/20698-mario-transparent-background
- https://unsplash.com/photos/H1cuGOjk8d8
- https://ichef.bbci.co.uk/news/976/cpsprodpb/17638/production/_124800859_gettyimages-817514614.jpg
- https://images.unsplash.com/photo-1623063921261-5a9914c19548?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8Ym1wJTIwcGhvdG98ZW58MHx8MHx8&w=1000&q=80
- 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.
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
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 imageImageProcessingCommand
: an interface that represents different types of processing that can be performed on imagesBrightenCommand
: takes in anImage
and produces a new brightened/darkenedImage
.PixelInPlaceProcessingCommand
: an abstract class that represents image processing commands that do not alter the location of pixels.BlueComponentGreyscaleCommand
: takes in anImage
and produces a new greyscaleImage
based on the blue component of the pixels.GreenComponentGreyscaleCommand
: takes in anImage
and produces a new greyscaleImage
based on the green component of the pixels.RedComponentGreyscaleCommand
: takes in anImage
and produces a new greyscaleImage
based on the red component of the pixels.FlipHorizontalCommand
: takes in anImage
and produces a new horizontally flipped version of the image.FlipVerticalCommand
: takes in anImage
and produces a new vertically flipped version of the image.IntensityComponentGreyscaleCommand
: takes in anImage
and produces creates greyscale versions of images based on the intensity of each pixel.ValueComponentGreyscaleCommand
: takes in anImage
and produces a new greyscaleImage
based on the value component of the pixels.
FilterProcessingCommand
: an abstract class that represents image processing commands that apply a filterGaussianBlurCommand
: takes in anImage
and produces a version with gaussian blurSharpenCommand
: takes in anImage
and produces a sharpened version
TransformationProcessingCommand
: an abstract class that represents image processing commands that apply a transformationSepiaProcessingCommand
: takes in anImage
and produces a sepia versionLumaComponentCommand
: takes in anImage
and produces a new greyscaleImage
based on the luma component of the pixels.
ImageProcessingView
: an interface that represents a view for the image processing program.ImageProcessingTextView
: text-based implementation that can handle rendering messages.
ImageLoader
: loads images of type PPM, PNG, BMP, JPEG, and JPG asImage
objects.ImageExporter
: convertsImage
objects to theirString
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 makeAbstractQueryCommand
: an abstract class that represents the queries used for the text-based controllerBlueComponentQuery
: handles queries for blue-component processingBrightenQuery
: handles queries for brightening/darkening processingFlipHorizontalQuery
: handles queries for horizontal flipFlipVerticalQuery
: handles queries for vertical flipGaussianBlurQuery
: handles queries for gaussian blurGreenComponentQuery
: handles queries for green-component processingIntensityQuery
: handles queries for intensity processingListQuery
: handles queries to list all imagesLoadQuery
: handles queries to load an imageLumaQuery
: handles queries for luma component processingMenuQuery
: handles queries to return the menuQuitQuery
: handles queries to quitRedComponentQuery
: handles queries for red-component processingSaveQuery
: handles queries to save imagesSepiaQuery
: handles queries to apply sepiaSharpenQuery
: handles queries to sharpen imagesValueQuery
: handles queries for value component processing
ImageFilter
: handles applying filters to images
ExceptionMessage
: enumeration for common exception messages throughout our program. Helps us not have to remember the exact message to write.
- 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
Scanner
s and wanted it to solely handle manipulating a givenImage
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.