Preview

Computer Research

Satisfactory Essays
Open Document
Open Document
724 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Computer Research
COMPS412F Tutorial 8

Activities

Objective:
The objective of this activity is to make use of JPEGImageEncoder and JPEGImageDecoder from com.sun.image.codec.jpeg.* to perform JPEG compression and to study how the compressed image quality is related to the amount of compression.

Description:
[pic]
The image on the left is the original Lenna image. The scrollbar controls the quality factor of JPEGImageEncoder. The image on the right is the compressed image. The compressed image suffers a various degree of loss depending on the scrollbar position.
When the application is first invoked, it reads in the original lenna.bmp image and displays it on the left. When the Compress button is clicked, it encodes the image and outputs it as a JPEG file. This step is performed by the following code segment: try {
File file = new File("test.jpg"); FileOutputStream out = new FileOutputStream(file); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(im.image); param.setQuality((float)(jSlider1.getValue()/100.0), false); encoder.setJPEGEncodeParam(param); encoder.encode(im.image);
}
catch (Exception ex) { System.out.println(ex);
}
In the above code segment, im.image refers to the BufferedImage object used to hold the image.
After that, the newly created JPEG file is read in and displayed on the right using the following code segment: try { bm = new ImageData(256, 256); File file = new File("test.jpg"); FileInputStream in = new FileInputStream(file); JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in); bm.image = decoder.decodeAsBufferedImage(); imagePanel2.showImage(bm);
}
catch (Exception ex) { System.out.println(ex);
}
By changing the quality factor, you can see how the compressed image quality is affected. You should also check the size of the JPEG file created.
Results:
The entire zip (jpegviewer.zip) file can be downloaded

You May Also Find These Documents Helpful

  • Good Essays

    The tag used to insert a image is <img> and this tag embeds an image in an HTML page. If you notice that the images are not technically inserted into an HTML page, images are linked to HTML pages. The <img> tag creates a holding space for the referenced image. The <img> tag has two required attributes: src and alt. In HTML the <img> tag has no end tag. In XHTML the <img> tag must be properly closed.…

    • 520 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Nt1310 Unit 3 Assignment 1

    • 1398 Words
    • 6 Pages

    Introduction: The quality of your displayed photos depends on the quality of your original photos and your ability to edit or enhance them after importing them to your computer.…

    • 1398 Words
    • 6 Pages
    Good Essays
  • Satisfactory Essays

    Sql Triggers

    • 357 Words
    • 2 Pages

    | What is the exact size of the image file you created, in bytes.The exact…

    • 357 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Image: Include either the URL of the image you want to use, or the file name that you saved the image under…

    • 1579 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    4. Images, like the ones you make with your digital camera, cannot be stored as…

    • 435 Words
    • 5 Pages
    Satisfactory Essays
  • Good Essays

    composition of an image it is just there. The dictionary definition is as simple as “the action of…

    • 530 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    The name of the person who created the image. The title of the image. TIP: If the image doesn't have a title,…

    • 518 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Vibe Magazine

    • 833 Words
    • 4 Pages

    Once I have saved the file its time to locate it so I will maximise Photoshop and click open then go to the saved destination and open the folder as you saved it. I have opened this picture and it looks exactly like the way I have opened it.…

    • 833 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    D2: Discuss the impact that file format, compression techniques, image resolution and colour depth have on file size and image quality.…

    • 2174 Words
    • 9 Pages
    Powerful Essays
  • Satisfactory Essays

    Document Object Model

    • 455 Words
    • 2 Pages

    The Image object is characterized by an image produced using the <img> element. Image objects are represented in an array form by using image [0], image [1], and so on and are dynamically changed on the web page in this format. Object images must appear in the array in the same order they appear on the web page. The manipulation of the Image objects depends on the properties used. One can use the align property to set the alignment of the image in relation to the text surrounding it using right, left, top, middle, or bottom values (Gosselin, n.d.). The alt property is used for the alternate text or description of the image (Gosselin, n.d.). The border property is set in pixels and provides a border around the image (Gosselin, n.d.). The height property sets the height of the image in pixels (Gosselin, n.d.). The isMap property indicates if this is a server side map, and returns a Boolean value (Gosselin, n.d.).…

    • 455 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Teenage Pregnancy

    • 269 Words
    • 2 Pages

    * Plane white screen to see the image to figure out the size of the image…

    • 269 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Have to understand pixel size otherwise you have to alter the image before importing it to the document…

    • 589 Words
    • 3 Pages
    Good Essays
  • Better Essays

    In this method, a code word is not used to represent a symbol of the text. Instead it uses a fraction to represent the entire source message. The occurrence probabilities and the cumulative probabilities of a set of symbols in the source message are taken into account. The cumulative probability range is used in both compression and decompression processes. In the encoding process, the cumulative probabilities are calculated and the range is created in the beginning.…

    • 1255 Words
    • 6 Pages
    Better Essays
  • Satisfactory Essays

    faltu

    • 943 Words
    • 4 Pages

    import java.io. UnsupportedEncodingException; import java.security. MessageDigest; import java.security. NoSuchAlgorithmException; import java.util.…

    • 943 Words
    • 4 Pages
    Satisfactory Essays
  • Better Essays

    % expression and in the lighting. When a new input image is read and added…

    • 1958 Words
    • 8 Pages
    Better Essays