DIP – Brightness and Contrast

Brightness and Contrast ”; Previous Next Brightness Brightness is a relative term. It depends on your visual perception. Since brightness is a relative term, so brightness can be defined as the amount of energy output by a source of light relative to the source we are comparing it to. In some cases we can easily say that the image is bright, and in some cases, its not easy to perceive. For example Just have a look at both of these images, and compare which one is brighter. We can easily see, that the image on the right side is brighter as compared to the image on the left. But if the image on the right is made more darker then the first one, then we can say that the image on the left is more brighter then the left. How to make an image brighter. Brightness can be simply increased or decreased by simple addition or subtraction, to the image matrix. Consider this black image of 5 rows and 5 columns Since we already know, that each image has a matrix at its behind that contains the pixel values. This image matrix is given below. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Since the whole matrix is filled with zero, and the image is very much darker. Now we will compare it with another same black image to see this image got brighter or not. Still, both images look the same. To make the second one brighter we just need to add the value 1 to each element in the matrix representing it. What we will do is, that we will simply add a value of 1 to each of the matrix value of image 1. After adding the image 1 would something like this. Now we will again compare it with image 2, and see any difference. We see, that still we cannot tell which image is brighter as both images looks the same. Now what we will do, is that we will add 50 to each of the matrix value of the image 1 and see what the image has become. The output is given below. Now again, we will compare it with image 2. Now you can see that the image 1 is slightly brighter then the image 2. We go on, and add another 45 value to its matrix of image 1, and this time we compare again both images. Now when you compare it, you can see that this image1 is clearly brighter then the image 2. Even it is brighter then the old image1. At this point the matrix of the image1 contains 100 at each index as first add 5, then 50, then 45. So 5 + 50 + 45 = 100. Contrast Contrast can be simply explained as the difference between maximum and minimum pixel intensity in an image. For example. Consider the final image1 in brightness. The matrix of this image is: 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 The maximum value in this matrix is 100. The minimum value in this matrix is 100. Contrast = maximum pixel intensity(subtracted by) minimum pixel intensity = 100 (subtracted by) 100 = 0 0 means that this image has 0 contrast. Print Page Previous Next Advertisements ”;

DIP – Computer Vision and Graphics

Computer Vision and Computer Graphics ”; Previous Next Computer Vision Computer vision is concerned with modeling and replicating human vision using computer software and hardware. Formally if we define computer vision then its definition would be that computer vision is a discipline that studies how to reconstruct, interrupt and understand a 3d scene from its 2d images in terms of the properties of the structure present in scene. It needs knowledge from the following fields in order to understand and stimulate the operation of human vision system. Computer Science Electrical Engineering Mathematics Physiology Biology Cognitive Science Computer Vision Hierarchy Computer vision is divided into three basic categories that are as following: Low-level vision: includes process image for feature extraction. Intermediate-level vision: includes object recognition and 3D scene Interpretation High-level vision: includes conceptual description of a scene like activity, intention and behavior. Related Fields Computer Vision overlaps significantly with the following fields: Image Processing: it focuses on image manipulation. Pattern Recognition: it studies various techniques to classify patterns. Photogrammetry: it is concerned with obtaining accurate measurements from images. Computer Vision Vs Image Processing Image processing studies image to image transformation. The input and output of image processing are both images. Computer vision is the construction of explicit, meaningful descriptions of physical objects from their image. The output of computer vision is a description or an interpretation of structures in 3D scene. Example Applications Robotics Medicine Security Transportation Industrial Automation Robotics Application Localization-determine robot location automatically Navigation Obstacles avoidance Assembly (peg-in-hole, welding, painting) Manipulation (e.g. PUMA robot manipulator) Human Robot Interaction (HRI): Intelligent robotics to interact with and serve people Medicine Application Classification and detection (e.g. lesion or cells classification and tumor detection) 2D/3D segmentation 3D human organ reconstruction (MRI or ultrasound) Vision-guided robotics surgery Industrial Automation Application Industrial inspection (defect detection) Assembly Barcode and package label reading Object sorting Document understanding (e.g. OCR) Security Application Biometrics (iris, finger print, face recognition) Surveillance-detecting certain suspicious activities or behaviors Transportation Application Autonomous vehicle Safety, e.g., driver vigilance monitoring Computer Graphics Computer graphics are graphics created using computers and the representation of image data by a computer specifically with help from specialized graphic hardware and software. Formally we can say that Computer graphics is creation, manipulation and storage of geometric objects (modeling) and their images (Rendering). The field of computer graphics developed with the emergence of computer graphics hardware. Today computer graphics is use in almost every field. Many powerful tools have been developed to visualize data. Computer graphics field become more popular when companies started using it in video games. Today it is a multibillion dollar industry and main driving force behind the computer graphics development. Some common applications areas are as following: Computer Aided Design (CAD) Presentation Graphics 3d Animation Education and training Graphical User Interfaces Computer Aided Design Used in design of buildings, automobiles, aircraft and many other product Use to make virtual reality system. Presentation Graphics Commonly used to summarize financial, statistical data Use to generate slides 3d Animation Used heavily in the movie industry by companies such as Pixar, DresmsWorks To add special effects in games and movies. Education and training Computer generated models of physical systems Medical Visualization 3D MRI Dental and bone scans Stimulators for training of pilots etc. Graphical User Interfaces It is used to make graphical user interfaces objects like buttons, icons and other components Print Page Previous Next Advertisements ”;

