Wednesday, 25 April 2012

Lab 2

During this lab, kami belajar cara-cara utk recognize the size of file(image) based on its bytes, rows and columns. Then, we learn about image acquisition. image acquisition adalah suatu proses utk process image, compress image, edit image, storage image dgn menggunakan algorithm yang sesuai. 

Question 1

(a) Copy "Porshe.tiff" into file.
  • Read the file into f
  • How large is the image(rows,columns)?
In other to complete the question, followed these instructions:

- Use command imread to read the file

>> I=imread('Porsche.tiff')

- Make sure the directory for the image is the same as your current directory.


- To check the size of the image, you can check on the workspace


           Value = <342x546 uint8>
           Row = 342
           Column = 546

         * or double click I (open I) in workspace and variable editor of I will be displayed.      


(b) Answer the following questions about the image

  •     How big is the file?

              - Use whos command to display the information of the matrix


               - Answer: 186732 bytes

  • How large is the image (rows,columns)
           - Answer: image (342, 546)

  • What are the minimum and maximum gray values?
           - Answer:
             Min = 0;
             Max = 240

  • How many bytes in the file are used to store one pixel?
          - Answer: 1 pixel consists of 8 bits. 8 bits is equal to 1 byte.




Question 2

Part I : Image Acquisition

Sample image.



Part II : Read the image into MATLAB

- Use imread  command to read the image



- To display the information of matrix I 



- Note that the class should be "uint8" and the third dimension of I should be 3, which denotes it is a colour       image (the three components responding to R, G, B channels respectively). 

- To display the image with original colour.




- To convert image into grayscale



- To display the green channel of the image



- To display the red channel of the image



Part III : Basic Image Operations

- Transport the image and display it.




- To crop the top-left quarter of the image and display it




- To flip the image from left to right and display it






Tuesday, 24 April 2012

JPEG VS JPEG 2000??



We all know about  JPEG as we use it in our daily live. When we say JPEG, automatically we will think about images and pictures. However, what about JPEG2000? Have what do you understand about that?


Well, JPEG 2000 is basically a new standard or update for the well-known JPEG (Joint Photographic Expert Group) image standard. The name might be almost the same but truth be told, there are many differences between them. 

What you should know about JPEG2000? Well here’s some of its features:


  • Better efficiency in compression (incl. 48 bit color depth support)
  • Possibility of lossless compression
  • Decoding with different output resolutions
  • A process to calculate the integrated bit rate (possibility of reaching an aimed bit rate)
  • Dividing the image into smaller parts to be coded independently from the others
  • Improvement in noise resilience
  • Access to the compressed bit rate at any point in order to access the image directly
  • Better performances in coding/decoding through many different cycles
  • More flexible file format



The basic that we should know but don’t really care is the fact that in the lossy image compression mode, JPEG2000 is based on discrete wavelet transformation which is supposed to be more efficient compared to the JPEG algorithm cosine transformation. What does this mean? It means you can view it with different resolution and size based on the same image file! Why do you should know this? One application that this fact is useful is if you have a slow internet connection, you can view the image with a lower resolution as it saves time compared to higher resolution which takes long time to load. Bla bla bla.. OK! enough words! Lets look at the image below! =)



All the above images are viewing from a single JPEG2000 image with different size and resolution. We can see that the quality is good. We cant really do this with JPEG except if we edit the resolution or size in Photoshop. =p




From the picture above, we can see that the image after compression for JPEG2000 retain a much higher quality than JPEG.

 JPEG 2000 offers both lossy and lossless compression in the same file stream, while JPEG usually only utilizes lossy compression. JPEG does have a lossless compression engine, but it is separate from the lossy engine, and is not used very often. Thus, when high quality is a concern, JPEG 2000 proves to be a much better compression tool. Because of the way the compression engine works, JPEG 2000 promises a higher quality final image, even when using lossy compression. Since the JPEG 2000 format includes much richer content than existing JPEG files, the bottom line effect is the ability to deliver much smaller files that still contain the same level of detail as the larger original JPEG files. The JPEG 2000 files can also handle up to 256 channels of information as compared to the current JPEG standard, which, by reason of common implementation, is limited to only RGB (red, green, and blue) data.

 JPEG 2000 over JPEG is that JPEG 2000 is able to offer higher compression ratios for lossy compression.  For lossy compression, data has shown that JPEG 2000 can typically compress images from 20%-200% more than JPEG.  Compression efficiency for lossy compression is typically measured using the peak signal to noise ratio, or PSNR, and the root mean square error (RMSE).  This method seeks to take into account the visual quality retained by the compression method, as well as how much the image was compressed.  The formula for the PSNR compression efficiency, in dB, is shown below, where b is the bit depth of the original image.
