Вы находитесь на странице: 1из 11

Image Processing In this deliverable we have started with the conversion from whatever format to JPEG format for

images. First of all, we have done a practice about transform the format of a picture with the program VCDemo:

Coding with JPEG standard


Group B: Clown256B (8 bits per pixel) Practical session - JPEG Module 1. Encode the test image with quality parameters equal to 10, 20 and 36. Use the standard quantization matrix (Standard Y, default option). a) Calculate the compression factor for each case. Do the computations in two different ways: (i) From the bit rate (the one given by Image Information: click on the image with the right button of the mouse) (ii) By comparing the file size of the input image with that of the compressed image Quality 10 20 36 Original Bpp 0,42 0,62 0,84 8 C.F. 19,0476 12,9032 9,5238 Size (Kbytes) 3,37 4,95 6,73 65 C.F. 19,3 13,13 9,65 -

How do the compressed image size, the bit rate and the compression factor change with the quality parameter? When the quality parameter increases, the image size and the bit rate increases too, this is because of the bit rate and the quality of the image are directly proportional, if an image have more bits per pixel, its quality will be better but also it will have a bigger size. On the other hand the C.F. decreases, this is because the C.F. is the relation between the bits per pixel of the original image (8bpp) and the bits per pixel of the decoded image, and, as we said before, there are more bits per pixel in an image with better quality.

b) Compare the visual quality of the coded images (strictly speaking of the
decoded images). In particular, describe the different distortions and why they appear.

Original image

10

20

36

As we can see in the images above, every time we are decoding the image with a bigger C.F. we can see more significant the distortions that JPEG introduces. If we take the image with an optimized quality factor of 10, we can see these two distortions better: Blocking: Showed below with a green line, the blocking artifacts, as its name suggest, produce annoying blocking artifacts near block boundaries. Ringing: Showed below with the red line, the ringing artifacts created a light halo in the edge of some parts of the image.

c) Check the effect of applying a low-pass filtering (smoothing) to the


decoded image. (Check the option off once you have finished.) 36 36 Smoothed

20

20 Smoothed

10

10 Smoothed

As we can see in the images above, there is no difference, ore almost we cant differentiate it, between the decoded images without applying a low-pass filtering, and the images decoded applying it.

2. Repeat the previous coding but using an uniform quantization matrix (Flat
option). a) Compute the compression factor for each case (just as in 1a(i)). Quality 10 20 36 Original Bpp 0,20 0,30 0,47 8 C.F. 40 26,6666 17,0213 -

b) Experiment with different quality parameters until obtaining similar compression factors to those obtained in section 1a. Quality 31 53-54 69 Original Bpp 0,42 0,62 0,84 8 C.F. 19,0476 12,9032 9,5238 -

c) Compare the quality of the images with respect to section 1a.

36

36 using an uniform quantization matrix

20

20 using an uniform quantization matrix

10

10 using an uniform quantization matrix

As we can see in the images above, a decoded image using a uniform quantization matrix will have fewer bits per pixel to obtain the same optimized quality factor than an image decoded without use a uniform quantization matrix. We also can see more significant the distortions occurred because of the encoding in the image decoded with a uniform quantization matrix. 3. For each of the entropy coding options (three in total: FLC, Standard VLC and Optimal VLC), draw the SNR-bit rate and Quality-SNR curves . What conclusions can you infer?

SNR-bit rate curves

With the SNR-bit rate curves showed above, we can see that the images encoded with optimal VLC and Standard VLC have a similar SNR, the image encoded with optimal VLC has a bigger value of SNR than the image encoded with standard VLC with a bit rate lower than 0,6 bits per pixel. The image encoded with FLC has a value of SNR very lower than the other two images. But below we can see the Quality-SNR curves; there we saw that the image encoded with FLC has very low values of quality, the images encoded with optimal VLC and Standard VLC have a similar quality values per SNR. In conclusion, the image encoded with FLC will have less SNR but also will have less quality, too much less quality.

Quality-SNR curves

Quality-SNR curve
90 80 70 60 Quality 50 40 30 20 10 0 0 5 10 15 20 25 30 Optimal VLC Standard VLC FLC