DIP – Histogram Sliding

Histogram Sliding ”; Previous Next The basic concept of histograms has been discussed in the tutorial of Introduction to histograms. But we will briefly introduce the histogram here. Histogram Histogram is nothing but a graph that shows frequency of occurrence of data. Histograms has many use in image processing, out of which we are going to discuss one user here which is called histogram sliding. Histogram sliding In histogram sliding, we just simply shift a complete histogram rightwards or leftwards. Due to shifting or sliding of histogram towards right or left, a clear change can be seen in the image.In this tutorial we are going to use histogram sliding for manipulating brightness. The term i-e: Brightness has been discussed in our tutorial of introduction to brightness and contrast. But we are going to briefly define here. Brightness Brightness is a relative term. Brightness can be defined as intensity of light emit by a particular light source. Contrast Contrast can be defined as the difference between maximum and minimum pixel intensity in an image. Sliding Histograms Increasing brightness using histogram sliding Histogram of this image has been shown below. On the y axis of this histogram are the frequency or count. And on the x axis, we have gray level values. As you can see from the above histogram, that those gray level intensities whose count is more then 700, lies in the first half portion, means towards blacker portion. Thats why we got an image that is a bit darker. In order to bright it, we will slide its histogram towards right, or towards whiter portion. In order to do we need to add atleast a value of 50 to this image. Because we can see from the histogram above, that this image also has 0 pixel intensities, that are pure black. So if we add 0 to 50, we will shift all the values lies at 0 intensity to 50 intensity and all the rest of the values will be shifted accordingly. Lets do it. Here what we got after adding 50 to each pixel intensity. The image has been shown below. And its histogram has been shown below. Lets compare these two images and their histograms to see that what change have to got. Conclusion As we can clearly see from the new histogram that all the pixels values has been shifted towards right and its effect can be seen in the new image. Decreasing brightness using histogram sliding Now if we were to decrease brightness of this new image to such an extent that the old image look brighter, we got to subtract some value from all the matrix of the new image. The value which we are going to subtract is 80. Because we already add 50 to the original image and we got a new brighter image, now if we want to make it darker, we have to subtract at least more than 50 from it. And this what we got after subtracting 80 from the new image. Conclusion It is clear from the histogram of the new image, that all the pixel values has been shifted towards right and thus, it can be validated from the image that new image is darker and now the original image look brighter as compare to this new image. Print Page Previous Next Advertisements ”;

DIP – Fourier series and Transform