Another advantage of JPEG 2000 is its ability to display images at different resolutions and sizes from the same image file as i said earlier.  With JPEG, an image file was only able to be displayed a single way, with a certain resolution.  Because JPEG 2000 is based on wavelets, the wavelet stream can be only partially decompressed if the user only wants a low-resolution image, while the full resolution image can be viewed if this is desired.  

 An example of some PSNR efficiencies for JPEG 2000 and JPEG is shown in Table 1.  Two different color images were compressed using several different bit rates (measured in bits per pixel, or bpp) using both JPEG 2000 and JPEG.  A higher bit rate will result in a higher quality picture.  The analysis was performed by Maryline Charrier, Diego Santa Cruz, and Mathias Larsson as part of an overview of JPEG 2000.  The results indicate that JPEG 2000 consistently offers a higher compression efficiency.  One should note that since the PSNR is measured on a log scale, the data in Table 1 indicates that in actuality the test showed that JPEG 2000 compresses almost twice more than JPEG. JPEG 2000 is also able to offer compression ratios of about 2.5:1 for lossless compression, whereas JPEG was not able to satisfactorily perform lossless compression at all.  Lossless compression ratios are simply measured by how much less memory the compressed image uses.

 Table 1  Comparison of PSNR compression efficiencies
(in dB) for two images at various bit rates


Another benefit of JPEG 2000 is its ROI capability, or Region of Interest.  The use of wavelets allows one to be able to select a certain area of an image to view at a high quality, while leaving the rest of the image at a lower quality.  This allows the user to only view a necessary portion of the image instead of the entire image.  This significantly reduces the amount of memory the image requires, and the amount of time required to access the image.

Finally, lets talk about ER. Im sorry, i did not mean EMERGENCY ROOM. ER that i am talking about is Error resilience, which measures the ability of a compression method to avoid letting errors introduced into the image file affect the quality of the image.  For example, when downloading an image from the Internet, background “noise” may be introduced into the image file, causing some small errors.  Conversion of the file for use in another application is another way in which small errors may be brought into the image file.  JPEG 2000 offers significantly higher error resilience than JPEG; therefore, there is less chance that the image will be somehow corrupted and its quality sacrificed in some way.


Thats all for this week. Take care!


Sunday, 22 April 2012

JPEG vs. JPEG 2000


Introduction

The JPEG2000 file format was put forward as an improvement on the classic JPEG format. JPEG2000 was created by JPEG committee (Joint Photographic Experts Group) back in 2000 hence the name for the format. It was supposed to improve on the original JPEG format (which was created back in 1992). The standardized file extension for JPEG2000 is .jp2 and .jpx.
JPEG2000 offers:
  • Better efficiency in compression (including 48 bit color depth support)
  • Possibility of lossless compression>
  • Decoding with different output resolutions>
  • A process to calculate the integrated bit rate (possibility of reaching an aimed bit rate)
  • Dividing the image into smaller parts to be coded independently from the others
  • Improvement in noise resilience
  • Access to the compressed bit rate at any point in order to access the image directly
  • Better performances in coding/decoding through many different cycles
  • More flexible file format

The current reality

Similar to JPEG there's no requirement to implement to complete standard which can result in incompatibilities between different applications (it was the same in the early days of JPEG). While the complexity of the implementation didn't really help to boost the acceptance in the field JPEG2000 is now slowly entering the mainstream. The very latest imaging applications often offer a JPEG2000 file format though it still tends to be limited to 24 bit color depth.

The following images are ENLARGED BY 200% for a better illustration of the differences:

ORIGINAL IMAGE

JPEG2000 1:20

JPEG 1:20

A compression rate of 1:20 is quite extreme and naturally even JPEG2000 can't recreate the fine structures of the original image. Nonetheless it does a much better job than JPEG here. You may notice that the (in-) famous blocks (the 8x8 pixel blocks from the cosine transformation) are no longer present in the JPEG2000 image. The halo artifacts around contrast transitions (e.g. roof to sky) are also much less pronounced and there're no extreme color defects. Overall the JPEG2000 result looks soft, like sprinkled with water, but it isn't completely unusable like the JPEG result. 

Other examples:

Original

JPEG at 10% of original file size.
 Some of the fine-grained noise is smoothed out.  Some subtle 'ghost' contrast artifacts are found around areas of high contrast, such as the shoreline border.

JPEG2000 at 10% of original filesize
'Ghost' contrast artifacts are also present here, in different areas.  Fine-grained noise and small feature contrast, however, is heavily affected, causing a blurring effect.  This is easy to see in the green fields of the lower-right quadrant, where the features have blurred into mush.

Tuesday, 17 April 2012

Time Domain


Time domain is a term used to describe the analysis of:
·         mathematical functions,
·         physical signals or time series of economic or environmental data, with respect to time.

In the time domain, the signal or function's value is known for all real numbers, for the case of continuous time, or at various separate instants in the case of discrete time.

Tool used to visualize real-world signals in the time domain is oscilloscope.

Time domain graph shows how a signal changes over time, whereas a frequency domain graph shows how much of the signal lies within each given frequency band over a range of frequencies.

The simple manipulation of a signal's time-domain representation is waveform and it can provide a number of useful properties.




Visualization of periodic, aperiodic, and swept-frequency waveforms.


Visualizing a speech signal in the time domain using the Signal Browser interface in the Signal Processing Tool (SPTool).


