CS6825: Computer Vision word cloud

Project 2: Image Processing Program

Phase 1(20 points)Due start of class April 27th
Phase 2 (200 points)Due 11pm May 4


You are to create a program that is a GUI Java application. It will allow the user to load an image and present the user with a set of Image Processing Functions that they can choose to apply. After loading an image a display of the image will pop up.

Now the user can choose various operations and it will be applied to the active image window. The new image will be displayed in the same active window.

Also, at any time the user should be able to save the image data currently being displayed to a file (in the original JPEG/GIF format). Note that the image data that has been processed is not saved to a file until the user specifically asked to do this operation. You should save the file in jpeg format.

 

This project is broken up into two phases to help you with breaking down the problem. The first phase will only implement the image loading, display, and saving to a file (in JPEG/GIF). For phase 2, you will have to implement the following image processing operations: thresholding, image negative, contrast stretching and edge detection (Sobel). The elements of each phase are described below. BECAUSE you are learning how to manipulate an image and create code to do this at a pixel level, you MUST write these algorithms yourself. YOU CAN NOT use a funciton routine from a third party software package or from a java package.

After a valid image is loaded, the following operations (displayed as menu items) should be enabled:

  • File Menu = Open (partially done for you in sample code), Save As, Exit (partially done for you in sample code)
  • Edit Menu= Undo
  • Process Menu = Threshold, Contrast Stretch, Image Negative, Edge Detection

Note, when most options are choosen, other windows that may ask for necessary relavent user input may pop-up before the image function takes place on the image already loaded. For example, when Threshold selected, asks for threshold value. See below for details.


IMPORTANT: After each selection is made, it is applied to that active image (see ActiveImage object below) window and the processing is completed the new resulting image should be displayed in the same active window. Any further processing requested by the user will be done on the active image. For example, this means that you can first create a edge detected image and then do thresholding on the edge detected image.

Note: You are only required to load the standard formats of JPEG and GIF that Java accepts.

You should be able to load either a color or greyscale image. See information below about different operations and how to handle it for color images.

THIS IS NOT GROUP WORK. You must do it individually.
 

Some Code Requirements

  • You may use the following partial java code to get you started. Included in here are java source files as well as the GUI files needed. (setup for work in the required Eclipse environment). This will open up an image and display it in a new window. It also saves raw data ONLY does not save as a JPEG or GIF as you will need to do. NOTE: this is old code using AWT interface --- you are more than welcome to convert it to swing or any other Java framework/package for GUI you like to use. While GUI for professional applications is important it is not the focus of our class in this project.
  • See the comments in the code, to help you get started.
  • Change the loading of images to use MediaTraker class to make sure the image loaded successfully.
  • You will need to use PixelGrabber class to grab data into an array that you can manipulate. (there are some examples of this in the partial code)

Required Data Classes and their Meanings

Class

Meaning

ImageData