Fourier Series and Transform ”; Previous Next In the last tutorial of Frequency domain analysis, we discussed that Fourier series and Fourier transform are used to convert a signal to frequency domain. Fourier Fourier was a mathematician in 1822. He give Fourier series and Fourier transform to convert a signal into frequency domain. Fourier Series Fourier series simply states that, periodic signals can be represented into sum of sines and cosines when multiplied with a certain weight.It further states that periodic signals can be broken down into further signals with the following properties. The signals are sines and cosines The signals are harmonics of each other It can be pictorially viewed as In the above signal, the last signal is actually the sum of all the above signals. This was the idea of the Fourier. How it is calculated Since as we have seen in the frequency domain, that in order to process an image in frequency domain, we need to first convert it using into frequency domain and we have to take inverse of the output to convert it back into spatial domain. That’s why both Fourier series and Fourier transform has two formulas. One for conversion and one converting it back to the spatial domain. Fourier series The Fourier series can be denoted by this formula. The inverse can be calculated by this formula. Fourier transform The Fourier transform simply states that that the non periodic signals whose area under the curve is finite can also be represented into integrals of the sines and cosines after being multiplied by a certain weight. The Fourier transform has many wide applications that include, image compression (e.g JPEG compression), filtering and image analysis. Difference between Fourier series and transform Although both Fourier series and Fourier transform are given by Fourier , but the difference between them is Fourier series is applied on periodic signals and Fourier transform is applied for non periodic signals Which one is applied on images Now the question is that which one is applied on the images , the Fourier series or the Fourier transform. Well, the answer to this question lies in the fact that what images are. Images are non – periodic. And since the images are non periodic, so Fourier transform is used to convert them into frequency domain. Discrete fourier transform Since we are dealing with images, and in fact digital images, so for digital images we will be working on discrete fourier transform Consider the above Fourier term of a sinusoid. It include three things. Spatial Frequency Magnitude Phase The spatial frequency directly relates with the brightness of the image. The magnitude of the sinusoid directly relates with the contrast. Contrast is the difference between maximum and minimum pixel intensity. Phase contains the color information. The formula for 2 dimensional discrete Fourier transform is given below. The discrete Fourier transform is actually the sampled Fourier transform, so it contains some samples that denotes an image. In the above formula f(x,y) denotes the image, and F(u,v) denotes the discrete Fourier transform. The formula for 2 dimensional inverse discrete Fourier transform is given below. The inverse discrete Fourier transform converts the Fourier transform back to the image Consider this signal Now we will see an image, whose we will calculate FFT magnitude spectrum and then shifted FFT magnitude spectrum and then we will take Log of that shifted spectrum. Original Image The Fourier transform magnitude spectrum The Shifted Fourier transform The Shifted Magnitude Spectrum Print Page Previous Next Advertisements ”;

DIP – Concept of Blurring