The most common processing approach in the time or space domain is enhancement of the input signal through a method called filtering. Digital filtering generally consists of some linear transformation of a number of surrounding samples around the current sample of the input or output signal. There are various ways to characterize filters; for example:
§  A "linear" filter is a linear transformation of input samples; other filters are "non-linear". Linear filters satisfy the superposition condition, i.e. if an input is a weighted linear combination of different signals, the output is an equally weighted linear combination of the corresponding output signals.
§  A "causal" filter uses only previous samples of the input or output signals; while a "non-causal" filter uses future input samples. A non-causal filter can usually be changed into a causal filter by adding a delay to it.
§  A "time-invariant" filter has constant properties over time; other filters such as adaptive filters change in time.
§  A "stable" filter produces an output that converges to a constant value with time, or remains bounded within a finite interval. An "unstable" filter can produce an output that grows without bounds, with bounded or even zero input.
§  A "finite impulse response" (FIR) filter uses only the input signals, while an "infinite impulse response" filter (IIR) uses both the input signal and previous samples of the output signal. FIR filters are always stable, while IIR filters may be unstable.
Filters can be represented by block diagrams, which can then be used to derive a sample processing algorithm to implement the filter with hardware instructions. A filter may also be described as a difference equation, a collection of zeroes and poles or, if it is an FIR filter, an impulse response orstep response.
The output of a digital filter to any given input may be calculated by convolving the input signal with the impulse response.

Thursday, 12 April 2012

Frequency Domain :))

Frequency Domain


Definition

  • changes in image position correspond to changes in the spatial frequency
  • this is the rate at which image intensity values are changing in the spatial domain image
  • transform the image to its frequency representation 
  • perform image processing
  • compute inverse transform back to the spatial domain
Methods

FD can be obtained through the transformation from one (time or spatial) domain to the other (frequency) via
  • Discrete Cosine Transform
  • Fourier Transform 
Discrete Cosine Transform (DCT)

It helps to separate the image into parts of differing importance. It is similar to discrete Fourier transform; it transform a signal or image from the spatial domain to the frequency domain.


Basic operation of the DCT is as folows:
  • the input image is N by M
  • f ( i , j ) is the intensity of the pixel in row i and column j
  • F ( u , v ) is the DCT coefficient in row k1 and column k2 of the DCT matrix.
  • for most images, much of the signal energy lies at low frequencies; these appear in the upper left corner of the DCT.
  • compression is achieved since the lower right values represent higher frequencies, and are often small - small enough to be neglected with little visible distortion.
  • the DCT input is an 8 by 8 array of integers. this array contain ah pixel's gray scale level
  • 8 bits pixels have level from 0 to 255.
The One-Dimensional DCT
    
The Two-Dimensional DCT


Fourier Transform (FT)

Brief Description

It is used to decompose image into its sine and cosine components. The output represent the image in frequency domain while the input is the spatial domain. 

Widely used in image analysis image filtering, image reconstruction and image compression.

Properties of the Fourier Transform
  • The FT is a linear operator
  • some other useful properties include



Filtering - scheme



Filtering Example
Smooth an Image with a Gaussian Kernel














Spatial Domain :))


Spatial domain (Image Enhancement)

Definition

-          Techniques are based on direct manipulation of pixels in an image
-          “normal” image space
-          Changes in pixel positions correspond to changes in the scene
-          Distances in / correspond to real distances
-          Directly process the input image pixel array


-          An image processing operation transform the gray value of the pixels
-          In order to perform the transformation, the image must undergo 3 process
i.                     Point processing  - Gray values change without any knowledge of its surrounding
ii.                   Neighbourhood processing – Gray values change depends on the gray value in a small neighbourhood of pixels around the given pixel.
iii.                  Transform – Gray values are represented in a different domain but equivalent form; Fourier, wavelet.

Point processing

·         Neighbourhood =  1*1 pixel
·          g depends on only the value of f at (x,y)
·         T = gray level (or intensity or mapping) transformation function 
s = T(r) 
where
r = gray level of f(x,y)  
s =gray level of g(x,y)
                Arithmetic Operation
·         Act by applying a simple arithmetic functions

                  s = T(r)

to each gray level in the image
·          T is a function that maps r to s.
·         Additions, subtraction, scaling (multiplication & division), complement

Image Subtraction
g(x,y) = f(x,y) - h(x,y)
  •            Is obtained by computing the difference between all pairs of corresponding pixels
  •            Usefulness: enhancement of differences between images


                Image Negatives


The appearance of photographic negatives



  •           It enhances white or gray detail on dark regions especially when black areas are dominant in size.

Identity function


  •           what “goes in” , “comes out” the same
                              


Log transformation
  •            bring up the details that are not visible due to large dynamic range of values 


 


Inverse Log Transformation
  •          the opposite of Log transformation
  •       used to expand the higher value pixels in an image while compressing darker-level values.




Power-Law Transformation


Gamma Correction

  •           make linear input appear linear on displays
  •           method: calibration pattern + interactive adjustment


-         
  •      effect gamma on consumer photos