You are on page 1of 48

New Digital Image Compression to Increase Storage Capacity of Cameras

by

Tanooj Luthra

March 28, 2007

Luthra 2 1. Introduction In the past twenty years, most of the major technological breakthroughs in consumer electronics have really been part of one larger trend Analog to Digital conversion. When you get down to it, CDs, DVDs, HDTV, MP3 and DVR are all built around the same basic process: converting conventional analog information into digital information. This fundamental shift in technology totally changed how we handle visual and audio information -- it completely redefined what is possible. In the world of photography the trend has been moving away from film based photography to digital photography and digital cameras have been replacing film based camera at increasingly fast pace. A digital image consists of digital units called pixels. A pixel (short for picture element, using the common abbreviation pix for picture) is a single point in a graphic image containing certain intensity and colors. With care, pixels in an image can be reproduced at any size without the appearance of visible dots or squares; but in many contexts, they are reproduced as dots or squares and can be visibly distinct when not fine enough. The more pixels per unit area, the smoother the picture looks. Digital cameras break a picture into many tiny pixels and store intensities and colors for those pixels. Digital cameras are becoming more sophisticated year after year with their capabilities, including number of pixels per picture, increasing dramatically. The first recorded attempt at building a digital camera was by Steve Sasson, an engineer at Eastman Kodak (Wikipedia.com). It used the then-new solid-state CCD chips developed by Fairchild Semiconductor in 1973. The camera weighed 8 pounds (3.6 kg), recorded black and white images to a cassette tape, had a resolution of 0.01 mega pixel (10,000 pixels), and took 23 seconds to capture its first image in December of 1975 (Wikipedia.com). Since then, camera sophistication has dramatically increased. Mega

Luthra 3 pixels (Mp) have ranged from 0.01 mega pixel, all the way up to over 10 mega pixels today. The amount of detail that the camera can capture is called the resolution, and it is measured in pixels. The more pixels a camera has the more detail it can capture and larger the pictures can be without becoming blurry. The increase of resolution is depicted here:

256x256 (.065 Mp) - Found on very cheap cameras, this resolution is so low that the picture quality is usually unacceptable. 640x480 (.30 Mp) - This is the low end on most real cameras. This resolution is ideal for e-mailing pictures or posting pictures on a Web site. 1216x912 (1.1 Mp) - This is a mega pixel image size which is good for printing pictures. 1600x1200 (1.9 Mp) - With almost 2 million total pixels, this is high resolution. You can print a 4x5 inch print taken at this resolution with the same quality that you would get from a photo lab. 2240x1680 (3.79 Mp) - This allows even larger printed photos, with good quality for prints up to 16x20 inches. 4064x2704 (10.99 Mp) - A top-of-the-line digital camera takes pictures at this resolution. At this setting, one can create 13.5x9 inch prints with no loss of picture quality. (HowStuffWorks.com)

As described below, for each pixel has typically three dimensions of variability such as red, green and blue, a RGB value. They are called primary colors. Any color can be created by adding red, green and blue color in proper ration. For example, 50% red and 50% green combination gives a yellow color. Each Red, Green or Blue color values can be between 0 and 255 levels (8 bits) per pixels. Therefore, an uncompressed image of size 1600x1200 will take 1600x1200x3x8 46 Mbits. This is a very large number and

Luthra 4 will require huge amount of memory to store several images. Therefore, images are typically compressed for storage. Human Vision and Color System The human eye works by picking up the light that bounces off colors. Human eyes have two types of cells, rods and cones. Rods are used for night and peripheral vision, while cones are used for color. The two main theories of how we see are the trichromatic color theory, and the opponent process theory. The trichromatic theory states that our eyes have three different types of cones, cones that see short wavelengths, long wavelengths, and medium wavelengths. The cones that see the short wavelengths see hues of violet and blue, while the long wavelength cones see the reddish hues. The colors in the middle are picked up by the medium wavelength specific cells. The opponent process theory proposes that there are three different types of cones, and each different type picks up opposite colors. One type will pick up white and black, another will pick up green and red, while the last one will pick up yellow and blue. However, there is an agreement among scientists that, in principle, three parameters are needed to describe a color sensation. A specific method for associating three numbers (or tristimulus values) with each color is called a color space. Cameras and JPEG use Red (R), Green (G) and Blue (B) color space. Every pixel in an image has an RGB value and every color is represented as combination of different values of R, G and B. Typically, the range of R,G and B values in a pixel is from 0-255, with 255 being the maximum possible. If the red value is 255, and the other two are at 0, the resulting color will be a solid red. However, if red is at 200, and green is also at 200, a yellow color will result. Human eye is not able to see all

