-
Hero
ITM Ue - Aufgabe 1
Assignment 1 - Digital Image Processing
About
In this assignment you will use the Java imaging API to load, transcode and store images. You will also use the API to extract some basic metadata from the images and store them to a text file for fast access.
Installation/Deployment
If you want to use an IDE for development, there are some HOW-TOs - use them at your own risk
Please contribute here to improve them:
Background
- for beginners/java newbies: Sun java tutorial

- work through the Sun java tutorial for "2D Graphics"

- learn about java exception handling

- Your programs should be stable in the sense that invalid input files should be ignored (a message should be written to System.err) rather than stop the program execution! Your programs will be tested with other (possibly corrupt) image files than the ones in the assignment zip file).
- analyze the java files in the itm/image and in the itm/model package
- you have to be able to explain how these classes work when you hand in the first assignment!
- In order to fulfill task 1.3 you should refresh your knowledge about basic trigonometry and matrix/vector multiplications
Tasks
Task 1.1: comparison of image formats - 20 P
Update the file java/itm/image/ImageConverter.java so that one can call the java program with 4 parameters, an input file/directory name, an output directory name, a target file format and an optional quality parameter. The program should be able to
- read the images
- convert them to the passed target format
- store the image to the output directory.
- For BMP and PNG files it is ok to use the default image writer.
- For JPEG a configurable writer has to be used. The quality parameter has to be passed to this writer.
The output filename for BMP and PNG files should be the original name appended with ".bmp" and ".png" respectively.
The output filename for JPEG files should conform to the following structure: (original name)-(quality).jpeg Example:
input: image1.gif
output: image1.gif.bmp
output: image1.gif-0.5.jpeg
- test your program with the files in the media directory
- test your program with your own images!
- use your program to convert the ITM test images (please choose 4 images for comparison!):
- Convert them to the following formats: BMP, PNG, JPEG (quality:0), JPEG (quality:0.5), JPEG (quality:1.0)
- Summarize and compare the results in a spreadsheet (e.g. an Excel sheet):
- compare the filesizes of the original and the created files
- compare the quality of the resulting images manually (use "GOOD", "MEDIUM", "BAD")
Questions:
Additionally answer the following questions in written form:
- Did the file sizes increase or decrease when you used different formats? Why? What is the difference between lossy and lossless image formats?
- How many bytes are required in theory (i.e. ignoring any file format overhead and image compression) to store a 200x200px monochrome thumbnail (i.e. a binary image)?
- How many bytes are required (in theory again) if you want to store the same image with 16 possible colors?
Task 1.2: extract/get image metadata - 20P
The class AbstractMedia is a simple, abstract superclass for storing metadata associated with a media file (an image, a video, an audio...). It provides functionality for storing
- a reference to the media file
- a name of the media (by default the filename)
- a list of tags for semantic annotation
- functionality for deserializing/serializing the object from/to a string
- functionality for storing/loading the object to/from a text file.
First, take a good look at the AbstractMedia class. The class ImageMedia should extend AbstractMedia by image specific properties. Update the file ImageMedia.java so that
- it can store the following metadata
- width (integer)
- height (integer)
- number of image components (integer) - (see java.awt.image.ColorModel)
- number of image color components (integer) - (see java.awt.image.ColorModel)
- transparency (integer) - (see java.awt.image.ColorModel)
- pixelSize(integer) - (see java.awt.image.ColorModel)
- colorSpaceType(integer) - (see java.awt.image.ColorModel)
- orientation (integer) - (either ImageMedia.ORIENTATION_LANDSCAPE or ImageMedia.ORIENTATION_PORTRAIT)
- provide get/set methods for these properties
- extend the serializeObject() and deserializeObject() methods to make sure your metadata is stored/loaded!
Now update the class ImageMetadataGenerator.java so that it
- loads an image
- gets the metadata from this image
- stores this metadata to the media object
Filename example: input: image1.jpg
output: img_image1.jpg.txt
Example of a metadata file: type: image
file: webapps\itm\media\img\b17barb026.jpg
name: b17barb026.jpg
size: 261328 bytes (261kB)
tags: image,jpg,
width: 1024
height: 768
numComponents: 3
numColorComponents: 3
transparency: 1
pixelSize: 24
orientation: 0
colorSpaceType: TYPE_RGB
Questions
- Critically discuss the used format for storing the image meta data. Why do you think the used format is good/bad?
Task 1.3: load images and convert them to thumbnails - 35P
Update the file ImageThumbnailGenerator.java so that
- one can call the java program with 2 parameters, an input file/directory and an output directory name.
- the program should read the file(s)
- the program should rotate the image 90 degrees clockwise in case it is not in landscape-orientation.
- Carefully think about what happens if you apply a rotation to an image!
- the program should scale the image to a maximum width of 200px
- if the image width exceeds this value: downscale the image to fit the maximum thumbnail width
- DO NOT distort the image - the aspect ratio of the image has to be preserved
- if the image is smaller than the thumbnail size (i.e. width and height are smaller than 200x100px), create a new 200x100px BufferedImage and print the image to the center of this BufferedImage.
- Check your results:
- Use the affine transformation API
for all image transformations. - All resulting thumbnails should have a width of exactly 200px
- What is the maximum height of a thumbnail? why?
- No parts of an image should be missing (cropped)!
- all originally portrait-oriented images should be rotated by 90 degrees clockwise
- the program should write the result to an output file in PNG format
Three example thumbnails:
2009_itm_examplethumbnails.png
owner: niko.popitsch
image/png
2009_itm_examplethumbnails.png
input: image.jpg
output: image.jpg.thumb.png
Questions
- What is an affine transformation?
- What affine transformations are supported by Java2D?
- What 2D transformation matrix is required to rotate a point by 90 degrees counterclockwise (around the origin)? Explain.
Task 1.4: create histogram representation for images - 25P
Update the ImageHistogramGenerator.java so that
- start with reviewing the code in utils/Histogram.java
- one can call the histogram java program with 2 parameters, an input file/directory and an output directory name.
- read the pixel information and extract colors from it
- how many color components can an image have? take this into consideration!
- the program should plot the histogram by calling the appropriate function from utils/Histogram.java class
- find the optimal image dimensions for best visualization
Example of a histogram:
2010_itm_examplehistogram.png
owner: martin.kysel
image/png
2010_itm_examplehistogram.png
Filename example:
input: image1.jpg
output: img_image1.jpg.hist.png
Questions:
- Can the created histogram be used to reconstruct the image? What other information would be needed?
- Would your function work with the HSV or CMYK color space?
- Explain the difference between an individual color histogram, a combined color histogram and an intensity histogram. What information is displayed in each of these diagrams? What histogram type did we use?
- Explain the concept of histogram bins.
Required Results
You have to hand in the following results for this assignment:
- A reworked ImageConverter.java that corresponds to the above mentioned specification
- A reworked ImageMedia.java that corresponds to the above mentioned specification
- A reworked ImageMetadataGenerator.java that corresponds to the above mentioned specification
- A reworked ImageThumbnailGenerator.java that corresponds to the above mentioned specification
- Answers to all above mentioned questions in written form (1-2 A4 page maximum!) - see file Answers.txt.
Please make sure you meet all formal criteria for turning in your assignmentlink to:ITM 10 UE Main
owner: niko.popitsch
solution! .
Resources
Last edited by Super; 18-04-2010 at 20:03.
-
-
Hero
Last edited by Super; 18-04-2010 at 20:03.
-
-
Veteran
sind die lösungen offline?
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks