Smita Rosemary and Ben Bishop – CS3500 Fall 2022, Northeastern University
This project represents an Image Processor that allows you to manipulate and enhance a given image.
The Image Processor allows a user to load an Image into the program, save it, and apply transformations such as:
- Visualizing the red, blue, green, alpha, luma, or intensity channels of each pixel in an image as a greyscale image
- Vertically or horizontally flipping an image
- Brightening or darkening an image
- Blurring or sharpening an image
- Filtering an image to greyscale or sepia
The user interacts with the Image Processor through the command line interface (CLI). or they can also specify a script file to run as a command line argument, which will run the script and exit the program. More details on interacting with the program can be found in the USEME.md file.
The program currently supports "PPM" images and any image type supported by the Java ImageIO library. We guarantee support for "PNG", "JPG/JPEG", and "BMP" images. The program will automatically detect the format to save to/load from based on the file extension.
We have provided two test images located in the res
folder named ExampleImage.ppm
and ExampleImage2.png
. We have also processed this image with all available commands to visualize
transformations without running the program and saved them to the subfolder res/processed
. ExampleImage.ppm
was created by Smita Rosemary, and has been used with her
permission. ExampleImage2.png
was created by Ben Bishop, and has been used with his permission.
Instructions on how to use the program can be found in the USEME.md file.
Second version. Retained all existing functionality, and added support for new transformations and the ability to run from a script file.
- Added support for blurring, sharpening, and applying a sepia or greyscale filter to an image.
- Added more implementations of the
ImageTransformation
interface in the model (Blur
,Sharpen
,Sepia
, andGreyscale
) to apply these filters toImage
s. - Added a new implementation of the
ImageProcessorCmd
interface in the controller (FilterCmd
) to handle the execution of theblur
,sharpen
,sepia
, andgreyscale
commands. - Modified the
addCommands
method in theImageProcessorControllerImpl
class to add the four new commands to the map of supported commands. - Updated the
renderMenu
method in theImageProcessorViewImpl
to include the new filters in the menu. - Added new test methods in both the
ImageControllerTest
andImageTransformationTest
classes to test the new commands. - Added new example images in the
res/processed
folder to demonstrate the new filters.
- Added more implementations of the
- Added a new higher-resolution example image in the
res
folder (ExampleImage2.png
) to make visualization of the new filters easier. - Added support for loading and saving images from more conventional file formats
- Added a new implementation of the
ImageFileHandler
interface in the controller (ImageIOHandler
) to handle loading and saving images using the Java ImageIO library. This library supports a wide variety of image formats, including "png", "jpg", "jpeg" , and "bmp". These four formats are guaranteed to be supported by the program, but others may be as well. - Modified the
LoadCmd
andSaveCmd
classes to check the file format of the image to be loaded/saved and use theImageIOHandler
if it is not a "ppm" image. - Added new test methods in the
ImageControllerTest
class to test loading/saving images using the new file formats.
- Added a new implementation of the
- Added support for loading and running a script file as a command line option.
- Modified the
ImageProcessorRunner
class to check for the presence of the-script <script text file>
command line option, and fallback to the standard CLI if it is not present.
- Modified the
- Updated the test methods in the
ImageProcessorViewImplTest
class to ensure the new menu is displayed. - Added support for running the program from a JAR file (see USEME.md for details).
- Added a new
MANIFEST.MF
file to theMETA-INF
folder to specify the main class of the program. - Built the program into a JAR file located at
res/ImageProcessor.jar
.
- Added a new
- Updated the
README.md
file to include more information about the image processor and the new features implemented in this version. - Created a new
USEME.md
file to document how to use the program.
ImagePPMHandler
- Fixed that the
process
method would throw an exception if the file was empty. - Fixed that the
process
method did not close scanners it opened.
- Fixed that the
Visualize
- Replaced typecasting with rounding in the
transform
method to result in more accurate transformations.
- Replaced typecasting with rounding in the
- Cleaned up JavaDoc comments to be more consistent and accurate.
- Cleaned up error messages to be more consistent and accurate.
Initial version. Included the following initial features:
- Use the image processor within the terminal
- Load an image into the program
- Save an image from the program
- Brighten or darken an image
- Flip an image horizontally or vertically
- Visualize the red, blue, green, alpha, luma, or intensity channels of each pixel in an image as a greyscale image
- View a menu of commands
- Transform multiple images at once
To more easily visualize these classes, we have provided a class diagram below:
- Interfaces
ImageProcessorController
: Represents a controller for the image processor. As the user inputs commands, the controller validates the parameters and executes them. The controller also handles the exceptions thrown by the model and view, and displays them as messages to the user via the view.- Implementations:
ImageProcessorControllerImpl
: Implements theImageProcessorController
interface supporting the above transformation commands as well asload
,menu
, andsave
.
- Implementations:
ImageProcessorCmd
: Represents a supported command that the image processor can handle. The command is executed by calling theexecute
method, and implemented subclasses of this interface will handle the execution of the command- Implementations:
MenuCmd
: Implements theImageProcessorCmd
and represents themenu
command offered by the processor.LoadCmd
: Implements theImageProcessorCmd
and represents theload
command offered by the processor.SaveCmd
: Implements theImageProcessorCmd
and represents thesave
command offered by the processor.BrightnessCmd
: Implements theImageProcessorCmd
and represents thebrighten
anddarken
command offered by the processor.HorizontalFlipCmd
: Implements theImageProcessorCmd
and represents thehorizontal-flip
command offered by the processor.VerticalFlipCmd
: Implements theImageProcessorCmd
and represents thevertical-flip
command offered by the processor.VisualizeCmd
: Implements theImageProcessorCmd
and represents thevisualize-<componenet>
command offered by the processor.FilterCmd
: Implements theImageProcessorCmd
and represents theblur
,sharpen
,sepia
, andgreyscale
commands offered by the processor.
- Implementations:
ImageFileHandler
: Represents a model used to convert image files intoImage
objects.- Implementations:
ImagePPMHandler
: Implements theImageFileHandler
interface for converting PPM image files intoImage
objects, and vice versa.ImageIOHandler
: Implements theImageFileHandler
interface for converting images intoImage
objects using the Java ImageIO library.
- Implementations:
- Interfaces
-
Image
: Represents an image and it's pixels.- Implementations:
ImageImpl
: Implements theImage
interface, each image is represented by a 2D array of colors.
- Implementations:
-
ImageTransformation
: Represents a macro that can be applied to anImage
to transform its pixels in some way.- Implementations:
Brightness
: Implements theImageTransformation
interface and represents a macro that adjusts the brightness of an image, both up the scale and down.HorizontalFlip
: Implements theImageTransformation
interface and represents a macro that flips an image along the horizontal axis.VerticalFlip
: Implements theImageTransformation
interface and represents a macro that flips an image along the vertical axis.Visualize
: Implements theImageTransformation
interface and represents a macro that transforms the images to visualize the greyscale image by one of the following color components :Red
,Blue
,Green
,Value
,Luma
, orIntensity
.Blur
: Implements theImageTransformation
interface and represents a macro that blurs an image.Sharpen
: Implements theImageTransformation
interface and represents a macro that sharpens an image.Sepia
: Implements theImageTransformation
interface and represents a macro that applies a sepia filter to an image.Greyscale
: Implements theImageTransformation
interface and represents a macro that applies a greyscale filter to an image.
- Implementations:
-
StoredImages
: Represents a collection ofImage
s that have been loaded into the program by the user, identified by the image's file name selected by the user.- Implementations:
StoredImagesImpl
: Implements theStoredImages
interface. The stored images are represented by aMap<String, Image>
, the string representing a fileName.
- Implementations:
-
- Interfaces
ImageProcessorView
: This interface represents the view of the Image Processor. It contains methods that the controller can call to render the view.- Implementations:
ImageProcessorViewImpl
: Implements the ImageProcessorView interface and it's methods. Handles appending all the messages from the controller to the user.
- Implementations:
ImageProcessorRunner
: Contains the main method which runs the image processor in the terminal for the user. The class will parse any command line arguments and use them to initialize the controller and view.