Concept of Blurring ”; Previous Next A brief introduction of blurring has been discussed in our previous tutorial of concept of masks, but we are formally going to discuss it here. Blurring In blurring, we simple blur an image. An image looks more sharp or more detailed if we are able to perceive all the objects and their shapes correctly in it. For example. An image with a face, looks clear when we are able to identify eyes, ears, nose, lips, forehead e.t.c very clear. This shape of an object is due to its edges. So in blurring, we simple reduce the edge content and makes the transition form one color to the other very smooth. Blurring vs zooming You might have seen a blurred image when you zoom an image. When you zoom an image using pixel replication, and zooming factor is increased, you saw a blurred image. This image also has less details, but it is not true blurring. Because in zooming, you add new pixels to an image, that increase the overall number of pixels in an image, whereas in blurring, the number of pixels of a normal image and a blurred image remains the same. Common example of a blurred image Types of filters Blurring can be achieved by many ways. The common type of filters that are used to perform blurring are. Mean filter Weighted average filter Gaussian filter Out of these three, we are going to discuss the first two here and Gaussian will be discussed later on in the upcoming tutorials. Mean filter Mean filter is also known as Box filter and average filter. A mean filter has the following properties. It must be odd ordered The sum of all the elements should be 1 All the elements should be same If we follow this rule, then for a mask of 3×3. We get the following result. 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 Since it is a 3×3 mask, that means it has 9 cells. The condition that all the element sum should be equal to 1 can be achieved by dividing each value by 9. As 1/9 + 1/9 + 1/9 + 1/9 + 1/9 + 1/9 + 1/9 + 1/9 + 1/9 = 9/9 = 1 The result of a mask of 3×3 on an image is shown below Original Image Blurred Image May be the results are not much clear. Let’s increase the blurring. The blurring can be increased by increasing the size of the mask. The more is the size of the mask, the more is the blurring. Because with greater mask, greater number of pixels are catered and one smooth transition is defined. The result of a mask of 5×5 on an image is shown below Original Image Blurred Image Same way if we increase the mask, the blurring would be more and the results are shown below. The result of a mask of 7×7 on an image is shown below. Original Image Blurred Image The result of a mask of 9×9 on an image is shown below. Original Image Blurred Image The result of a mask of 11×11 on an image is shown below. Original Image Blurred Image Weighted average filter In weighted average filter, we gave more weight to the center value. Due to which the contribution of center becomes more then the rest of the values. Due to weighted average filtering, we can actually control the blurring. Properties of the weighted average filter are. It must be odd ordered The sum of all the elements should be 1 The weight of center element should be more then all of the other elements Filter 1 1 1 1 1 2 1 1 1 1 The two properties are satisfied which are (1 and 3). But the property 2 is not satisfied. So in order to satisfy that we will simple divide the whole filter by 10, or multiply it with 1/10. Filter 2 1 1 1 1 10 1 1 1 1 Dividing factor = 18. Print Page Previous Next Advertisements ”;

DIP – Frequency Domain Analysis

Introduction to Frequency domain ”; Previous Next We have deal with images in many domains. Now we are processing signals (images) in frequency domain. Since this Fourier series and frequency domain is purely mathematics, so we will try to minimize that math’s part and focus more on its use in DIP. Frequency domain analysis Till now, all the domains in which we have analyzed a signal , we analyze it with respect to time. But in frequency domain we don’t analyze signal with respect to time, but with respect of frequency. Difference between spatial domain and frequency domain In spatial domain, we deal with images as it is. The value of the pixels of the image change with respect to scene. Whereas in frequency domain, we deal with the rate at which the pixel values are changing in spatial domain. For simplicity, Let’s put it this way. Spatial domain In simple spatial domain, we directly deal with the image matrix. Whereas in frequency domain, we deal an image like this. Frequency Domain We first transform the image to its frequency distribution. Then our black box system perform what ever processing it has to performed, and the output of the black box in this case is not an image, but a transformation. After performing inverse transformation, it is converted into an image which is then viewed in spatial domain. It can be pictorially viewed as Here we have used the word transformation. What does it actually mean? Transformation A signal can be converted from time domain into frequency domain using mathematical operators called transforms. There are many kind of transformation that does this. Some of them are given below. Fourier Series Fourier transformation Laplace transform Z transform Out of all these, we will thoroughly discuss Fourier series and Fourier transformation in our next tutorial. Frequency components Any image in spatial domain can be represented in a frequency domain. But what do this frequencies actually mean. We will divide frequency components into two major components. High frequency components High frequency components correspond to edges in an image. Low frequency components Low frequency components in an image correspond to smooth regions. Print Page Previous Next Advertisements ”;

DIP – Perspective Transformation