Luthra 5 the possible colors. All of the colors visible to average person are shown in the CIE (Commission Internationale de l'Eclairage) Diagram developed by International Commission on Illumination in 1931 and is shown below (Wikipedia.com). The region of visible colors is called the gamut of human vision. The gamut of all visible chromaticities on the CIE plot is the tongue or horseshoe-shaped figure shown in color. The curved edge of the gamut corresponds to monochromatic light, with wavelengths listed in nanometers. Three colors are picked as primary colors and the triangular region formed by those three colors represents the all the colors in the gamut that can be represented by those three primaries. Typical R, G and B primaries used are shown as white circle in the diagram and the triangular region depicts the typical set colors represented by those primaries. The color palette shown next to the CIE Diagram an example of what color can be created by mixing certain values of red, green, and blue together. If all of the RGB values are the same, then the resulting color will be a shade of gray, depending on whether the values are high or low. If all three values are 0, then the color will be black. If all three values are 255 the resulting color will be white, and in between, the color will be a shade of gray. Along with RGB values, color in each pixel can also be represented using Hue, Saturation, and Luminosity (Brightness). Hue determines what the color of the pixel will be, whether it be red, yellow, green, orange, blue, or anything in between. If the hue is around 0 or around 255, the color will be red. Around 85 is green, and around 170 is blue. If the hue is in the middle of these colors, it will create a color in the middle. Saturation is how intense the color is. The higher the saturation the more intense color will be achieved. If the saturation is 0, then only a gray color will be seen. Luminosity is

Luthra 6

Luthra 7 how bright the color will appear. A higher luminosity will mix in more white with the picture, while a low luminosity will make the color darker. Compression methods exploit the characteristics of human visual system and remove the information that human eye cannot easily see. For example, human cannot see very high frequencies, which correspond to very fast changes in the brightness. It also can also not see very fine changes in the brightness, a fact exploited routinely in printed images in magazines or photographs. To reduce the storage requirement image compression techniques are used. Most popular one is the JPEG (Joint Photographic Experts Group) compression. It exploits the fact that the human eye is good at seeing small differences in brightness over a relatively large area, but not so good at distinguishing the exact strength of a high frequency brightness variation (Pennebaker & Mitchell). This allows one to get away with greatly reducing the amount of information in the high frequency components. However, even after using JPEG, many times the picture size is too large for a good quality picture and there is always a need to develop new and better compression schemes to store more images in the same memory space (New York University).

Luthra 8 2. Purpose With the number of digital cameras increasing, and becoming more prevalent, it becomes imperative that the memory capacity keep up with the cameras capability, such as the number of mega pixels in a camera. Image compression has become a vital asset in storage of pictures. Many times, I have found myself in the situation where the camera memory is full just when a great new shot is in front of me. It would be excellent if I could just press a button and all of the shots I had taken earlier would be further squeezed to make room for the new shots waiting for me to take with my camera. The current software in the cell phones or digital cameras does not provide that convenience. In this project, I will focus on developing new image compression programs, which would be compatible with the current programs used in camera and be able to reduce the memory required to store the images. These programs will allow more options regarding how to make space for storing more pictures in a digital camera or cell phone and at the same time provide better picture quality. The only currently available software is to shrink the resolution of picture by , however that compromises too much quality, and I will develop a program that will save space without reducing the resolution as much. Unlike currently available options, my techniques will work not only on the pictures to be taken in future but also on the pictures already taken. In addition, my approach will allow user to pick a technique that is optimal in providing the best picture quality depending upon the attributes of the scene while reducing the memory requirement. Current approaches do not provide that option.

Luthra 9 3. Hypothesis I predict that by using my image compression algorithms, I will be able to decrease the amount of memory required to store the images by about 20%, while maintaining the same visible image quality. The memory space required for each image will decrease because my algorithms will exploit the high correlation of the pixel values between multiple shots of the scenes, and optimally reduce the dynamic range and picture resolution based on the sensitivity of human vision to those attributes of the images.

4. Procedure In my project, I first developed three compression algorithms that work in conjunction with the JPEG method used in current cameras. These algorithms are (1) advanced spatial resolution change, (2) dynamic range reduction and (3) pixel subtraction. I then created Matlab based computer programs corresponding to these algorithms and applied them on photographs I took in real setting of my last vacation. Advanced spatial resolution change is based on the thinking that many cameras have too high a resolution and human eye cannot see that fine resolution. Current cameras provide this option but the step size between the resolution changes is large and it works only on the pictures to be taken in future. My algorithm provides finer step size. For example, in my camera I can go from 1600x1200 to 1280x960, a factor of 1.25 reductions in each direction. In my method, I use advanced interpolation technique to reduce the image size in the finer step size of 0.75. This way I create less blur if the picture is enlarged. My software program reads the picture, and then selects every 4th

Luthra 10 column to copy all of the RGB values into the new compressed picture. For the columns in the middle, my program interpolates the pixel values based on the values of the columns to the left and right. Mathematical equations for this process are:

For R, G, B values of pixels for j th Column


Pnew (i, j ) = P (i, j ) old 2 1 P (i, j ) + P (i + 1, j ) old old 3 3 1 2 Pnew (i, j ) = P (i, j ) + P (i + 1, j ) old old 3 3 Pnew (i, j ) =

For i = 1, 4, 7, ... For i = 2, 5, 8, ... For i = 3, 6, 9, ...

The rows go through the same process. Block diagram of this process is shown in Chart 1. My Matlab computer program is attached in the Appendix of the report. Dynamic range alteration is based on the fact that human vision is not sensitive to large number of brightness levels, especially when the pictures do not have large areas with very slowly changing brightness, as is generally the case. In this algorithm, the number of bits per pixel per color is changed from 8 to 7. This slightly changes the intensity levels for each R, G, and B color in each pixel; however, this slight change is barely visible to the human eye. Block diagram of this process is shown in Chart 2. My Matlab computer program is attached in the Appendix of the report. Pixel subtraction exploits the fact that many times more than one shots of the same scene are taken. Images and pixels in those shots have very high correlation. To take advantage of that correlation, in this method I will take two pictures, and subtract the RGB values of all of the pixels. If pixels are highly correlated then the new subtracted

Luthra 11 picture, (Picture2 Picture1), will need less bits to store. Therefore, I would store first picture and the subtracted picture, instead of two full highly correlated pictures. To create the second picture for display or printing I will add the first picture back to the subtracted picture and create the original second picture. After looking at many pictures I took during last vacation, I realized that camera angle and position changed a little between the shots of the same scene. Therefore, to get right pixels aligned before subtraction, I will make the pictures shift left, up, right, or down, to find the best pixel match. The best match is found by finding the shift for which the total energy in the difference of the two pictures is the smallest:

1 Mean Square Difference = N

all columns all rows j i

(P (i + n, j + m) P (i, j ))
2 1

This will reduce the picture size without deleting pictures, or even lowering the resolution. Block diagram of this process is shown in Chart 3. My Matlab computer program is attached in the Appendix of the report.

Luthra 12

Chart 1 Flow Diagram of Spatial Resolution Method

Get image information and read image stored in JPG format

Convert Image to Double RGB format

Display Image

Convert image back to unsigned integer RGB format

Change resolution of rows as done for columns

Change Resolution of columns by by interpolating inbetween values Compare the file size of the picture before and after compression Calculate compression factor

Store image in JPG format and check the file size

Compare the quality of the picture before and after compression

Luthra 13

Chart 2 Flow Diagram of Dynamic Range Method

Get image information and read image (JPG format)

Convert Image to Double RGB format

Reduce the range of each pixel by 1 bit and create the compressed image

Read and display compressed image

Store new compressed image in JPG format

Convert it back to unsigned integer

Rescale the intensity range and recreate the original picture

Display original picture

Compare the quality of the picture before and after compression Compare the file size of the picture before and after compression

Calculate compression factor

Luthra 14

Chart 3 Flow Diagram of Pixel Subtraction Method

Get image information, and read two images

Convert Images into a Double RGB format

Find optimal shifting with minimum mean square difference

Store the new compressed image in JPG format

Convert subtracted image to unsigned integer

Subtract the corresponding pixel values of the two images

Compare the file size of the image before and after compression

Calculate compression factor

Reread the image, and recreate original

Compare the quality of the picture before and after compression

Display recreated image

Luthra 15 5. Simulation Experiment Results Table 1 shows the memory sizes of the 5 original and compressed pictures in Kilo Bytes (KB). It also shows the percent reduction, in the space required to store the images, I got by using my three different techniques for these pictures. Percent storage reduction was obtained by

% Storage Reduction =

Original Storage Size Compressed Storage Size Original Storage Size

I then calculated the compression factor by using

Original Storage Size Compression Factor = Compressed Storage Size


Resolution Change provided average storage size reduction of 44% with the average compression factor of 1.8. Dynamic Range method provided average compression of 25%, giving compression factor of 1.3. Pixel subtraction provided average compression of 45% with the compression factor of 1.6. When these techniques were combined, the average compression was vastly increased. Using the resolution change, and the dynamic range method, the average compression was around 56%. When the dynamic range and pixel subtraction method were combined, the average compression was 62%. subtraction was 69%. The average compression for resolution change and pixel After all of the techniques were combined, the compression

jumped all the way up to 77%.

Luthra 16 Picture qualities obtained with my compression methods are compared against the original pictures for those 5 example photographs in Figs. 1-5. Fig. 1a shows the original St. Peters Piazza I started with. Fig. 1b shows the picture quality I got after resolution change with 45% compression. As it is clear, the picture quality is still very good and there is no additional visible distortion despite that much reduction. Fig. 1c shows the picture quality I got after dynamic range based compression. A careful look at the picture can show slight amount added noise as this picture has large dynamic range. Fig. 1d shows second photograph (Picture 2) taken for the same scene (as generally done many times). Fig. 1e shows the difference between Picture 2 and Picture 1 obtained. Effect of camera motion is clear on the bottom and right side. This difference was stored and provided 43% size reduction. Fig. 1f shows the recreated picture. Comparing Fig. 1f with Fig. 1a, we can see that there is not visible degradation in the picture quality. As I took my project further, I started getting much more compression. When I used both spatial resolution and dynamic range, the pictures had around a 57% reduction. After the dynamic range and pixel subtraction, the pictures experienced about a 60% reduction. Using both the spatial resolution method and pixel subtraction gave around 68% capacity reduction. When all three methods were combined, my program yielded about 77% reduction. The overall picture quality was very slightly compromised;

however, the size reduction far outweighs the slight distortion created through my programs. Figs. 1g to 1j show the recreated images after being put through my

compression programs and the rest of the images also underwent the combined compression algorithms.

Luthra 17 Figs. 2a to 2j show the results obtained by the same methods, respectively, for St. Marks Square. A careful look shows that as this picture has finer details, and my Spatial Resolution method added small amount of blur that may be visible. But, overall quality is still very good. The dynamic range modification algorithm overcomes this limitation and provides compression while preserving the resolution. As there was not much motion between the two shots, I get better compression for this picture by using picture subtraction method. As with these two images, there are similar results with the other three images shown in Figs. 3-5. These results are also summarized pictorially in the Graph 1. After reaching these results, I compare the results I obtained with the option currently available to users. At present, only thing a user can do is to reduce the picture resolution. As shown in Table 4, to get similar compression factor as I get with a combination of my Spatial Resolution and Pixel Subtraction methods, the picture resolution needs to be reduced by on each axis, i.e. picture needs to be shrunk to the of its original size. As it is clearly visible in the comparisons shown in Figs. 6-10, current approach degrades the picture quality significantly. A combination of all of my three techniques provides even more reduction in the storage space while still preserving the picture quality.

Luthra 18 Table 1: Percent Reduction in Storage Original Picture size (KB) 36 55 47 25 42 41 After After Pixel Resolution Subtraction Change Size % Size % Size % (KB) reduction (KB) reduction (KB) reduction After Dynamic Range 26 41 36 19 31 31 28% 25% 23% 24% 26% 25% 20 29 26 15 24 23 44% 47% 45% 40% 43% 44% 21 32 28 19 23 25 43% 47% 36% 47% 45% 44%

Image Name St. Peters Piazza St. Marks Square Roman Architecture Roman Fountain Pisa Average

Table 2: Percent Reduction in Storage Using Combinations Original Picture size (KB) 36 55 47 25 42 41 Combination Combination Combination Combination Res. Change + Dyn. Range + Res. Change + All Three Dyn. Range Pixel Sub. Pixel Sub. Size % Size % Size % Size % (KB) reduction (KB) reduction (KB) reduction (KB) reduction 15 23 20 12 18 18 58% 58% 57% 52% 57% 56% 14 21 19 13 16 17 61% 65% 57% 64% 62% 62% 12 17 15 11 13 14 67% 69% 64% 69% 69% 68% 8 12 11 8 10 10 78% 80% 75% 78% 76% 77%

Image Name St. Peters Piazza St. Marks Square Roman Architecture Roman Fountain Pisa Average

Luthra 19 Table 3: Compression Factors Image Name St. Peters Piazza St. Marks Square Roman Architecture Roman Fountain Pisa Average Dynamic Range 1.4 1.3 1.3 1.3 1.4 1.3 Resolution change 1.8 1.9 1.8 1.7 1.8 1.8 Pixel Subtraction 1.7 1.7 1.7 1.3 1.8 1.6 Res. Change + Dyn. Range 2.4 2.4 2.4 2.1 2.3 2.3 Dyn. Range + Pixel Sub. 2.6 2.6 2.5 1.9 2.6 2.4 Res. Change + Pixel Sub. 3.0 3.2 3.1 2.3 3.2 3.0 All Three 4.5 4.6 4.3 3.1 4.2 4.1

Table 4: Currently Available Techniques ( spatial resolution) vs. My New Combination Technique Original Picture size (KB) 36 55 47 25 42 41 Combination Res. Change + Pixel Sub. Size % Size % (KB) reduction (KB) reduction Spatial Resolution 11 17 15 9 14 13 69% 69% 68% 64% 67% 67% 12 17 15 11 13 14 67% 69% 68% 56% 69% 68%

Image Name St. Peters Piazza St. Marks Square Roman Architecture Roman Fountain Pisa Average

Compression Factor
0.5 0 2.5 2 1.5 1 5 4.5 4 3.5 3

Compression Factor

4.5 4 3.5 3 2.5 2 1.5 1 0.5 0

Dynamic Range

Dynamic Range Resolution change Pixel Subtraction


Methods

Resolution change

Pixel Subtraction

Compression Factor

Res. Change & Dyn. Range

Res. Change & Dyn. Range Dyn. Range & Pixel Sub. Res. Change & Pixel Sub. All Three

Average Compression Factor

Method Average

Dyn. Range & Pixel Sub.

Res. Change & Pixel Sub.

All Three

Luthra 20

Pisa

St. Peters Piazza St. Marks Square

Roman Architecture Roman Fountain

Luthra 21 6. Conclusion Three methods of Image Compression were developed and simulated. These worked in conjunction with the current JPEG compression (JPG format) used in the camera. These methods were based on (1) resolution change, (2) dynamic range modification and (3) pixel subtraction. Different combinations of these methods were also applied. The amount of compression obtained was more than I had hypothesized. Resolution change provided on average 46% compression and no visible degradation if the original picture does not contain very fine details. Dynamic range modification provided on average 25% compression and had the benefit of maintaining the original resolution. It provided no visible degradation when pictures did not have very fine variation in the brightness. Even for pictures with very fine variation in the brightness the degradation was very small. Pixel subtraction provided on average 45% compression and preserved both the sharpness as well as the dynamic range of a picture. But, it works well when similar shots of a scene are taken. For real application, it is easy to apply all three approaches or their combinations. Combination of Spatial Resolution with Dynamic Range provided on average 56 % compression, Dynamic Range and Pixel Subtraction combination resulted in, on average 62 % compression, Spatial Resolution and Pixel Subtraction achieved, on average, 68 % compression. They all preserved the quality of pictures very well. Combination of all three techniques provided the highest compression. It, on average, provided 77 % compression and still maintained very good picture quality. A user can be provided the option of selecting the one of the above available option that is most suitable for the attributes of a scene or the options of either preserving the highest

Luthra 22 quality or having the most compression. In future, a scheme can be developed to make that selection automatically. The techniques develop here can also be applied to other fields, like compressing medical images for storage or transmission for remote clinical diagnosis, photographs of Earth taken by remote sensing satellites, weather images etc.

Luthra 23

Fig. 1 Comparing Picture Quality Using Different Methods for St. Peters Piazza

(a) Original (b) Spatial Resolution (c) Dynamic Range

Luthra 24

Fig. 1 Comparing Picture Quality Using Different Methods for St. Peters Piazza

(d) Second Picture (e) Subtracted Difference Stored (f) Subtracted Recreated

Luthra 25

(g) Dynamic Range and Subtraction

(h) Resolution and Dynamic Range

(i) Resolution and Subtraction

(j) All Three

Fig. 1 Comparing Picture Quality Using Different Methods for St. Peters Piazza

Luthra 26

Fig. 2 Comparing Picture Quality Using Different Methods for St. Marks Square

(a) Original (b) Spatial Resolution (c) Dynamic Range

Luthra 27

Fig. 2 Comparing Picture Quality Using Different Methods for St. Marks Square

(d) Second Picture (e) Subtracted Difference Stored (f) Subtracted Recreated

Luthra 28

(g) Dynamic Range and Subtraction

(h) Resolution and Dynamic Range

(i) Resolution and Subtraction

(j) All Three

Fig. 2 Comparing Picture Quality Using Different Methods for St. Marks Square

Luthra 29

Fig. 3 Comparing Picture Quality Using Different Methods for Roman Architecture

(a) Original (b) Spatial Resolution (c) Dynamic Range

Luthra 30

Fig. 3 Comparing Picture Quality Using Different Methods for Roman Architecture

(d) Second Picture (e) Subtracted Difference Stored (f) Subtracted Recreated

Luthra 31

(g) Dynamic Range and Subtraction

(h) Resolution and Dynamic Range

(i) Resolution and Subtraction

(j) All Three

Fig. 3 Comparing Picture Quality Using Different Methods for Roman Architecture

Luthra 32

Fig. 4 Comparing Picture Quality Using Different Methods for Roman Fountain

(d) Second Picture (e) Subtracted Difference Stored (f) Subtracted Recreated

Luthra 33

Fig. 4 Comparing Picture Quality Using Different Methods for Roman Fountain

(d) Second Picture (e) Subtracted Difference Stored (f) Subtracted Recreated

Luthra 34

(g) Dynamic Range and Subtraction

(h) Resolution and Dynamic Range

(i) Resolution and Subtraction

(j) All Three

Fig. 4 Comparing Picture Quality Using Different Methods for Roman Fountain

Luthra 35

Fig. 5 Comparing Picture Quality Using Different Methods for Pisa

(a) Original (b) Spatial Resolution (c) Dynamic Range

Luthra 36

Fig. 5 Comparing Picture Quality Using Different Methods for Pisa

(d) Second Picture (e) Subtracted Difference Stored (f) Subtracted Recreated

Luthra 37

(g) Dynamic Range and Subtraction

(h) Resolution and Dynamic Range

(i) Resolution and Subtraction

(j) All Three

Fig. 5 Comparing Picture Quality Using Different Methods for Pisa

Luthra 38

(a) Current Compression

(b) My Compression

Fig. 6 Comparison of Picture Qualities of current method against my method for St. Peters Piazza

(a) Current Compression

(b) My Compression

Fig. 7 Comparison of Picture Qualities of current method against my method for St. Marks Square

Luthra 39

(a) Current Compression

(b) My Compression

Fig. 8 Comparison of Picture Qualities of current method against my method for Roman Fountain

(a) Current Compression

(b) My Compression

Fig. 9 Comparison of Picture Qualities of current method against my method for Roman Architecture

Luthra 40

(a) Current Compression

(b) My Compression

Fig. 10 Comparison of Picture Qualities of current method against my method for Pisa

Luthra 41

Works Cited
"CIE 1931 Color Space." Wikipedia. 20 Mar.-Apr. 2007 <http://en.wikipedia.org/wiki/CIE_1931_color_space>. "CS 184: COMPUTER GRAPHICS." 2 Dec. 2004. Berkeley. 25 Feb. 2007 <http://www.cs.berkeley.edu/~sequin/CS184/LECT04/L26.htm>. Digital Image Suite. Microsoft Corporation, 2003. Digital Image Pro. Microsoft Corporation, 2003. Digital Video Compression. Axis. June 2004. <http://www.axis.com/documentation/whitepaper/video/compression_standards.p df>. JPEG. Wikipedia. <http://en.wikipedia.org/wiki/JPEG>. King, Julie A. Digital Photography for Dummies. Indianapolis, Indiana: Wiley Inc., 2005. Luthra, Ajay. Personal interview. Oct. 2006. Paint Shop Pro. Minnetonka, MN: Jasc Software Inc, 1998. Pennebaker, William B., and Joan L. Mitchell. JPEG Still Image Data Compression Standard. New York: Van Nostrand Reinhold, 1993. Richardson, Iain E. H.264 and MPEG-4 Video Compression. Chichester, England: John Wiley & Sons Ltd, 2003. Rosenfeld, Azriel, and Avinash C. Kak. Digital Picture Processing. 2nd ed. Vol. 2. Orlando, Florida: Academic P Inc, 1982. The Essentials of Digital Images. NYU. New York University. <http://www.nyu.edu/gsas/dept/fineart/ifa/pdf/Digitalessentials.pdf>. Using Matlab. 5th ed. Natick, MA: The Math Works Inc., 1997. Wilson, Tracy V., K Nice, and G Gurevich. Digital Camera. How Stuff Works. <2. http://electronics.howstuffworks.com/digital-camera.htm>.

Luthra 42 Appendix A.
% %********************************************************************** **** %* CREATED BY TANOOJ LUTHRA %* Digital Image Compression - Squeezing more Pictures in the Same Memory %* SPATIAL RESOLUTION CHANGE %* JANUARY 2007 %********************************************************************** **** % cd d:\tanooj\matlab_fun imfinfo('photo_s1_shrunk.jpg') %Getting image information axis image photo_1 = imread('photo_s1_shrunk.jpg'); %Reading image photo_1d = double(photo_1)/255; %Converting image to double image(photo_1d); %Displaying Image c_dim=496; r_dim=372; q=0; w=0; e=0; r=0; c_n=0; r_n=0; % Changing resolution of columns for r=1:1:r_dim q=0; for c_n=1:3:(c_dim*3/4)-1 for z=1:1:3 c_index = c_n; c_o_index=c_index+q; photo_34cd(r,c_index,z) = photo_1d(r,c_o_index,z); c_index = c_n+1; c_o_index=c_index+q; photo_34cd(r,c_index,z) = (2/3)*photo_1d(r,c_o_index,z) + (1/3)*photo_1d(r,c_o_index+1,z); c_index = c_n+2; c_o_index=c_index+q; photo_34cd(r,c_index,z) = (1/3)*photo_1d(r,c_o_index,z) + (2/3)*photo_1d(r,c_o_index+1,z); end q=q+1; end end % % Changing resolution of rows for c=1:1:c_dim*3/4 w=0; for r_n=1:3:(r_dim*3/4)-1 for z=1:1:3 r_index = r_n; r_o_index=r_index+w; photo_34rd(r_index,c,z) = photo_34cd(r_o_index,c,z);

Luthra 43
r_index = r_n+1; r_o_index=r_index+w; photo_34rd(r_index,c,z) = (2/3)*photo_34cd(r_o_index,c,z) + (1/3)*photo_34cd(r_o_index+1,c,z); r_index = r_n+2; r_o_index=r_index+w; photo_34rd(r_index,c,z) = (1/3)*photo_34cd(r_o_index,c,z) + (2/3)*photo_34cd(r_o_index+1,c,z); end w=w+1; end end image(photo_34rd); %Displaying image photo_34rd_8=uint8(round(photo_34rd*255)); %Converting back to uint imwrite(photo_34rd_8,'Photo34rd.jpg','jpg'); %Storing image in JPG format

Luthra 44 Appendix B.
% %********************************************************************** **** %* CREATED BY TANOOJ LUTHRA %* Digital Image Compression - Squeezing more Pictures in the Same Memory %* DYNAMIC RANGE COMPRESSION %* JANUARY 2007 %********************************************************************** **** % cd d:\tanooj\matlab_fun % % imfinfo('photo_s1_shrunk.jpg') %Getting image information imfinfo('photo_s2_shrunk.jpg') %Getting image information axis image photo_2 = imread('photo_s2_shrunk.jpg'); %Reading image photo_2d = double(photo_2)/255; %Converting image to double image(photo_2d); %Displaying Image r_dim=372; c_dim=496; min=r_dim*c_dim*3*255+1.; p=0; scale=2; %Reducing the range by 1 bit for c=1:1:c_dim for r=1:1:r_dim for z=1:1:3 photo_dynamicd(r,c,z) = (photo_2d(r,c,z))/scale; end end end photo_dynamic_8=uint8(round(photo_dynamicd*255)); %Converting back to uint imwrite(photo_dynamic_8,'dynamic_range.jpg','jpg'); %Storing image in JPG format imfinfo('dynamic_range.jpg'); %Getting image information % % photo_dynamic_8 = imread('dynamic_range.jpg'); %Reading image image(photo_dynamic_8); %Displaying image photo_dynamicd = double(photo_dynamic_8)/255; %Converting image to double % Scaling back up the intensity range for c=1:1:c_dim for r=1:1:r_dim for z=1:1:3 photo_originald(r,c,z) = scale*(photo_dynamicd(r,c,z)); if photo_originald(r,c,z)>1

Luthra 45
photo_originald(r,c,z)=1; r; c; z; end end end end image(photo_originald); %Displaying Image and Looking at the Quality imwrite(photo_originald,'original2.jpg','jpg'); %Storing image in JPG format

Luthra 46 Appendix C.
% %********************************************************************** **** %* CREATED BY TANOOJ LUTHRA %* Digital Image Compression - Squeezing more Pictures in the Same Memory %* PIXEL SUBTRACTION %* JANUARY 2007 %********************************************************************** **** % cd d:\tanooj\matlab_fun imfinfo('photo_s1_shrunk.jpg') %Getting image information imfinfo('photo_s2_shrunk.jpg') %Getting image information axis image photo_1 = imread('photo_s1_shrunk.jpg'); %Reading image photo_2 = imread('photo_s2_shrunk.jpg'); %Reading image photo_2d = double(photo_2)/255; %Converting image to double photo_1d = double(photo_1)/255; %Converting image to double image(photo_1d); %Displaying Image image(photo_2d); %Displaying Image r_dim=372; c_dim=496; min=r_dim*c_dim*3*255+1.; p=0; max_x_shift=10; max_y_shift=60; %Picture Shifting and Subtraction for w=0:8:max_x_shift for e=0:8:max_y_shift for c=1:1:c_dim-w for r=1:1:r_dim-e for z=1:1:3 photo_diffd(r,c,z) = photo_1d(r+e,c+w,z)+photo_2d(r,c,z); squared=(photo_diffd(r,c,z))*(photo_diffd(r,c,z)); p=squared+p; end end end p=p/((r_dim-e)*(c_dim-w)); if p<min min=p c_min=w r_min=e end end end w=c_min; e=r_min; for c=1:1:c_dim-w for r=1:1:r_dim-e for z=1:1:3

Luthra 47
photo_diffd(r,c,z) = (photo_1d(r+e,c+w,z)+photo_2d(r,c,z)+1.)/4.000; end end end for c=c_dim-w+1:1:c_dim for r=1:1:r_dim for z=1:1:3 photo_diffd(r,c,z) = photo_2d(r,c,z)/2; end end end for r=r_dim-e+1:1:r_dim for c=1:1:c_dim for z=1:1:3 photo_diffd(r,c,z) = photo_2d(r,c,z)/2; end end end photo_diff_8=uint8(round(photo_diffd*255)); %Converting back to uint imwrite(photo_diff_8,'shifteddifference.jpg','jpg'); %Storing image in JPG format imfinfo('shifteddifference.jpg'); %Getting image information % % c_dim w e r_dim c_min r_min %Recreating original picture for c=c_dim-w+1:1:c_dim for r=1:1:r_dim for z=1:1:3 photo_originald(r,c,z)=2*photo_diffd(r,c,z); if photo_originald(r,c,z)<0 photo_originald(r,c,z)=0; r c z elseif photo_originald(r,c,z)>1 photo_originald(r,c,z)=1; r c z end end end end for r=r_dim-e+1:1:r_dim for c=1:1:c_dim for z=1:1:3 photo_originald(r,c,z) = 2*photo_diffd(r,c,z); if photo_originald(r,c,z)<0 photo_originald(r,c,z)=0;

Luthra 48
r c z elseif photo_originald(r,c,z)>1 photo_originald(r,c,z)=1; r c z end end end end for c=1:1:c_dim-w for r=1:1:r_dim-e for z=1:1:3 photo_originald(r,c,z) = 4.0*(photo_diffd(r,c,z)) + photo_1d(r+e,c+w,z)-1; if photo_originald(r,c,z)<0 photo_originald(r,c,z)=0; r c z elseif photo_originald(r,c,z)>1 photo_originald(r,c,z)=1; r c z end end end end image(photo_originald); %Displaying image imwrite(photo_originald,'original2.jpg','jpg'); %Storing image in JPG format

You might also like