Contains information about the Image (size-#rows, #columns, format, filename) as well as the image data itself.

 

tip: You may be able to use as variable of this class the Image class in Java, or there may be other classes out there.

tip: see the ImageData class in the partial java code which will start you out. You need to modify as required and desired.

 

Required Data OBJECTS and their Meanings

Object Name

Class

Meaning

ActiveImage ImageData Contains current image being displayed in the current window (note you can have multiple. Represents the current state of the image as pertaining to processing
BackupImage ImageData

Contains an image that represents the ActiveImage before the last processing operation selected.

Note: Initially, before any processing has been done, it will contain the same information as ActiveImage.

 

Phase 1

In this phase, you will develop a GUI java application that will allow the user to load an image and display it. The user can save the image data currently displayed. The user can also undo the last operation applied to it (note- if no operations applied Undo should not be enabled).

Eventhough you will not have implemented the image processing operations you should have the Process menu there to select them.

SW Development: I want you to use Eclipse IDE (latest stable version is preferred, not betas). Below I have listed the menus needed in your GUI application. Use the partial code (see above link) to help you get started. Note the partial code uses two frames - one for the main application and another frame (ImageFrame) for displaying the image. You can partion it in this fashion or combine if you want. However, most (except Exit and Open) must be associated with the window the Image is display in (in partial code provided this is the ImageFrame class).

File Menu

Option : File -> Open
Open image either JPEG or GIF. You will need to read on your own how to use Java Media Package or similar to do this. You will need to bring up a file dialog box to get location and name of file from user. You will store the image into the ActiveImage and the BackupImage objects

Option : File -> Save As
Save image as a JPEG or GIF. You will need to read on your own how to use Java Media Package or similar to do this. You will need to bring up a file dialog box to get location and name of file from user.

Option : File -> Exit
If this option is choosen simple exit the program. Make sure that you close any windows with images displayed in them.

 

Edit Menu

Option: Edit->Undo
This is where you in essence undo the last selected image operation (edge detection, negative,etc). If no operations have been selected then you will not have this menu option enabled. Note- you only have to undo the one last operation. So, after the user selects undo even if they have done 10 previous operations, they will not be able to any more than the once and the option will be disabled until a new operation is choosen (then it will be re-enabled). Tip: when undo is selected, you should move the content of the BackupImage object to the ActiveImage object and refresh the window displaying the new content in the ActiveImage object. Each time you do an Undo you ofcourse must refresh the display of the image frame.

Process Menu

Option: Process->Threshold
For phase one, does nothing

Option : Process -> Negaitve
For phase one, does nothing

Option : Process -> Edge Detect
For phase one, does nothing

Option : Process -> Contrast Stretch
For phase one, does nothing

 

Phase 2

You are now coing to implement the various Processing operations from Phase 1 that were not implemented

File Menu

Option : File -> Open
Same as Phase 1

Option : File -> Save As
Same as Phase 1

Option : File -> Exit
Same as Phase 1

 

Edit Menu

Option: Edit->Undo
This is where you can test this working....recall...This is where you in essence undo the last selected image operation (edge detection, negative,etc). If no operations have been selected then you will not have this menu option enabled. Note- you only have to undo the one last operation. So, after the user selects undo even if they have done 10 previous operations, they will not be able to any more than the once and the option will be disabled until a new operation is choosen (then it will be re-enabled). Tip: when undo is selected, you should move the content of the BackupImage object to the ActiveImage object and refresh the window displaying the new content in the ActiveImage object.

Process Menu

Option: Process->Threshold
If this option is selected, you must pop-up a diaglog box (called ThresholdDialogBox) where you ask for the threshold value between 0 to 255. It is up to you how you ask the user this information. Verify that this is a valid number if not return a message to user. Then threshold the image using this level and display the results. Display this new output image.

  • Note: if you have a color image loaded then apply the thresholding to the red, green and blue fields separately.
  • tip: make sure you store the previous image in the BackupImage and the new thresholded image in teh ActiveImage object.

Option : Process -> Negaitve
Create the negative image and display. Be CAREFUL not to create negative values!!!!

  • Note: if you have a color image loaded then apply the thresholding to the red, green and blue fields separately.
  • tip: make sure you store the previous image in the BackupImage and the new negative image in the ActiveImage object.

Option : Process -> Edge Detect
Apply the Sobel Edge Detector to the image in ActiveImage.

  • Note: if you have a color image loaded then FIRST convert the color image to a greyscale image (grey = (r+g+b) /3) and THEN do edge detection.
  • tip: make sure you store the previous image in the BackupImage and the new edge detected image in the ActiveImage object.

Option : Process -> Contrast Stretch
If this option is choosen you should perform contrast stretching, telling user information about the current contrast and somehow making an interface that lets the user alter (either up or down) the contrast of the image.

  • Note: if you have a color image loaded then FIRST convert the color image to a greyscale image (grey = (r+g+b) /3) and THEN do contrast stretching.
  • tip: make sure you store the previous image in the BackupImage and the new contrast stretched image in the ActiveImage object.

Evaluation Guidelines

Deliverables (and How to turn in)

  1. PHASE 1: Turn in only screen shots of the project working and a description in a pdf of the state of phase 1--what is completed and what is not. This is worth 10% of the points if you have turned in the items and they are fully functional. Note, you should have already done an exercise that actually finished most of the required work for Phase 1. Go to BB->Projects->Project2 Phase 1.

  2. PHASE 2: Fully comment and test out program. Post on Project 2 link in Projects on Blackboard (BB->Projects->Project 2 Phase 2). You MUST zip them up as a single file so that I can unzip into a test directory and run right away. YOU must setup all the ECLIPSE files necessary and send these.
  3. PHASE 2: IF YOU use additional classes not in standard Java, you need to have all of the files here...make a JAR file. I want to you to have the program ready to run already compiled!
  4. PHASE 2: Word Document (click here for template you MUST use) that details the following: HERE IS EXAMPLE FOR PHASE 1
    • Section 1 Execution Instructions: Instructions for me to download and run your code. YOU NEED to show me screen shots of you doing this from your uploaded blackboard code.....this forces you to make sure that I can run your code. You MUST have the following screenshots AND give description on what to do:
      • screenshot 1.1 = screen shot of your files uploaded to Project 1 turn in folder on blackboard
      • screenshot 1.2 = directory view of "temp" directory you unzipped file to showing the unziped files and directory structures.
      • screenshot 1.3 = Eclipse running where you have opened up project file in "temp" directory.
      • screenshot 1.4 = Eclipse running the application - show screenshot of it running. If I must do something beyond simply hitting the "run" button, you need to give screenshots and step by step instructions.
    • Section 2 Code Descpription: A describing how code is structured and the state of how it works. Give a describption for each filename listed.
    • Section 3 Testing: here you give screen shots of you running the various stages of the program as detailed here:
      • section 3.1: loading image -
        • screenshot 3.1a= pop-up file dialog box where you have selected the image you are going to load in your program.
        • screenshot 3.1b= the image being viewed in your application that was just loaded.
      • section 3.2: saving image
        • screenshot 3.2a = screen shot of active image in your application you are going to save
        • screenshot 3.2b = screen shot of file save as dialog box where you have specified a DIFFERENT name not used yet for this image.
        • screenshot 3.2c = screen shot after you do an open on the image you just saved in 3.2b
      • section 3.3: exit application
        • screenshot 3.3a = screen shot showing application gone (really this is nothing) BUT, if the application has errors on closing I want to see this!!!
      • section 3.4: thresholding
        • screenshot 3.4a = original image you are going to threshold shown in activeimage displayed in your application
        • screenshot 3.4b = pop-up dialog box asking user for threshold information, enter in the threshold value before screenshot
        • screenshot 3.4c = new image after thresholding in activeimage displayed in your applicaiton.
      • section 3.5: Undo Operation
        • screenshot 3.5a = thresholded image from screenshot 3.4c.
        • screenshot 3.5b = new image reverting back to unthresholded image AFTER you have selected the UNDO operation. This is the new activeimage displayed in your application.
      • section 3.6: negative
        • screenshot 3.6a = original image you are going to negate shown in activeimage displayed in your application
        • screenshot 3.6b = new image after negative operation done in activeimage displayed in your applicaiton.
      • section 3.7: edge detction
        • screenshot 3.7a = original image you are going to edge detection on shown in activeimage displayed in your application
        • screenshot 3.7b = new image after edge detection done in activeimage displayed in your applicaiton.
      • section 3.8: contrast stretching
        • screenshot 3.8a = original image you are going to contrast stretch shown in activeimage displayed in your application
        • screenshot 3.8b = pop-up dialog box asking user for input regarding contrast stretching enter in the information before screenshot
        • screenshot 3.8c = new image after contrast stretching in activeimage displayed in your applicaiton.
    • Section 4 Comments Optional any comments you have regarding your code (necessary if you code is not working, you need to tell me in detail what the problem is or what is missing)

 

NOTE: FOR PHASE 1 DUE DATE- you will only be asked to demonstrate the working items by turning in screen shots - YOU WILL get 10% of the points graded for this based on demonstrating full completion of Phase 1 --you will not be traditionally graded on partial credit. The goal of this is to make sure that you are staying on track in class and getting help if you need it prior to the due date. Also, don't forget you should have already done an exercise to help you out with much of Phase 1. Don't forget I have office hours.

NOTE: FOR PHASE 2 DUE DATE, ,will be traditionally graded (see evaluation guidelines) for the entire application code functionality when Phase 2 is turned in. For Phase 2, you will submit only 2 attachments 1 the zipped (use zip only) up source code and 2 the word document.

© Lynne Grewe