Perspective Transformation ”; Previous Next When human eyes see near things they look bigger as compare to those who are far away. This is called perspective in a general way. Whereas transformation is the transfer of an object e.t.c from one state to another. So overall, the perspective transformation deals with the conversion of 3d world into 2d image. The same principle on which human vision works and the same principle on which the camera works. We will see in detail about why this happens, that those objects which are near to you look bigger, while those who are far away, look smaller even though they look bigger when you reach them. We will start this discussion by the concept of frame of reference: Frame of reference: Frame of reference is basically a set of values in relation to which we measure something. 5 frames of reference In order to analyze a 3d world/image/scene, 5 different frame of references are required. Object World Camera Image Pixel Object coordinate frame Object coordinate frame is used for modeling objects. For example, checking if a particular object is in a proper place with respect to the other object. It is a 3d coordinate system. World coordinate frame World coordinate frame is used for co-relating objects in a 3 dimensional world. It is a 3d coordinate system. Camera coordinate frame Camera co-ordinate frame is used to relate objects with respect of the camera. It is a 3d coordinate system. Image coordinate frame It is not a 3d coordinate system, rather it is a 2d system. It is used to describe how 3d points are mapped in a 2d image plane. Pixel coordinate frame It is also a 2d coordinate system. Each pixel has a value of pixel co ordinates. Transformation between these 5 frames Thats how a 3d scene is transformed into 2d, with image of pixels. Now we will explain this concept mathematically. Where Y = 3d object y = 2d Image f = focal length of the camera Z = distance between object and the camera Now there are two different angles formed in this transform which are represented by Q. The first angle is Where minus denotes that image is inverted. The second angle that is formed is: Comparing these two equations we get From this equation, we can see that when the rays of light reflect back after striking from the object, passed from the camera, an invert image is formed. We can better understand this, with this example. For example Calculating the size of image formed Suppose an image has been taken of a person 5m tall, and standing at a distance of 50m from the camera, and we have to tell that what is the size of the image of the person, with a camera of focal length is 50mm. Solution: Since the focal length is in millimeter, so we have to convert every thing in millimeter in order to calculate it. So, Y = 5000 mm. f = 50 mm. Z = 50000 mm. Putting the values in the formula, we get = -5 mm. Again, the minus sign indicates that the image is inverted. Print Page Previous Next Advertisements ”;

DIP – Image Processing Introduction

