Wednesday, 9 May 2012

Region using quadtree


The region quadtree represents a partition of space in two dimensions by decomposing the region into four equal quadrants, subquadrants, and so on with each leaf node containing data corresponding to a specific subregion. Each node in the tree either has exactly four children, or has no children (a leaf node). The region quadtree is not strictly a tree - as the positions of subdivisions are independent of the data. They are more precisely called tries.

A region quadtree with a depth of n may be used to represent an image consisting of 2n × 2n pixels, where each pixel value is 0 or 1. The root node represents the entire image region. If the pixels in any region are not entirely 0s or 1s, it is subdivided. In this application, each leaf node represents a block of pixels that are all 0s or all 1s.

A region quadtree may also be used as a variable resolution representation of a data field. For example, the temperatures in an area may be stored as a quadtree, with each leaf node storing the average temperature over the subregion it represents.

If a region quadtree is used to represent a set of point data (such as the latitude and longitude of a set of cities), regions are subdivided until each leaf contains at most a single point.


 
Original

Quadtree

There's an a Region QuadTree Demo.
Try it : )

Tuesday, 8 May 2012

FREQUENCY DOMAIN PROCESSING (LAB 4)

Welcome to lab 4! What on earth we are going to learn today? Well, its all about Frequency domain processing.

What you need to understand for lab 4?

  1. DISCRETE FOURIER TRANSFORM
  2. LOWPASS AND HIGHPASS FREQUENCY DOMAIN FILTERS
Tips: Always ask yourself  WHAT & HOW question to make sure you understand this lab exercise.


------------------------------------------------------------------------------------------------------

Discrete Fourier Transform(DFT)

  • Concept: any waveform that can be constructed using a sum of sine and cosine waves of different frequencies.

  • Equation : 

(2d DFT)

(Inverse 2d DFT)
  • MATLAB CODE
  • Relation between DFT with Spatial Domain Filtering


The results is very similar after filtering in the condition of they both have negative values, use absolute function to get rid of negatives and threshold into a binary image. This are the results. 

Monday, 7 May 2012

Region Splitting and Merging

Region Splitting and Merging

  • Splitting or merging not produce good results when apply separately.
  • Better results can be obtained by interleaving merge and split operations.

Region Splitting

Region Splitting

  • This operation add missing boundaries by splitting regions that contain parts of different objects.
  • Splitting schemes begin with a partition satisfying condition, for example the whole image.
  • Then they proceed to satisfy condition by gradually splitting image regions
  • Two difficulties in implementing this approach:
          - Deciding when to split a region
          - Deciding how to split a region


Region Merging

Region Merging

  • This operation eliminates false boundaries and spurious regions by merging adjacent regions that belong to the same object.
  • Merging schemes begin with a partition satisfying condition
  • Then they proceed to fulfill condition by gradually merging adjacent image regions

  • How to determine region similarity?
          - Based on the gray values of the regions.

          - Based on the weakness of boundaries between the regions.
  • Region merging by removing weak edges.
          - The idea is to combine two regions if the boundary between them is weak.
          - A weak boundary is one for which the intensities on either side differ by less than some threshold. 
          - The relative lengths between the weak boundary and the region boundaries must be also considered.







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.