CS6825: Computer Vision word cloud

Image Arrays Exercise

due April 18, 11pm but may checkoff in class 20th

50 points

In this exercise, you will gain experience with multi-dimensional arrays as well as use in image manipulation. This application will help you start your Project 2.

Program Purpose

The application will be to create a simple image processing program that will brighten each pixel value in an image (each element in the array representing the image) by adding to it a constant value making sure the resulting value does not exceed 255. The method you will write that will brighten the image is called brighten(int x) x is the ammount you are increasing all of the image pixel values by. It will then save the image to the original file it read it from.

 

Tools to View Images

Tools to download a tool to open up and display PGM files which
is the image format we are using for this project.

 

Sample Image

Click here to download a sample image file to work with.


Sample Code to Start With

 

  • USE THE PARTIAL CODE located in this directory: Read carefully each class...there is code you will need to change and implement see the various comments, tips. There are 5 classes.
    • ImageApplication = The main class that will launch a FileDialog that will ask user to select an image file (try one above) then it will load the file.
        • File loading: Change the loading of images to use MediaTracker class to make sure the image loaded successfully. Read in the Java API about the MediaTracker class to see how it could be used
          • 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)
        • Uncomment some of the code -
          • here is some code commented like the following that you will want to uncomment --but, you need to understand it and it is basic java.awt (not even swing) to display a frame containing the image.

            //create frame to display image in
            //frame_image_display = new ImageFrame();
            //frame_image_display.setVisible(false);

         

        • Like the following that creates an instance of another class called ImageData which stores the data in the image for future processing

          /Class to hold image data to be able to
          //manipulate
          //ImageData img_data; //YOU MUST CREATE********

        • Create CODE to invoke brighten and save methods of ImageData class youwill have to add code to call:

        img_data.brighten(x); //you will need to create brighten method of ImageData class

        img_data.save(); //you will need to create save method of ImageData class

    • ImageData = class that reads in the data from a file and saves it in a class variable datastructure
      • currently constructor reads in data into a class variable called data[] you can consider altering this to instead of a 1D array a variable of classs type java.awt.Image. Up to you but, read about that basic class java.awt.Image and decide if you like it or like data[] array.
      • brighten(x) create this method as discussed below
      • saveToFile() create this method that will save the current data in ImageData instance img_data to the original file you read it from.


    • ImageFrame = class to display image data.
    • AboutDialog = about dialog frame
    • QuitDialog = quit dialog frame



How to Get Started

  • Read the project page entirely
  • Read the code --See the comments in the code, to help you get started.
  • See tips above and below that gives you directions on things you will need to create/change in sample code.

Special new methods of ImageData class

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 rather than having the data variable of ImageData being a 1D array. BUT, this is not a requirement. However, feel free to alter this code as long as you get it to work

 

>> method

brighten(int x) = you need to create this method as described in the algorithm below that will work on this classes ImageData.Image and brighten each pixel by a value of x.

 

>> method

saveToFile() = saves to file you read the image from the current data.

 

Introduction - Image Manipulation - Brightening method algorithm

##############YOU NEED TO ADD CODE THAT LETS YOU########

Brightening algorithm

You need to implement the following algorithm:

for (each element in the 2D array image, i) {

     i = i + value;

    if (i > 255) i = 255; //saftey check as pixel value cant be above 255

}

 

 

Deliverables

  1. Turn in working.pdf = pdf tell me if the application is work or not and IF NOT - tells me what you think you have implemented and what you have not. IF it is working it should contain 3 screen shots:
    1. Screen Shots of code running
    2. before image
    3. after image (make the value you are using to brighten large enough to see a difference and not so large the who image turns white)
  2. Turn this into BB->Exercises->Exercise 1
© Lynne Grewe