Digital Image Processing Introduction ”; Previous Next Introduction Signal processing is a discipline in electrical engineering and in mathematics that deals with analysis and processing of analog and digital signals , and deals with storing , filtering , and other operations on signals. These signals include transmission signals , sound or voice signals , image signals , and other signals e.t.c. Out of all these signals , the field that deals with the type of signals for which the input is an image and the output is also an image is done in image processing. As it name suggests, it deals with the processing on images. It can be further divided into analog image processing and digital image processing. Analog image processing Analog image processing is done on analog signals. It includes processing on two dimensional analog signals. In this type of processing, the images are manipulated by electrical means by varying the electrical signal. The common example include is the television image. Digital image processing has dominated over analog image processing with the passage of time due its wider range of applications. Digital image processing The digital image processing deals with developing a digital system that performs operations on an digital image. What is an Image An image is nothing more than a two dimensional signal. It is defined by the mathematical function f(x,y) where x and y are the two co-ordinates horizontally and vertically. The value of f(x,y) at any point is gives the pixel value at that point of an image. The above figure is an example of digital image that you are now viewing on your computer screen. But actually , this image is nothing but a two dimensional array of numbers ranging between 0 and 255. 128 30 123 232 123 321 123 77 89 80 255 255 Each number represents the value of the function f(x,y) at any point. In this case the value 128 , 230 ,123 each represents an individual pixel value. The dimensions of the picture is actually the dimensions of this two dimensional array. Relationship between a digital image and a signal If the image is a two dimensional array then what does it have to do with a signal? In order to understand that , We need to first understand what is a signal? Signal In physical world, any quantity measurable through time over space or any higher dimension can be taken as a signal. A signal is a mathematical function, and it conveys some information. A signal can be one dimensional or two dimensional or higher dimensional signal. One dimensional signal is a signal that is measured over time. The common example is a voice signal. The two dimensional signals are those that are measured over some other physical quantities. The example of two dimensional signal is a digital image. We will look in more detail in the next tutorial of how a one dimensional or two dimensional signals and higher signals are formed and interpreted. Relationship Since anything that conveys information or broadcast a message in physical world between two observers is a signal. That includes speech or (human voice) or an image as a signal. Since when we speak , our voice is converted to a sound wave/signal and transformed with respect to the time to person we are speaking to. Not only this , but the way a digital camera works, as while acquiring an image from a digital camera involves transfer of a signal from one part of the system to the other. How a digital image is formed Since capturing an image from a camera is a physical process. The sunlight is used as a source of energy. A sensor array is used for the acquisition of the image. So when the sunlight falls upon the object, then the amount of light reflected by that object is sensed by the sensors, and a continuous voltage signal is generated by the amount of sensed data. In order to create a digital image , we need to convert this data into a digital form. This involves sampling and quantization. (They are discussed later on). The result of sampling and quantization results in an two dimensional array or matrix of numbers which are nothing but a digital image. Overlapping fields Machine/Computer vision Machine vision or computer vision deals with developing a system in which the input is an image and the output is some information. For example: Developing a system that scans human face and opens any kind of lock. This system would look something like this. Computer graphics Computer graphics deals with the formation of images from object models, rather then the image is captured by some device. For example: Object rendering. Generating an image from an object model. Such a system would look something like this. Artificial intelligence Artificial intelligence is more or less the study of putting human intelligence into machines. Artificial intelligence has many applications in image processing. For example: developing computer aided diagnosis systems that help doctors in interpreting images of X-ray , MRI e.t.c and then highlighting conspicuous section to be examined by the doctor. Signal processing Signal processing is an umbrella and image processing lies under it. The amount of light reflected by an object in the physical world (3d world) is pass through the lens of the camera and it becomes a 2d signal and hence result in image formation. This image is then digitized using methods of signal processing and then this digital image is manipulated in digital image processing. Print Page Previous Next Advertisements ”;

DIP – Color Codes Conversion

