728x90 AdSpace

Latest Article

Picture Manipulation C++ Assignment Project Homework Task case study Online





Picture Manipulation Assignment Project Homework Task case study Online 
WHAT YOUR APPLICATION SOULD BE DOING BY NOW?
In the first phase of the project development, the focus was on Picture Manipulation. This handout assumes that your application developed so far is able to:
 Read a picture from a file
  Read the RGB color information from a pixel in a picture
Rotate a picture 90o clockwise and 90o anticlockwise
 Flip a picture horizontally and vertically
  Write a picture to a file
  Create mirror images of pictures OR adjust color information.
WHAT IS THE FOCUS OF THIS HANDOUT?
In this phase of project development, you will be building a small Search Engine (and its extensions) for finding pictures by matching their pixels and color information. You have to write a separate class for this phase which should be called SearchEngine. The key features to be implemented are as follows:
Compare two images for similarity
Create a listing/database of all images in a certain directory
 Find a matching image in a directory
   Detect and Remove duplicate images in a directory
In this assignment, you will also learn to use Java Documentation which will be your guide for using classes from Java Library in your code. The complete documentation is available at http://java.sun.com/javase/6/docs/api/ where the left hand pane lists all packages and classes included in the Java Library.
You will import java.io in your code (apart from other packages that you may need to import) under which you will find various classes, the most important being File in the scope of this assignment. This class has methods for listing files in a directory, getting length of file, deleting a file and almost all sorts of operations that you can do to a file. Now it is on your part to decide what you will use in order to implement the required tasks.
Note that this is a creative assignment so one reason of exposing you to the java library is to allow you to add your own operations and functionality to your application – which is AFTER you are done implementing the required tasks. If you have any bright ideas and you want to implement and incorporate them in your application, the Java Docs is your guide to explore the things you can do. Although you may not be awarded extra marks for this but towards the end, it will be your application and you will feel good about it.
IMPORTANT: You should try and optimize your code/algorithm so your application runs efficiently with large image files and huge directories – if you have a bad algorithm and it takes unnecessary time to do what is required, it would take very long for larger inputs and thus would not leave a good impression of your application.
Turn to the next page for details and hints on the required tasks.


In all of the following methods that you will implement, you are required to apply thorough checking on the inputs received. Your program must not crash if an invalid input is passed to your method. Of course you will not check for invalid data types but you will definitely check for valid values of inputs before using them in your code. If you find an invalid input, you should smartly exit from the function letting the calling function know about the error.
COMPARE TWO IMAGES
The method that you will write should take two Picture objects and a threshold value of type int. You are required to compare the two pictures and tell if the pictures are exactly the same, similar or not matching at all. The prototype for this method is:
public int compareImage(int threshold, Picture p1, Picture p2)
You may be wondering why this function returns an integer. Well you could have just printed the results inside this function but this seems to be a better way because this way, the calling function would also know the results. You will follow the following convention to read results returned by this function:

Return Value
Result
0
Pictures are exactly the same
1
Pictures are similar
2
Pictures do not match at all
-1
Invalid Input received

Your calling function should print the results on screen depending upon what value is returned by this method. You will not print anything in this method.

ALGORITHM FOR SIMILARITY:
There should be no problem in checking if the two pictures are the same. For similarity, you will use the threshold value passed to this method. You will check if the difference in color values for every pixel is less than this threshold value or not – if it is, then the pictures are similar and if it is not (and the pictures are also not the same) then the pictures do not match at all. For example, if your threshold value is 5 and the colors of two pixels being compared are (100, 90, 90) and (99, 86, 93), then you can say that the two pixels are similar.
CREATE A LISTING/DATABASE
For this feature, you will write a method that takes a String as a parameter. This String object will hold the path of the directory which is to be searched for images. The prototype for this method is:
public ArrayList<String> getList(String directoryPath)
The list of files (their names) in a directory should be returned from this method as ArrayList of type String. Ignore all subdirectories and non-images in the given directory – the ArrayList must only hold names of image files in the directory. The calling function, when it receives the ArrayList returned by this method, should traverse it and print its contents. Again, you will not print anything in this method. You can assume that all image files will be of JPEG format with the extension .jpg.
If you get an invalid input or a directory path that does not exist, return null from this method and apply a check in your calling function. You will not return null if no files exist in the specified directory – if you don’t get a list of filenames at the calling end, you should be able to tell whether an error occurred or no files were found in the directory in which case the appropriate message should be printed on the screen at the calling end.


FIND A MATCHING IMAGE
So far so good, you’ve created a method to compare two images and you have a way to get a list of image files in a specific directory. Next, write a method that finds all matches of a given image in a directory. The prototype for this method is:
public ArrayList<String> findMatch(Picture p, String directoryPath)
Again, this function returns an ArrayList of type String which holds filenames of all matching images found in the directory. This method is passed an object of type Picture and you have to find similar/exact matches of this picture in the directory path which is also passed to this method as a String. Ignore all subdirectories and non-images in the given directory - you can assume that all image files will be of JPEG format with the extension .jpg. The calling function, when it receives ArrayList returned by this method, should traverse it and print its contents. Do not print anything in this method.
If you get an invalid input or a directory path that does not exist, return null from this method and apply a check in your calling function. You will not return null if no matching files are found – if you don’t get a list of filenames at the calling end, you should be able to tell whether an error occurred or no matching files were found in which case the appropriate message should be printed on the screen at the calling end.

DETECT DUPLICATE IMAGES
Duplicate in this context means exact, not similar. This method just takes the directory path as a String and searches this directory for duplicate images. The prototype of this function is:
public ArrayList<String> findDuplicate(String directoryPath)
You will not pass the picture object to this method; your algorithm should automatically check duplicate occurrences of image files in the directory and remove them from the directory. Ignore all subdirectories and non-images in the given directory - you can assume that all image files will be of JPEG format with the extension .jpg. The names of all the files that are deleted by this method go in the ArrayList of type String which is then returned from this method. The calling function, when it receives the ArrayList, should traverse it and print its contents. Again, do not insert any print statement in this method.
If you get an invalid input or a directory path that does not exist, return null from this method and apply a check in your calling function. You will not return null if no files are removed – if you don’t get a list of filenames at the calling end, you should be able to tell whether an error occurred or no duplicate files were found in which case the appropriate message should be printed on the screen at the calling end.
HOW TO MERGE PHASE 1 AND PHASE 2:
This phase is implemented as a separate class. Your main method resides in the class that you created in Phase 1 so why not just let it stay there and declare this class there.
You should keep in mind that the next phase will require you to build a GUI layer on top of all this so your class (from phase 1) should be such that you face minimum difficulty when linking your function calls to the GUI – it should be organized (broken down into proper methods – everything must not be in the main method) and everything should be easily identifiable. 
no image
  • Title : Picture Manipulation C++ Assignment Project Homework Task case study Online
  • Posted by :
  • Date : 10:17
  • Labels :





  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment

Top