Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

EECS 2030: Lab 2

Introduction

For this assignment you will finish implementing a command-line application that takes one argument – an image file name (JPG, PNG, or GIF files can be used), reads the image from the specified file and processes it as soon as the user clicks a button in the application         window, performing one of the two operations: blurring or edge detection. All operations are based on convolving images with proper kernels1 .

The actual image processing is to be done in a dedicated class called ImageFilter. The class should be a utility class (i.e., it is not meant to be used to create objects).

To run your code from the command-line during the development, you can add the following

changes to your Run Configurations:

 

Currently, the main methods always loads the flower.png image.

Please leave your classes in the default package.

Merging Images

For your application, you will have to write a method

publicstaticvoid mergeImages(int[] imageData1, int[] imageData2, intwidth)

The pixels of two images stored in two one-dimensional arrays as integers need to be      combined (averaged) and stored in the first image. This operation needs to be done         separately for each of the three colour channels; basically, you cannot simply average the integer values representing a colour pixel, with all three components as one 32-bit int.

Edge Detection

For edge detection, your will have to implement the following method

privatevoidedgeDetection(int[] imageData, intwidth)

Feel free to use any kernel you can find; you can hard-code it in your Java code. Link [1] from the previous page contains some possible examples of edge detection kernels. The kernels   for edge detection are typically 2D kernels, and you will need to perform a 2D convolution      operation. In case any pixel coordinate are outside of the image boundaries, replace the        indices with either 0 or the image size − 1 (whichever appropriate). Note that both input   and output pixels are in the same row.

Image Data Internal Format

The images are read for you into a BufferedImageobject (called image). Among many      things, BufferedImageallows one to query image parameters, such as width and height, as well as reading it into a 1D array of int’s (in the starter code – rgbData).

The data for every pixel has the following format (you can assume that all images will use 24- bit colour, with 8 bits per channel): 0x__RRGGBB2 , where RR, GG, BB are red, green, and   blue bytes respectively. The 8 most significant bits are not used. The individual colour           components can be extracted using bitwise operations, as you will notice in the code             fragments (look inside edgeDetection).

Remember that you can always calculate the image pixels addresses in the 1D array using the following procedure:

image1DIndex = imageRowIndex * image.getWidth() +  imageColumnIndex

Starter Code

You are expected to work with the starter code supplied (find the TODO sections). Feel free   to create any private methods if needed. You may modify the code as you see fit – as long as the source and the result images are shown in the same windows at the end.

The application displays its output to the right of the original image window. Your methods    should not assume any limits for image sizes. E.g., if you need to create a temporary array in your code, do not assume the images are no larger than N ×M, where N and M are“huge”   numbers. Instead, read the image dimensions from the image object (or equivalent) and       create that temporary array of the exact size required.

You dont have to understand the Graphical User Interface (GUI) code written using Java Swing, however, you might find it useful for the future.

An example input and the output the application produces for merging two images. The flower image is merged with another image, named Trees.png.

 

An example input and the output the application produces for edge detection:

 

Grading

The assignment will be graded using the Common Grading Scheme for Undergraduate         Faculties3 . We look at whether the code passes the unit tests, and whether it conforms to the code style rules.

Submission:

You have to submit to eClass the following files (and no more):

ImageFilter.java

GraphicsApp.java

group.txt (optional, contains student numbers and names of the students in the group)

Academic Honesty

Direct collaboration (e.g., sharing your work results across groups) is not allowed (plagiarism detection software may be employed). However, you’re allowed to discuss the assignment    requirements, approaches you take, etc.

You may not use any code from outside sources, even if it is your own code you wrote for

another assignment, project, hobby, etc.