Color Codes Conversion ”; Previous Next In this tutorial, we will see that how different color codes can be combined to make other colors, and how we can covert RGB color codes to hex and vice versa. Different color codes All the colors here are of the 24 bit format, that means each color has 8 bits of red, 8 bits of green, 8 bits of blue, in it. Or we can say each color has three different portions. You just have to change the quantity of these three portions to make any color. Binary color format Color:Black Image: Decimal Code: (0,0,0) Explanation: As it has been explained in the previous tutorials, that in an 8-bit format, 0 refers to black. So if we have to make a pure black color, we have to make all the three portion of R, G, B to 0. Color:White Image: Decimal Code: (255,255,255) Explanation: Since each portion of R, G, B is an 8 bit portion. So in 8-bit, the white color is formed by 255. It is explained in the tutorial of pixel. So in order to make a white color we set each portion to 255 and thats how we got a white color. By setting each of the value to 255, we get overall value of 255, thats make the color white. RGB color model: Color:Red Image: Decimal Code: (255,0,0) Explanation: Since we need only red color, so we zero out the rest of the two portions which are green and blue, and we set the red portion to its maximum which is 255. Color:Green Image: Decimal Code: (0,255,0) Explanation: Since we need only green color, so we zero out the rest of the two portions which are red and blue, and we set the green portion to its maximum which is 255. Color: Blue Image: Decimal Code: (0,0,255) Explanation: Since we need only blue color, so we zero out the rest of the two portions which are red and green, and we set the blue portion to its maximum which is 255 Gray color: Color: Gray Image: Decimal Code: (128,128,128) Explanation As we have already defined in our tutorial of pixel, that gray color Is actually the mid point. In an 8-bit format, the mid point is 128 or 127. In this case we choose 128. So we set each of the portion to its mid point which is 128, and that results in overall mid value and we got gray color. CMYK color model: CMYK is another color model where c stands for cyan, m stands for magenta, y stands for yellow, and k for black. CMYK model is commonly used in color printers in which there are two carters of color is used. One consist of CMY and other consist of black color. The colors of CMY can also made from changing the quantity or portion of red, green and blue. Color: Cyan Image: Decimal Code: (0,255,255) Explanation: Cyan color is formed from the combination of two different colors which are Green and blue. So we set those two to maximum and we zero out the portion of red. And we get cyan color. Color: Magenta Image: Decimal Code: (255,0,255) Explanation: Magenta color is formed from the combination of two different colors which are Red and Blue. So we set those two to maximum and we zero out the portion of green. And we get magenta color. Color: Yellow Image: Decimal Code: (255,255,0) Explanation: Yellow color is formed from the combination of two different colors which are Red and Green. So we set those two to maximum and we zero out the portion of blue. And we get yellow color. Conversion Now we will see that how color are converted are from one format to another. Conversion from RGB to Hex code: Conversion from Hex to rgb is done through this method: Take a color. E.g: White = (255, 255, 255). Take the first portion e.g 255. Divide it by 16. Like this: Take the two numbers below line, the factor, and the remainder. In this case it is 15 � 15 which is FF. Repeat the step 2 for the next two portions. Combine all the hex code into one. Answer: #FFFFFF Conversion from Hex to RGB: Conversion from hex code to rgb decimal format is done in this way. Take a hex number. E.g: #FFFFFF Break this number into 3 parts: FF FF FF Take the first part and separate its components: F F Convert each of the part separately into binary: (1111) ( 1111) Now combine the individual binaries into one: 11111111 Convert this binary into decimal: 255 Now repeat step 2, two more times. The value comes in the first step is R, second one is G, and the third one belongs to B. Answer: ( 255 , 255 , 255 ) Common colors and their Hex code has been given in this table. Color Hex Code Black #000000 White #FFFFFF Gray #808080 Red #FF0000 Green #00FF00 Blue #0000FF Cyan #00FFFF Magenta #FF00FF Yellow #FFFF00 Print Page Previous Next Advertisements ”;

DIP – JPEG compression

Introduction to JPEG Compression ”; Previous Next In our last tutorial of image compression, we discuss some of the techniques used for compression We are going to discuss JPEG compression which is lossy compression, as some data is loss in the end. Let’s discuss first what image compression is. Image compression Image compression is the method of data compression on digital images. The main objective in the image compression is: Store data in an efficient form Transmit data in an efficient form Image compression can be lossy or lossless. JPEG compression JPEG stands for Joint photographic experts group. It is the first interanational standard in image compression. It is widely used today. It could be lossy as well as lossless . But the technique we are going to discuss here today is lossy compression technique. How jpeg compression works First step is to divide an image into blocks with each having dimensions of 8 x8. Let’s for the record, say that this 8×8 image contains the following values. The range of the pixels intensities now are from 0 to 255. We will change the range from -128 to 127. Subtracting 128 from each pixel value yields pixel value from -128 to 127. After subtracting 128 from each of the pixel value, we got the following results. Now we will compute using this formula. The result comes from this is stored in let’s say A(j,k) matrix. There is a standard matrix that is used for computing JPEG compression, which is given by a matrix called as Luminance matrix. This matrix is given below Applying the following formula We got this result after applying. Now we will perform the real trick which is done in JPEG compression which is ZIG-ZAG movement. The zig zag sequence for the above matrix is shown below. You have to perform zig zag until you find all zeroes ahead. Hence our image is now compressed. Summarizing JPEG compression The first step is to convert an image to Y’CbCr and just pick the Y’ channel and break into 8 x 8 blocks. Then starting from the first block, map the range from -128 to 127. After that you have to find the discrete Fourier transform of the matrix. The result of this should be quantized. The last step is to apply encoding in the zig zag manner and do it till you find all zero. Save this one dimensional array and you are done. Note. You have to repeat this procedure for all the block of 8 x 8. Print Page Previous Next Advertisements ”;