4. Encode the image Noise256B at 0.5 bpp, 1 bpp and 1.5 bpp. Compare the
results with the ones you would obtain with your test image. What conclusions can you draw? As the images below show, we can appreciate more the differences between the different encodes in the Noise256B than with our image. In our image, the difference between the encoding with 1.5 bpp and the encoding between 1 bpp is very small, we practically cant appreciate it, when the image is decoded with 0,5 bpp the differences are bigger, but not too much. On the other hand, in Noise256B the differences between 1,5 bpp and 1bpp are bigger, and in the decoded image with 0,5 bpp the distortions are very visible. The fact that makes the Noise256B decoding effects more visible than in Clown256B is that in Noise256B there are more abrupt changes between the colors, the frequency of a change of color is very big, so there are more edges and the distortion effects of JPEG are more visible.

NOISE256B

CLOWN256B

0.5 bpp

0.5 bpp

1 bpp

1 bpp

10

1.5 bpp

JPEG Converter application

The second part of this deliverable is the implementation of a mini application without GUI about JPEG conversion. This application have to read and incoming image that have to be in the same directory of the main class, apply a filter (in our case a convolution to sharp the image) and store the new image as JPEG with a desired quality (applying the conversion to JPEG). First of all, we have made an interface called iConvertion explaining the functions to implement. In this interface are the functions reader, convolution and ToJPEG. public interface iConvertion { public PlanarImage reader(String orig_name); public PlanarImage convolution(PlanarImage img); public void ToJPEG(String conv_name, PlanarImage img, float qual) throws FileNotFoundException, IOException; } We have decided to make it in this way because the structure for every part of the application will be defined as interfaces or classes implementing interfaces. It will be much easier to integrate it into our application. After this, we have created the class that implements de interface. It is being called Convertion. public class Convertion implements iConvertion{ In this class, there are the functions to call from the main class and make the different requirements for this deliverable:

Function reader:

public PlanarImage reader(String orig_name){ //Load the picture PlanarImage img=null; img= JAI.create("fileload", orig_name); return img; }

This function will catch a string where we put the original name of the picture and create a planar image from the original picture. It would read that picture.

Function convolution: //Sharp the image

public PlanarImage convolution(PlanarImage img){

KernelJAI kernels; float[] sharpenMoreData = { -1.0F/ 4.0F, -1.0F/ 4.0F, -1.0F/ 4.0F, -1.0F/ 4.0F, 12.0F/ 4.0F, -1.0F/ 4.0F, -1.0F/ 4.0F, -1.0F/ 4.0F, -1.0F/ 4.0F }; kernels = new KernelJAI(3, 3, 1, 1, sharpenMoreData); ParameterBlock paramBlock = new ParameterBlock(); paramBlock.addSource(img); paramBlock.add(kernels); img=JAI.create("convolve", paramBlock); return img; } In this part, the planar image created before in reader will be convolved with a matrix that will sharp the image. The first thing is the creation of a matrix that will sharp some image when it is convolved with this image. We create a ParameterBlock and add the two images in it. After that we have only to create the convolved image from the ParameterBlock.

Function ToJPEG:

public void ToJPEG(String conv_name, PlanarImage img, float qual) throws FileNotFoundException, IOException{ OutputStream out = new FileOutputStream(conv_name); //Convert to JPEG with quality selected and store JPEGEncodeParam encodeParam = new JPEGEncodeParam(); encodeParam.setQuality(qual); ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG", out, encodeParam); encoder.encode(img); } In this last part we have only to convert the image to JPEG format but with the quality desired by the user. First, we have created the output image file, where the convolved imaged will be created. After that, the have created a encoding parameter where we set the quality inserted by the user and then, we have created the encoder with the name of the output file, the quality encoding parameter and the format we want to convert. After that, the new convolved image is created in the same folder of the original picture. We think this mini application will be useful for the application of this project because the fact of convert to JPEG would be interesting when downloading a picture. The application of a filter is also useful for the editor tool bar in our application (explained in the User Interface part, paper prototype).

Вам также может понравиться