blur estimation in frequency domain

Published on January 2017 | Categories: Documents | Downloads: 48 | Comments: 0 | Views: 270
of 68
Download PDF   Embed   Report

Comments

Content

.

A PROJECT REPORT ON A NEW REFERENCE-FREE IMAGE QUALITY INDEX FOR BLUR ESTIMATION IN THE FREQUENCY DOMAIN

ABSTRACT

Image blur occurs often when using a camera due to handshake or jitter. Although there exist many motion de-blurring algorithms in the literature, the computational complexities of these algorithms and the assumptions considered make them unsuitable for deployment on a cell-phone camera processor. This project presents a new reference-free image quality index based on spectral analysis is proposed. The main idea is based on exploiting the limitations of the Human Visual System (HVS) in blur detection; the proposed method consists of adding blur to the test image and measuring its impact. The impact is measured using radial analysis in the frequency domain . The efficiency of the proposed method is tested objectively by comparing it to some well known algorithms and in terms of correlation with subjective scores.

INTRODUCTION When a photograph is taken in low light conditions or of a fast moving object, motion blur can cause significant degradation of the image . This is caused by the movement of the object relative to the sensor in the camera during the time the shutter is open. Both the object moving and camera shake contribute to this blurring. The problem is particularly apparent in low light conditions when the exposure time can often be in the region of several seconds. There are several techniques for either preventing image motion blurring at the time of image capture or Post processing images to remove motion blur. As well as in every day photography, the problem is particularly important to applications such as video surveillance where low quality cameras are used to capture sequences of photographs of moving objects (usually people). Current techniques can be split roughly into the following categories:
 Hardware in the optical system of the camera to stabilize the image  Post processing of the image to remove motion blur by estimating the camera's motion  From a single photograph (blind de-convolution)

 From a sequence of photographs

A hybrid approach that measures the camera's motion during photograph capture.

Blurring for Beginners
This is a short tutorial on blurring techniques for beginners. When I was learning this stuff, there was very little available material which was useful. That's not true of course - there was masses of material, but half of it was way too simple and the other half began "Let T be a vector function evaluated over the half-open interval...." and was full of very scary multi-line equations with those big sigma symbols and things. This article is meant to remedy that. I'll talk about various kinds of blur and the effects you can use them for, with source code in Java.

A Disclaimer
Whenever blurring is mentioned, there's always somebody who says "Hey! That's not a real motion blur!", or writes angry letters in green ink complaining that the mathematics is dubious or that there's a much faster way to do this using the sponglerizer registers on the HAL-9000. Ignore these people. This is a big subject, and this article is just for beginners (of which I can proudly say I am one). What matters is you get the results that you're aiming for, and if the results you're aiming for require dubious mathematics, then so be it. If the results you're aiming for look horrible to me, then that's fine, as long as they look good to you.

Another Disclaimer
There's source code in Java for pretty well everything I talk about here. I make no claims that these are optimised in any way - I've opted for simplicity over speed everywhere and you'll probably be able to make most of these thing go faster with a bit of effort. You can use the source code for anything you want, including commercial purposes, but there's no liability. If your nuclear power station or missile system fails because of an improper blur, it's not my fault.

What is Blurring?
We all know what blurring is, don't we? It's that thing that happens when your camera is out of focus or the dog steals your glasses. What happens is that what should be seen as a sharp point gets smeared out, usually into a disc shape. In image terms this means that each pixel in the source image gets spread over and mixed into surrounding pixels. Another way to look at this is that each pixel in the destination image is made up out of a mixture of surrounding pixels from the source image. The operation we need for this is called convolution. This sounds complicated but thats only because mathematicians like to make things sound complicated in order to maintain that air of magic and keep the funding rolling in. Well, I'm onto them and I can reveal that convolution is not that complicated (at my level anyway). The way it works is this: we imagine sliding a rectangular array of numbers over our image. This array is called the convolution kernel. For every pixel in the image, we take the corresponding numbers from the kernel and the pixels they are over, multiply them together and add all the results together to make the new pixel. For example, imagine we want to do a really simple blur where we just average together each pixel and its eight immediate neighbours. The kernel we need is:
1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9

Notice that these all add up to 1, which means that our resulting image will be just as bright as the original. Without further ado, let's blur an image in Java. All that convolution stuff sounds tricky to implement, but luckily Java comes with a built-in and ready-to-use operator to do exactly that. I'm talking ConvolveOp here. Here's the code:

The Original and Blurred Images Fantastic! A blurry image! It's not very blurry though. Let's do a really big blur like this:

Big Blur with ConvolveOp Hmmmmmm. Well that's not so good. Not only did it take a really long time, but the result is slightly odd - everything looks, well, sort of square, and what on earth has happened around the edges? First the edges: Convolve is a timid namby-pamby thing which is scared of falling off the edge of the image. If the kernel would overlap the edge of the image, it just gives up and just leaves the pixel unchanged. You can change this by passing EDGE_ZERO_FILL instead of EDGE_NO_OP, but that's even worse - the pixels round the edge just get set to zero and effectively disappear. What shall we do? Well, we could pad the image out around the edges before blurring and crop the result, but that's just giving in, and besides we wouldn't learn anything. Instead, we'll write a proper, fearless, no-nonsense operator which isn't scared of edges. We'll call it Convolve Filter to distinguish it from Convolve

Now the squareness problem: The reason everything looks square is because what we're doing here is called a box blur - our kernel is shaped like a square, as if we're using a camera which has a square aperture. Incidentally, don't let anyone tell you that box blurs are useless - in fact if you're simulating the shadow cast by a square light, it's exactly what you want. Anyway, they'll come in useful further on. Another thing: don't get confused - I'm using the term box blur to refer to the shape of the kernel, not its profile, which I'm going to call a box filter. More on this later on. To get a more realistic blur, what we should have done is used a circle-shaped kernel. This simulates much better what a real camera does.

That's much better. We'll come back to this later on, but first a diversion back to the box blur.

Box Blur
We will solve the edge pixel problem, but our blur is still going really slowly, and things are only going to get worse. The problem is that the number of multiplications in the convolution is going up as the square of the kernel radius. With a 100x100 kernel, we're going to be doing 10000 multiplies and adds per pixel (approx). How can we get round this? It turns out that there are more ways to go about this than I've possibly got time to write about, or even bother to look at. One way I will mention quickly before sweeping it under the rug is this: You can do a box blur by shrinking down your image, blurring it and scaling it up again. This may be fine for your purposes, and you should bear it in mind. One problem is that it doesn't animate very well, but may not be a concern to you. Let's look at the box blur again: It turns out that there's a couple of really easy ways to speed this up. Firstly, it turns out that the box blur is separable. This means that we can do a 2D blur by

doing two 1D blurs, once in the horizontal direction and once in the vertical direction. This is much faster than doing the 2D blur because the time taken goes up in proportion to the kernel size, not as its square. Secondly, Think about the window that we're sliding across the image. As we move it from left to right, pixels come in at the right edge and are added to the total and at the same time pixels leave the left edge and are subtracted from the total. All we need to do is just do the add and subtract for the entering and leaving pixels at each step instead of adding together all the pixels in the window. We only need to store a set of running totals which are the width or height of the kernel. This gives a massive speed improvement at the cost of having to write some code. Luckily, I've written the code for you, so you win all round. We need two passes, once to blur horizontally and once vertically. The code for these is, of course, quite different. But wait! There's a trick we can do which allows us just to write the code once. If we write a blurring function which does the horizontal blur but writes its output image transposed, then we can just call it twice. The first pass blurs horizontally and transposes, the second pass does the same, but as the image is now transposed, it's really doing a vertical blur. The second transposition makes the image the right way up again and voila! - a very fast box blur. Try it out in this applet: You may have noticed that we have only used an integer radius so far which makes it easy to work out the array indices for the blurring. We can extend the technique to do sub-pixel blurring (i.e. a non-integral radius) simply by linear interpolation between the array values. My source code doesn't do this, but it's easy to add.

Gaussian Blur
Now it's time to address the speed and square-looking blur issues at the same time. To get rid of the square look to the blur, we need a circular-shaped kernel. Unfortunately, the trick we used for box blurs doesn't work with a circle but there's a loophole: If the kernel has the right profile - the Gaussian profile - then we can do a 2D blur by performing two 1D blurs, just like we did with the box blur. It's not so fast because the sliding window trick doesn't work, but it's still a lot faster than doing the 2D convolution. The profile we need is the familiar bell-shaped, or Gaussian curve that you've heard of:

Gaussian Blur Here's some code to create a 1D Gaussian kernel for a given radius. All we need to do is to apply this twice, once horizontally and once vertically. As a bonus, I've wrapped it up in a Gaussian Filter to make it easy to use. This is why the Gaussian blur is found in every graphics package - it's much faster than other types of blur. The only problem is that it's not very realistic when it comes to simulating camera lenses, but more on that later. If you want to do things like simulating shadows, then the Gaussian blur, or even the box blur may be just fine. There's a place for all these effects - just because they aren't realistic doesn't mean they're not useful. The Gaussian blur is much faster, but it's nowhere near as fast as our box blur we did earlier on. If only there was some way to combine the two. I imagine you've guessed by now that there might be one, so I'll not hold the suspense any longer: If you do a lot of box blurs, the result looks more and more like a Gaussian blur. In fact, you can prove it mathematically if you've a spare moment (but don't tell me how - I'm not interested). In practice, 3 to 5 box blurs look pretty

good. Don't just take my word for it: The box blur applet above has an "Iterations" slider so you can try it out for yourself.

Box Blur: 1, 2 and 3 iterations

Alpha Channels
A quick diversion here to discuss a problem which often crops up: Imagine you want to blur a shape which is on a transparent background. You've got an empty image, and you draw a shape on it, then blur the image. Hang on - why does the blurry bit look too dark? The reason is that we've blurred each channel separately, but where the alpha channel is zero (the transparent bits), the red, green and blue channels are zero, or black. When you do the blur, the black gets mixed in with the opaque bits and you get a dark shadow. The solution is to pre-multiply the image alpha before blurring and un-pre-multiply it afterwards. Of course, if your images are already pre-multiplied, you're all set.

Blur: Separate and Premultiplied Alpha

Motion Blur
Time for a change of direction. So far we've only talked about uniform blurs, but there are other types. Motion blur is the blur you get when an object (or the camera) moves during the exposure. The image gets blurred along the apparent path of the object. Here we're just going to be talking about simulating motion blur on an existing still image - doing motion blur in animations is a whole different area. We're also only going to be blurring the whole image - we're not going to try and blur an object in the image. The good news is that we've already done simple motion blur. Go back to the box blur applet above and set the horizontal radius to, say 10, and the vertical radius to zero. This gives you a nice horizontal motion blur. For some purposes, this may be all you need. For example, one way to produce a brushed metal texture is to take an image consisting of random noise and apply a motion blur.

If we want to blur in a direction other than horizontal or vertical, then things get more complicated. One technique might be to rotate the image, blur and then rotate back. What we'll do here though is to do it the hard and slow way. What we need to do is loop over the image, and

for every pixel, add up all the pixels along the motion path. For a straight motion blur, this just means following a straight line from the pixel, but you could follow a wiggly path if you wanted to simulate long-exposure camera shake, say.

Spin and Zoom Blur
Once we've got the code for motion blur in place, it's a simple matter to modify it to do zoom and spin blurs, or even a combination of all three. It's just a matter of following the right path for each pixel. For radial blurs, just follow a path going from the blur center. For a spin blur, follow a tangential path.

Zoom and Spin Blur

Faster Motion Blur
You may have noticed that doing the motion blur is a pretty slow business - all those sines and cosines really slow things down. If we're not so worried about quality though, we can speed this up. All we need to do is add together a lot of transformed versions of the image in a clever way. The clever part is that we can do a 1-pixel motion blur by averaging the image and the same image translated by one pixel. We can do a 2-pixel blur by repeating this with the 1-pixel blurred images. By repeating this we can do an N-pixel blur in log2(N) operations, which is a lot better than doing it the hard and slow way. Zoom and spin blurs can be done by scaling and rotating instead of translating. One filter will do all three using an affine Transform.

Domain Shifting
There's yet another way to do these motion blurs: Remember I said you could do the linear motion blur by rotating the image, doing a horizontal box blur and rotating back? Well, the same is true of the zoom and spin blurs, except you need something more complicated than rotation. What you need is the polar transform:

Polar Transform Once you've transformed your image, a horizontal box blur is a spin when you transform back, and a vertical box blur gives you a zoom blur. One detail is that you need a special horizontal box blur which wraps at the edges otherwise you'll get a sharp vertical line in your blurred image where the spin angle should wrap round.

Blurring by Fourier Transform
The Gaussian blur is very fine when you want that Gaussian blur effect, but what if you want a proper lens blur which simulates a real camera aperture? Watch any film or TV program for a while, especially something shot at night with lights in the background, and you'll see that things which are out of focus form disk shapes, or perhaps pentagons. There's also a phenomenon called blooming where bright parts of the image wash out the image, becoming even brighter compared to the rest. These shapes are called Bokeh. Some people love it and some people hate it. We don't care whether people love it or hate it, we just want to reproduce it.

Bokeh (real, not faked) You won't get those disk shapes with Gaussian blur - it's just too fuzzy round the edges. What you need to do it use a nice sharp-edged convolution kernel in the shape of your camera aperture. The problem you'll come across here is that all those tricks to do with separable kernels, iterated box blurs and the like won't work here - there's no separable kernels which will give you a pentagon (well, probably - I'm no mathematician) - we're back to the old problem of the blur time going up as the square of the blur radius. Fear not, we can turn the heavy mathematical guns onto the problem. I don't know how the heavy guns work, but I can aim them. The heavy guns are Fourier Transforms. I don't know how they work because I wasn't listening in my university lectures, but there's a vast amount on the subject you can find on the Internet, although practically nothing practical (i.e. with source code) on the subject of blurring. With Fourier Transforms, you can make a blur which takes a time unaffected by the blur radius (in practice, dealing with the image edges means this isn't quite true). Unfortunately, this means that for a small radius, it's slow, but you really win with a large radius. One way to deal with this is to use the simple convolution for small radii, and switch to Fourier Transforms when you reach to crossover point in time, assuming you've done the experiments to determine where that is. But be careful, if you're animating a blur, you've got to make sure that you don't get any visible artifacts at the point where you switch algorithm - the eye is really good at spotting those. For that reason, you may prefer to stick with one algorithm for the whole of an animation. For still images, nobody is going to notice. Really.

Lens Blur with Blooming Does it really look any different? Surely, we can get away with a Gaussian blur? Well, here's an example which will help you make up your mind.

Original, Lens Blur, Triangle Aperture and Gaussian Blur The principle behind doing the blur is not too hard, although it seems like magic. What we do is take the image and the kernel, and perform the Fourier transform on them both. We then multiply

the two together and inverse transform back. This is exactly the same as performing the long convolution above (apart from rounding errors). You don't actually need to know what a Fourier transform does to implement this, but anyway, what it does is to convert your image into frequency space - the resulting image is a strange-looking representation of the spatial frequencies in the image. The inverse, of course, transforms back to space.., er, space. Think of it like a graphic equalizer for images. You can think of blurring an image as removing high frequencies from it, so that's how Fourier transforms come into the picture. Implementing this is actually fairly straightforward, but there are a lot of nasty details to worry about. First of all we need some functions to do the transform and its inverse. These can be found in the class FFT. This is not by any means a super-optimized implementation - you can find many of those elsewhere on the Internet. Next, we need to convert the kernel into an image the same size as the image we're blurring (I'm sure there are ways to avoid this, but I don't know enough maths - if only I'd been listening in those lectures). We also need to pad out our source image by the radius of the blur, duplicating the edge pixels as it's hard to get the FFT to deal with edges like this. Now, the FFT works on complex numbers, so we need to copy the image and kernel into float arrays. We can do a trick here - our images have four channels (alpha, red, green and blue) so we need to do four transforms plus one for the kernel, making five, but since we're using complex numbers we can do two transforms at once by puttng one channel in the real part of the array and one channel in the imaginary part. Now things get easy, just transform the image and kernel, complex multiply them together and inverse transform and we have our image back, but convolved with the kernel. One last tiny detail is that the transformation process swaps over the quadrants of the image so we need to unswap. Only one small detail remains: the FFT only works on images which are a power of 2 in each direction. What we have to do is to add twice the blur radius to the width and height, find the next highest power of 2 and make our arrays that size. For big images this has a couple of problems: One is that we're using up lots of memory. Remember we have our images in float arrays and we need 6 of these arrays, each of which is 4 times the size of the image when it's been expanded to a power of two. Your Java virtual machine may well complain at you if you try this on a big image (I know, I've tried). The second problem is related: Things just go slower with the large images because of memory caching problems. The answer is to split the image up

into tiles and blur each tile separately. Choosing a good tile size is an option research problem (i.e. I haven't been bothered to experiment much), but is tricky - we need to overlap the tiles by the blur radius so if we chose a tile size of 256 with a blur radius of 127, we'd only be blurring 4 pixels with each tile.

Threshold Blurs
Something which is often wanted is a blur which blurs parts of the image which are very similar but preserves sharp edges. This is digital wrinkle cream and you can see this in any movie poster ever printed - the stars' faces have all those nasty blemishes ironed out without the image appearing blurry. Often this is so overdone that the actors look like waxworks or computergenerated figures.

Original Image and Threshold Blur The way we do this is to do an ordinary convolution, but only count in surrounding pixels which are similar to the target pixel. Specifically, we have a threshold and only include a pixel in the convolution if it differs from the center pixel by less than the threshold. Unfortunately, the short cuts we took above won't work here as we need to include a different set of surrounding pixels for each target pixel, so we're back to the full convolution again. Now, although this is extremely dubious, it actually works quite well to still do the two 1D convolutions for a Gaussian blur which is faster than doing the full 2D convolution, so that's what I've done here. Feel free to modify the source to do the full thing.

Variable Blurs
So far we've only talked about uniform blurs - where the blur radius is the same at each point. For some purposes, it's nice to have blurs which have a different radius at each point in the image. One example is simulating depth of field: You could take an image which is in focus all over and apply a variable blur to it to make parts look out of focus. Real depth of field is more complicated than this because an object which is behind another object shouldn't receive any blur from the object in front, but we'll ignore that and leave it to the professionals. Now, our fancy tricks above aren't going to help us much here as everything involves precalculating kernels or relies on the blur radius being the same over the image and at first sight it looks like we've got no option but to fall back on the full convolution at each pixel, only this time it's much worse as the kernel might have changed from the previous pixel. However, all is not lost. Remember that trick with box blurs where we just added in pixels as they entered the kernel and subtracted them as they left? It seems as though this won't work in the variable radius case because we'd have to keep totals for every possible radius, but there's a modification we can make to the trick which enables us to magically pull out the totals for any radius with only one subtraction. What we do is preprocess the image and replace every pixel by the sum of all the pixels to the left. That way when we want to find the total of all the pixels between two points in a scanline, we just need to subtract the first from the second. This enables us to do a fast variable blur using a modified version of the box blur code above. Dealing with the edges is slightly more complicated as simply subtracting the totals doesn't work for pixels off the edge, but this is a minor detail. We also need a bit more storage space because the totals will go above the maximum value of a pixel - we'll need to to use an int per channel instead of storing four channels in one int.

Variable Blur - increasing with radius Well, OK, but this is a Gaussian(ish) blur isn't it? What about doing that lens blur thing with variable radius? Unfortunately, you're out of luck here. I'm not saying there isn't a super fast way of doing this, but as far as I know you're going to have to do the full convolution thing. Try it out in this applet, which blurs more as you move to the right:

Sharpening by Blurring
You can use a blur to sharpen an image as well as blur it using a technique called unsharp masking. What you do is take the image and subtract a blurred version, making sure you compensate for the loss of brightness. This sounds like magic, but it really works: compare this image with the original.

Sharpening with Unsharp Mask

Glow
If subtracting a blurred version of an image from itself sharpens it, what does adding it do? As ever, there's no need to guess - I'm here to inform you. What you get is a sort of glowing effect

which can look quite nice, or quite cheesy depending on your point of view. Varying the amount of blur added in varies the glowing effect. You can see this effect used a lot on television for dreamy-looking transitions.

Glowing Blur

 Making Shadows  Making a shadow is just a matter of creating an image which looks like the silhouette of the the shadowing object, blurring it, possibly distorting or moving it, and pasting the original image over the top. As this is a really common thing to want to do, there ought to be a filter to do it, And here it is...

Adding Shadows This is actually a very simplistic implementation - it just blurs the shadow and draws the original image over the top. In practice, it's better to not bother blurring the pixels which are completely hidden by the object.

Casting Rays
We can do the same trick to make light rays appear to come out of an object, only this time making the shadow color white and using a zoom blur instead of the ordinary blur, then adding the result on top of the original.

Light Rays The rays often look better if you only cast them from bright parts of the image, so the filter has a threshold which you can set to restrict rays to bright areas. This is a good effect to animate: make the centre of the rays move across the image and you get the effect of a moving light source behind the image.

IMAGE BLUR MODEL:
Image blur is a common problem. It may be due to the point spread function of the sensor, sensor motion, or other reasons.

Linear model of observation system is given as g(x, y) = f(x, y) ? h(x, y) + _(x, y)

CAUSES OF BLURRING: The blurring, or degradation, of an image can be caused by many factors: 1. Movement during the image capture process, by the camera or, when long exposure times are used, by the subject. 2. Out-of-focus optics, use of a wide-angle lens, atmospheric turbulence, or a short exposure time, which reduces the number of photons captured. 3. Scattered light distortion in confocal microscopy. NEGATIVE EFFECTS OF MOTION BLUR: In televised sports where conventional cameras expose pictures 25 or 30 times per second, motion blur can be inconvenient because it obscures the exact position of a projectile or athlete in slow motion .For this reason special cameras are often used which eliminate motion blurring

by taking rapid exposures on the order of 1/1000 of a second, and then transmitting them over the course of the next 1/25 or 1/30 of a second. Although this gives sharper slow motion replays it can look strange at normal speed because the eye expects to see motion blurring and does not. Sometimes, motion blur can be removed from images with the help of deconvolution.

THEORY:

Image quality assessment plays nowadays an important role in various multimedia applications. This research carried in area has reached a certain level of maturity in the multimedia communications community. Several image quality metrics have been proposed in the literature [I. Avcibas et al., 2002]. Unfortunately, in the absence of a universal image quality index, people still continue to use the classical PSNR (Peak Signal to Noise Ratio) in many applications. Moreover, the problem of finding the best image quality index becomes more challenging when various types distortions are considered. As such, many of the researchers continue to propose new heuristic metrics based on psychophysical tests and some established databases. The intend of this work is not to propose a quality index for all the known distortions but rather to focus on a particular artifact, namely blurring. This artefact mostly affects salient features such as contours and can result in drastic quality degradation. The fine details lost due to the blur correspond to the high frequencies in the image. This phenomenon is commonly found in compression applications in which high frequency components are generally neglected. We will discuss in what follows a number of techniques used in estimating blur, then we present our own approach and discuss how it is used in developing the new quality index. A suitable quantity for evaluating the image quality in mammography is the smallest visible size of an object. This quantity, called the image quality index (IQI), can be derived from the basic image parameters: contrast, MTF, Wiener spectrum. Several evaluation methods of the IQI, all based on statistical decision theory, have been considered. An experimental visibility test using simulated microcalcifications has been

performed in order to compare the results obtained with different IQI models. A previous approach, based on simplifying assumptions, yields a good correlation with the visibility test but fails to predict the actual size of the visible objects. Improved models have been derived for an ideal observer and for a 'quasi-ideal' one with perfect or with realistic visual characteristics. The experimental visual results are well modelled by the IQI method, provided that a suitable threshold signal-to-noise ratio is used for each of these models

Previous works:
H. Tong et al., in 2004, a blur estimation method based on wavelets was proposed. An edge map is obtained after combining the coefficients of high frequencies of each decomposition level. The blur measure is then obtained by analyzing the type of the edge contained in the image X. Marichal et al., in 1999, a no reference blur estimation method based on DCT is proposed. First, a block-wise DCT transform is applied to the image. By comparing the DCT coefficients inside each block 8x8 to some thresholds, a global blur measure is then derived. J. Caviedes et al., in 2004 the DCT is used to estimate the blur without a reference image. The idea is to measure the peakedness of each block 8x8 around each edge point by computing the kurtosis coefficient. Then, the kurtosis coefficient is computed in each block. The mean value of the kurtosis coefficients is then used as a global measure of the blur. In this work, we propose a new blur estimation inspired by the idea developed in [F. Crete et al., 2007]. It is worth noting that since blurring affects mainly object contours, most blur estimation algorithms are based primarily on edge detection. However, in the case of highly blurred images, edge detection fails resulting in poor estimation of the blurring artefact. Here, we adopt another approach without referring to edge detection. The idea is to add blur to the distorted image and analyze its impact on the image quality. A radial analysis in the frequency domain is applied to both the distorted image and its filtered version. A Blur Index (BI) is then computed from this radial analysis.

Proposed methods:
To estimate the blurring effect by first adding blur to the test image, then analyzing its effect. Figure 1 displays three images with different levels of blur. One can note that the human perception of blur depends upon the original image ”blurriness” level of the original image. In figure 1, the application of a first blur yields the image displayed in Fig. 1.b whereas Fig. 1.c is the application of a second blur to image in Fig. 1b, using the same filter.

We can see that the perceptual difference is more visible between the images in Fig. 1.a and Fig. 1.b than the images Fig. 1.b and Fig. 1.c in spite of having used the same filtering strength. Therefore, the perceived HVS estimation of blur is not monotonic. Also we can note that the impact of the blurring for a given image depends on the original image quality level, i.e. sharpness/blur strength. In other words, the blur effect on an already blurred image has less perceptual impact than on a sharpened image.

Fig. 1. a) Original image, b) Filtered image with a 3x3 binomial filter and

c) Result of applying the same filter to the filtered image with a 3x3 binomial fillter. In order to better visualize this effect, we consider a 2D random test signal. We analyze the energy spectrum of this signal and the result of applying a 3x3 binomial filter repeatedly, first to the original signal and then to this filtered version. The energy spectrum of the original and the filtered signals are displayed on Fig. 2. It could be noticed that the filter impact is effectively less visible on the energy spectrum as shown in Fig. 2b and Fig. 2c. Based on the above observations, we propose to exploit this characteristic of the HVS to evaluate the blur in an image by applying a blurring operation, then analyzing the impact of this degradation to quantify the quality of the original image.

After transforming both the original and the blurred images into the frequency domain, we apply a radial analysis and deduce a Blur Quality Index [A. Beghdadi et al., 2000]. The flowchart of the proposed algorithm is illustrated in figure 3. The first step consists of adding blur to the degraded image. We propose to simulate the blur with a 3x3 binomial filter. Figure 4 shows an example of a test image. Figs. 4.a and 4.b show a real image and its degraded version, respectively. A zoomed zone taken from the original and filtered images is displayed in Fig. 4.c and Fig. 4.d.

Fig. 2. a) Energy spectrum of the original signal, b) Energy spectrum of the filtered signal c) Energy spectrum of the refiltered signal.

Fig. 4. a) Original image, b) Filtered image with a 3x3 binomial filter and c) Result of applying the same filter to the filtered image with a 3x3 binomial filter

Once the test image and its filtered version are obtained, the discrete Fourier transform of the two images is computed using the following equation:

Where F(u,v) represent the centered Fourier coefficients corresponding the image f(x,y). (X,Y) represent the size of the image and (u,v) are the spatial frequencies.

The energy spectrum is obtained as follows:

with R(u,v) and I(u,v) are the real and imaginary parts of F(u,v), respectively. F(u,v) is then transformed into polar coordinates represented by F(ω, θk). An expression for the total radial energy is then obtained using the following:

with

with ER(ω) and ERf (ω) corresponding to the test image and its filtered version at the frequency ω, respectively. Figures 5.a and 5.b display an example of a color image and its blurred version. Figs. 5.c and 5.d show the results from radial analysis of images 5.c and 5.d respectively.

Fig. 5. a-b) Original and blurred images, c-d) Radial analysis of the images in 5.a and 5.b, respectively

Based on the above energy measures, we propose a global Blur Index (BI) defined as:

where ωmax is the maximal frequency of w .

EXPERIMENTAL RESULTS: A. Objective tests:
The procedure described above was tested on a number of images containing different levels of blur. Fig. 6 shows an example from natural images. Fig. 6.a is the reference image while Fig. 6.b and 6.c are two distorted versions of the image 6.a. The resulting BIs are 9.56, 11.55 and 12.20, respectively To evaluate the performance of the proposed index, we carried both objective and subjective testing. These tests are described below which correspond well to perceptual quality ranking.

Fig. 6. a) Original image with BI = 9.5574 and DMOS= 35.0583, b) Degraded image with BI= 11.5492 et DMOS = 43.2751 et c) Degraded image with BI = 12.1937 et DMOS = 67.0564.

B. Subjective tests:
In our experiments, the efficiency of the proposed method was tested using two image databases: LIVE database release 2 [H.R. Sheikh et al.] and IVC [P. Le Callet et al.]. The performance is evaluated in terms of correlation between the proposed index (BI) and subjective scores.

1) Database for subjective testing:
The LIVE database provides the Difference Mean Opinion Scores (DMOS). The participants in the database were asked to provide their perception of quality on a continuous linear scale divided into five equal regions marked as ”‘Bad”’,”’Poor”’, ”‘Fair”’,”’Good”’and “Excellent”.

Each image was rated by around 20 to 30 observers. Each distortion type was evaluated by different subjects in the same viewing conditions. A DMOS value of zero corresponds to a high image quality while a high DMOS value corresponds to a poor image quality. The database used contains different types of degradations. Here, the performance of our method is tested using only the Gaussian blur images. Some images from the database are displayed in Fig. 7. For the IVC database, the authors describe it as follows: ”Subjective evaluations were made at viewing distance of 6 times the screen height using a DSIS (Double Stimulus Impairment Scale) method with 5 categories and 15 observers”. The IVC database provides the Mean Opinion Scores (MOS) where MOS equal zero corresponds to a poor quality of the image and higher the MOS is, high the quality of the image is. As far as the database used contains different types of degradations. Here, we test the proposed method using only the Gaussian blur images. Fig. 8 presents some reference images of the IVC database.

Fig. 7. Some reference images of the LIVE database

Fig. 8. Some reference images of the IVC database.

2) Analysis of the results:
To test the efficiency of the proposed method, we compare our method with some previously developed techniques [2, 5]. Also, we implement the proposed radial analysis and BI stimation using the original image and its blurred version. For benchmarking purposes, we chose the popular SSIM metric [Z. Wang et al., 2004], named here Blur-SSIM. Table 1 summarizes the results for the correlation coefficients for both the LIVE and IVC databases. The best correlation is obtained for the proposed method excepted for the LIVE database, the BlurM obtained sensibly a higher correlation than the proposed method. Indeed, the obtained correlation is equal to 0.938 using the IVC database. To observe the distribution of the BI compared with subjective scores, we plot also the BI versus DMOS of the LIVE database curve in figure 9. Note that scatters of these distributions are smaller.

APPLICATIONS OF MOTION BLUR: 1) Photography 2) Computer animation PHOTOGRAPHY: When a camera creates an image, that image does not represent a single instant of time. Because of technological constraints or artistic requirements, the image represents the scene over a period of time. As objects in a scene move, an image of that scene must represent an integration of all positions of those objects, as well as the camera's viewpoint, over the period of exposure determined by the shutter speed In such an image, any object moving with respect to the camera will look blurred or smeared along the direction of relative motion. This smearing may occur on an object that is moving or on a static background if the camera is moving. In a film or television image, this looks natural because the human eye behaves in much the same way.

Because the effect is caused by the relative motion between the camera, and the objects and scene, motion blur may be avoided by panning the camera to track those moving objects. In this case, even with long exposure times, the objects will appear sharper, and the background more blurred.

Computer animation:
Similarly, in real-time computer animation each frame shows a perfect instant in time (analogous to a camera with an infinitely fast shutter), with zero motion blur. This is why a video game with a frame rate of 25-30 frames per second will seem staggered, while natural motion filmed at the same frame rate appears rather more continuous. Many next generation video games feature motion blur, especially vehicle simulation games. In pre-rendered computer animation, such as CGI movies, realistic motion blur can be drawn because the renderer has more time to draw each frame.

CONCLUSIONS AND PERSPECTIVES
An efficient no-reference blur quality index is proposed. The method is not based on edge detection as most existing methods. Instead, we use a basic radial analysis in the frequency domain to measure the impact of blur added to the original image. The obtained results in terms of correlation with the subjective tests prove the efficiency of the proposed method. The efficiency of the proposed method could be improved by taking into account some HVS properties as contrast sensibility function.

INTRODUCTION TO MAT LAB APPENDIX-A DIGITAL IMAGE PROCESSING:
Digital image processing is an area characterized by the need for extensive experimental work to establish the viability of proposed solutions to a given problem. An important characteristic underlying the design of image processing systems is the significant level of testing & experimentation that normally is required before arriving at an acceptable solution. This characteristic implies that the ability to formulate approaches &quickly prototype candidate solutions generally plays a major role in reducing the cost & time required to arrive at a viable system implementation. WHAT IS DIP? An image may be defined as a two-dimensional function f(x, y), where x & y are spatial coordinates, & the amplitude of f at any pair of coordinates (x, y) is called the intensity or gray level of the image at that point. When x, y & the amplitude values of f are all finite

discrete quantities, we call the image a digital image. The field of DIP refers to processing digital image by means of digital computer. Digital image is composed of a finite number of elements, each of which has a particular location & value. The elements are called pixels. Vision is the most advanced of our sensor, so it is not surprising that image play the single most important role in human perception. However, unlike humans, who are limited to the visual band of the EM spectrum imaging machines cover almost the entire EM spectrum, ranging from gamma to radio waves. They can operate also on images generated by sources that humans are not accustomed to associating with image.

There is no general agreement among authors regarding where image processing stops & other related areas such as image analysis& computer vision start. Sometimes a distinction is made by defining image processing as a discipline in which both the input & output at a process are images. This is limiting & somewhat artificial boundary. The area of image analysis (image understanding) is in between image processing & computer vision.

There are no clear-cut boundaries in the continuum from image processing at one end to complete vision at the other. However, one useful paradigm is to consider three types of computerized processes in this continuum: low-, mid-, & high-level processes. Low-level process involves primitive operations such as image processing to reduce noise, contrast enhancement & image sharpening. A low- level process is characterized by the fact that both its inputs & outputs are images. Mid-level process on images involves tasks such as segmentation, description of that object to reduce them to a form suitable for computer processing & classification of individual objects. A mid-level process is characterized by the fact that its inputs generally are images but its outputs are attributes extracted from those images. Finally higher- level processing involves “Making sense” of an ensemble of recognized objects, as in image analysis & at the far end of the continuum performing the cognitive functions normally associated with human vision.

Digital image processing, as already defined is used successfully in a broad range of areas of exceptional social & economic value.

WHAT IS AN IMAGE?

An image is represented as a two dimensional function f(x, y) where x and y are spatial co-ordinates and the amplitude of ‘f’ at any pair of coordinates (x, y) is called the intensity of the image at that point.

Gray scale image:

A grayscale image is a function I (xylem) of the two spatial coordinates of the image plane. I(x, y) is the intensity of the image at the point (x, y) on the image plane. I (xylem) takes non-negative values assume the image is bounded by a rectangle [0, a] × [0, b]I: [0, a] × [0, b] → [0, info) Color image:

It can be represented by three functions, R (xylem) for red, G (xylem) for green and B (xylem) for blue. An image may be continuous with respect to the x and y coordinates and also

in amplitude. Converting such an image to digital form requires that the coordinates as well as

the amplitude to be digitized. Digitizing the coordinate’s values is called sampling. Digitizing the amplitude values is called quantization.

Coordinate convention: The result of sampling and quantization is a matrix of real numbers. We use two principal ways to represent digital images. Assume that an image f(x, y) is sampled so that the resulting image has M rows and N columns. We say that the image is of size M X N. The values of the coordinates (xylem) are discrete quantities. For notational clarity and convenience, we use integer values for these discrete coordinates. In many image processing books, the image origin is defined to be at (xylem)=(0,0).The next coordinate values along the first row of the image are (xylem)=(0,1).It is important to keep in mind that the notation (0,1) is used to signify the second sample along the first row. It does not mean that these are the actual values of physical coordinates when the image was sampled. Following figure shows the coordinate convention. Note that x ranges from 0 to M-1 and y from 0 to N-1 in integer increments. The coordinate convention used in the toolbox to denote arrays is different from the preceding paragraph in two minor ways. First, instead of using (xylem) the toolbox uses the notation (race) to indicate rows and columns. Note, however, that the order of coordinates is the same as the order discussed in the previous paragraph, in the sense that the first element of a coordinate topples, (alb), refers to a row and the second to a column. The other difference is that the origin of the coordinate system is at (r, c) = (1, 1); thus, r ranges from 1 to M and c from 1 to N in integer increments. IPT documentation refers to the coordinates. Less frequently the toolbox also employs another coordinate convention called spatial coordinates which uses x to refer to columns and y to refers to rows. This is the opposite of our use of variables x and y. Image as Matrices: The preceding discussion leads to the following representation for a digitized image function:

f (0,0) f(1,0) f(xylem)= . .

f(0,1) f(1,1) . .

……….. …………

f(0,N-1) f(1,N-1) . .

f(M-1,0) f(M-1,1) ………… f(M-1,N-1) The right side of this equation is a digital image by definition. Each element of this array is called an image element, picture element, pixel or pel. The terms image and pixel are used throughout the rest of our discussions to denote a digital image and its elements.

A digital image can be represented naturally as a MATLAB matrix: f(1,1) f(1,2) ……. f(1,N) f(2,1) . f= . . f(2,2) …….. f(2,N) . . .

f(M,1) f(M,2) …….f(M,N)

Where f(1,1) = f(0,0) (note the use of a monoscope font to denote MATLAB quantities). Clearly the two representations are identical, except for the shift in origin. The notation f (p ,q) denotes the element located in row p and the column q. For example f (6, 2) is the element in the sixth row and second column of the matrix f. Typically we use the letters M and N respectively to denote the number of rows and columns in a matrix. A 1xN matrix is called a row vector whereas an Mx1 matrix is called a column vector. A 1x1 matrix is a scalar.

Matrices in MATLAB are stored in variables with names such as A, a, RGB, real array and so on. Variables must begin with a letter and contain only letters, numerals and underscores. As noted in the previous paragraph, all MATLAB quantities are written using mono-scope characters. We use conventional Roman, italic notation such as f(x ,y), for mathematical expressions

READING IMAGES: Images are read into the MATLAB environment using function imread whose syntax is imread(‘filename’)

Format name TIFF JPEG GIF BMP PNG XWD

Description Tagged Image File Format Joint Photograph Experts Group Graphics Interchange Format Windows Bitmap Portable Network Graphics X Window Dump

recognized extension .tif, .tiff .jpg, .jpeg .gif .bmp .png .xwd

Here filename is a spring containing the complete of the image file(including any applicable extension).For example the command line >> f = imread (‘8. jpg’); reads the JPEG (above table) image chestxray into image array f. Note the use of single quotes (‘) to delimit the string filename. The semicolon at the end of a command line is used by MATLAB for suppressing output. If a semicolon is not included. MATLAB displays the results of the operation(s) specified in that line. The prompt symbol (>>) designates the beginning of a command line, as it appears in the MATLAB command window. When as in the preceding command line no path is included in filename, imread reads the file from the current directory and if that fails it tries to find the file in the MATLAB search path. The simplest way to read an image from a specified directory is to include a full or relative path to that directory in filename. For example, >> f = imread ( ‘D:\myimages\chestxray.jpg’); reads the image from a folder called my images on the D: drive, whereas >> f = imread(‘ . \ myimages\chestxray .jpg’); reads the image from the my images subdirectory of the current of the current working directory. The current directory window on the MATLAB desktop toolbar displays MATLAB’s current working directory and provides a simple, manual way to change it. Above table lists some of the most of the popular image/graphics formats supported by imread and imwrite. Function size gives the row and column dimensions of an image: >> size (f) ans = 1024 * 1024

This function is particularly useful in programming when used in the following form to determine automatically the size of an image: >>[M,N]=size(f); This syntax returns the number of rows(M) and columns(N) in the image. The whole function displays additional information about an array. For instance ,the statement >> whos f gives Name F size 1024*1024 Bytes 1048576 Class unit8 array

Grand total is 1048576 elements using 1048576 bytes The unit8 entry shown refers to one of several MATLAB data classes. A semicolon at the end of a whose line has no effect ,so normally one is not used. Displaying Images: Images are displayed on the MATLAB desktop using function imshow, which has the basic syntax: imshow(f,g) Where f is an image array, and g is the number of intensity levels used to display it. If g is omitted ,it defaults to 256 levels .using the syntax imshow(f,{low high})

Displays as black all values less than or equal to low and as white all values greater than or equal to high. The values in between are displayed as intermediate intensity values using the default number of levels .Finally the syntax Imshow(f,[ ]) Sets variable low to the minimum value of array f and high to its maximum value. This form of imshow is useful for displaying images that have a low dynamic range or that have positive and negative values. Function pixval is used frequently to display the intensity values of individual pixels interactively. This function displays a cursor overlaid on an image. As the cursor is moved over the image with the mouse the coordinates of the cursor position and the corresponding intensity values are shown on a display that appears below the figure window .When working with color images, the coordinates as well as the red, green and blue components are displayed. If the left button on the mouse is clicked and then held pressed, pixval displays the Euclidean distance between the initial and current cursor locations. The syntax form of interest here is Pixval which shows the cursor on the last image displayed. Clicking the X button on the cursor window turns it off. The following statements read from disk an image called rose_512.tif extract basic information about the image and display it using imshow: >>f=imread(‘rose_512.tif’);

>>whos f Name F Size 512*512 Bytes 262144 Class unit8 array

Grand total is 262144 elements using 262144 bytes

>>imshow(f) A semicolon at the end of an imshow line has no effect, so normally one is not used. If another image,g, is displayed using imshow, MATLAB replaces the image in the screen with the new image. To keep the first image and output a second image, we use function figure as follows: >>figure ,imshow(g) Using the statement >>imshow(f),figure ,imshow(g) displays both images.

Note that more than one command can be written on a line ,as long as different commands are properly delimited by commas or semicolons. As mentioned earlier, a semicolon is used whenever it is desired to suppress screen outputs from a command line. Suppose that we have just read an image h and find that using imshow produces the image. It is clear that this image has a low dynamic range, which can be remedied for display purposes by using the statement. >>imshow(h,[ ]) WRITING IMAGES: Images are written to disk using function imwrite, which has the following basic syntax: Imwrite (f,’filename’) With this syntax, the string contained in filename must include a recognized file format extension .Alternatively, the desired format can be specified explicitly with a third input argument. >>imwrite(f,’patient10_run1’,’tif’) Or alternatively

For example the following command writes f to a TIFF file named patient10_run1: >>imwrite(f,’patient10_run1.tif’) If filename contains no path information, then imwrite saves the file in the current working directory. The imwrite function can have other parameters depending on e file format selected. Most of the work in the following deals either with JPEG or TIFF images ,so we focus attention here on these two formats. More general imwrite syntax applicable only to JPEG images is imwrite(f,’filename.jpg,,’quality’,q) where q is an integer between 0 and 100(the lower number the higher the degradation due to JPEG compression). For example, for q=25 the applicable syntax is >> imwrite(f,’bubbles25.jpg’,’quality’,25) The image for q=15 has false contouring that is barely visible, but this effect becomes quite pronounced for q=5 and q=0.Thus, an expectable solution with some margin for error is to compress the images with q=25.In order to get an idea of the compression achieved and to obtain other image file details, we can use function imfinfo which has syntax. Imfinfo filename Here filename is the complete file name of the image stored in disk. For example, >> imfinfo bubbles25.jpg outputs the following information(note that some fields contain no information in this case):

Filename: ‘bubbles25.jpg’ FileModDate: ’04-jan-2003 12:31:26’ FileSize: Format: 13849 ‘jpg’ ‘‘

Format Version: Width: Height: Bit Depth: 714 682 8

Color Depth: ‘grayscale’ Format Signature: Comment: {} ‘‘

Where file size is in bytes. The number of bytes in the original image is corrupted simply by multiplying width by height by bit depth and dividing the result by 8. The result is 486948.Dividing this file size gives the compression ratio:(486948/13849)=35.16.This compression ratio was achieved. While maintaining image quality consistent with the requirements of the appearance. In addition to the obvious advantages in storage space, this reduction allows the transmission of approximately 35 times the amount of un compressed data per unit time. The information fields displayed by imfinfo can be captured in to a so called structure variable that can be for subsequent computations. Using the receding an example and assigning the name K to the structure variable. We use the syntax >>K=imfinfo(‘bubbles25.jpg’);

To store in to variable K all the information generated by command imfinfo, the information generated by imfinfo is appended to the structure variable by means of fields, separated from K by a dot. For example, the image height and width are now stored in structure fields K. Height and K. width. As an illustration, consider the following use of structure variable K to commute the compression ratio for bubbles25.jpg: >> K=imfinfo(‘bubbles25.jpg’); >> image_ bytes =K.Width* K.Height* K.Bit Depth /8; >> Compressed_ bytes = K.FilesSize; >> Compression_ ratio=35.162 Note that iminfo was used in two different ways. The first was to type imfinfo bubbles25.jpg at the prompt, which resulted in the information being displayed on the screen. The second was to type K=imfinfo (‘bubbles25.jpg’),which resulted in the information generated by imfinfo being stored in K. These two different ways of calling imfinfo are an example of command_ function duality, an important concept that is explained in more detail in the MATLAB online documentation. More general imwrite syntax applicable only to tif images has the form Imwrite(g,’filename.tif’,’compression’,’parameter’,….’resloution’,[colres rowers] ) Where ‘parameter’ can have one of the following principal values: ‘none’ indicates no compression, ‘pack bits’ indicates pack bits compression (the default for non ‘binary images’) and ‘ccitt’ indicates ccitt compression. (the default for binary images).The 1*2 array [colres rowers] Contains two integers that give the column resolution and row resolution in dot per_ unit (the default values). For example, if the image dimensions are in inches, colres is in the number

of dots(pixels)per inch (dpi) in the vertical direction and similarly for rowers in the horizontal direction. Specifying the resolution by single scalar, res is equivalent to writing [res res]. >>imwrite(f,’sf.tif’,’compression’,’none’,’resolution’,……………..[300 300]) the values of the vector[colures rows] were determined by multiplying 200 dpi by the ratio 2.25/1.5, which gives 30 dpi. Rather than do the computation manually, we could write >> res=round(200*2.25/1.5); >>imwrite(f,’sf.tif’,’compression’,’none’,’resolution’,res) where its argument to the nearest integer. It function round rounds is important to note that the number of pixels was not changed by these commands. Only the scale of the image changed. The original 450*450 image at 200 dpi is of size 2.25*2.25 inches. The new 300_dpi image is identical, except that is 450*450 pixels are distributed over a 1.5*1.5_inch area. Processes such as this are useful for controlling the size of an image in a printed document with out sacrificing resolution. Often it is necessary to export images to disk the way they appear on the MATLAB desktop. This is especially true with plots .The contents of a figure window can be exported to disk in two ways. The first is to use the file pull-down menu is in the figure window and then choose export. With this option the user can select a location, filename, and format. More control over export parameters is obtained by using print command: Print-fno-dfileformat-rresno filename Where no refers to the figure number in the figure window interest, file format refers one of the file formats in table above. ‘resno’ is the resolution in dpi, and filename is the name we wish to assign the file. If we simply type print at the prompt, MATLAB prints (to the default printer) the contents of the last figure window displayed. It is possible also to specify other options with print, such as specific printing device.

DATA CLASSES: Although we work with integers coordinates the values of pixels themselves are not restricted to be integers in MATLAB. Table above list various data classes supported by MATLAB and IPT are representing pixels values. The first eight entries in the table are refers to as numeric data classes. The ninth entry is the char class and, as shown, the last entry is referred to as logical data class. All numeric computations in MATLAB are done in double quantities, so this is also a frequent data class encounter in image processing applications. Class unit 8 also is encountered frequently, especially when reading data from storages devices, as 8 bit images are most common representations found in practice. These two data classes, classes logical, and, to a lesser degree, class unit 16 constitute the primary data classes on which we focus. Many ipt functions however support all the data classes listed in table. Data class double requires 8 bytes to represent a number uint8 and int 8 require one byte each, uint16 and int16 requires 2bytes and unit 32.

Name Double Uinit8 Uinit16

Description Double _ precision, floating_ point numbers the Approximate. Unsigned 8_bit integers in the range [0,255] (1byte per Element). Unsigned 16_bit integers in the range [0, 65535] (2byte Per element).

Uinit 32

Unsigned 32_bit integers in the range [0, 4294967295] (4 bytes per element).

Int8

Signed 8_bit integers in the range [-128,127]

(1 byte per element) Int 16 Int 32 signed 16_byte integers in the range [32768, 32767] (2 bytes per element). Signed 32_byte integers in the range [-2147483648, 21474833647], (4 byte per element). Single single _precision floating _point numbers with values In the approximate range (4 bytes per elements). Char Logical characters (2 bytes per elements). values are 0 to 1 (1byte per element).

int 32 and single required 4 bytes each. The char data class holds characters in Unicode representation. A character string is merely a 1*n array of characters logical array contains only the values 0 to 1,with each element being stored in memory using function logical or by using relational operators.

IMAGE TYPES: The toolbox supports four types of images: 1 .Intensity images 2. Binary images 3. Indexed images 4. R G B images

Most monochrome image processing operations are carried out using binary or intensity images, so our initial focus is on these two image types. Indexed and RGB colour images. Intensity Images: An intensity image is a data matrix whose values have been scaled to represent intentions. When the elements of an intensity image are of class unit8, or class unit 16, they have integer values in the range [0,255] and [0, 65535], respectively. If the image is of class double, the values are floating _point numbers. Values of scaled, double intensity images are in the range [0, 1] by convention. Binary Images: Binary images have a very specific meaning in MATLAB.A binary image is a logical array 0s and1s.Thus, an array of 0s and 1s whose values are of data class, say unit8, is not considered as a binary image in MATLAB .A numeric array is converted to binary using function logical. Thus, if A is a numeric array consisting of 0s and 1s, we create an array B using the statement. B=logical (A) If A contains elements other than 0s and 1s.Use of the logical function converts all nonzero quantities to logical 1s and all entries with value 0 to logical 0s. Using relational and logical operators also creates logical arrays. To test if an array is logical we use the I logical function: islogical(c) If c is a logical array, this function returns a 1.Otherwise returns a 0. Logical array can be converted to numeric arrays using the data class conversion functions. Indexed Images:

An indexed image has two components: A data matrix integer, x. A color map matrix, map. Matrix map is an m*3 arrays of class double containing floating_ point values in the range [0, 1].The length m of the map are equal to the number of colors it defines. Each row of map specifies the red, green and blue components of a single color. An indexed images uses “direct mapping” of pixel intensity values color map values. The color of each pixel is determined by using the corresponding value the integer matrix x as a pointer in to map. If x is of class double ,then all of its components with values less than or equal to 1 point to the first row in map, all components with value 2 point to the second row and so on. If x is of class units or unit 16, then all components value 0 point to the first row in map, all components with value 1 point to the second and so on. RGB Image: An RGB color image is an M*N*3 array of color pixels where each color pixel is triplet corresponding to the red, green and blue components of an RGB image, at a specific spatial location. An RGB image may be viewed as “stack” of three gray scale images that when fed in to the red, green and blue inputs of a color monitor.. Produce a color image on the screen. Convention the three images forming an RGB color image are referred to as the red, green and blue components images. The data class of the components images determines their range of values. If an RGB image is of class double the range of values is [0, 1]. Similarly the range of values is [0,255] or [0, 65535].For RGB images of class units or unit 16 respectively. The number of bits use to represents the pixel values of the component images determines the bit depth of an RGB image. For example, if each component image is an 8bit image, the corresponding RGB image is said to be 24 bits deep.

Generally, the number of bits in all component images is the same. In this case the number of possible color in an RGB image is (2^b) ^3, where b is a number of bits in each component image. For the 8bit case the number is 16,777,216 colors

APPENDIX-B

What Is MATLAB? MATLAB ® is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in familiar mathematical notation. Typical uses include Typical uses of MATLAB Math and computation Algorithm development Data acquisition Modeling, simulation, and prototyping Data analysis, exploration, and visualization Scientific and engineering graphics

Application development, including graphical user interface building. The main features of MATLAB 1. Advance algorithm for high performance numerical computation ,especially in the Field matrix algebra 2. A large collection of predefined mathematical functions and the ability to define one’s own functions. 3. Two-and three dimensional graphics for plotting and displaying data 4. A complete online help system 5. Powerful , matrix or vector oriented high level programming language for individual applications. 6. Toolboxes available for solving advanced problems in several application areas

MATLAB

MATLAB Programming language User written / Built in functions Computation Linear algebra Signal processing Quadrature Etc Tool boxes Signal processing Image processing Control systems Neural Networks Communications Robust control Statistics External interface Interface with C and FORTRAN Programs

Graphics 2-D graphics 3-D graphics Color and lighting Animation

Features and capabilities of MATLAB

MATLAB is an interactive system whose basic data element is an array that does not require dimensioning. This allows you to solve many technical computing problems, especially

those with matrix and vector formulations, in a fraction of the time it would take to write a program in a scalar non interactive language such as C or FORTRAN. The name MATLAB stands for matrix laboratory. MATLAB was originally written to provide easy access to matrix software developed by the LINPACK and EISPACK projects. Today, MATLAB engines incorporate the LAPACK and BLAS libraries, embedding the state of the art in software for matrix computation. MATLAB has evolved over a period of years with input from many users. In university environments, it is the standard instructional tool for introductory and advanced courses in mathematics, engineering, and science. In industry, MATLAB is the tool of choice for highproductivity research, development, and analysis. MATLAB features a family of add-on application-specific solutions called toolboxes. Very important to most users of MATLAB, toolboxes allow you to learn and apply specialized technology. Toolboxes are comprehensive collections of MATLAB functions (M-files) that extend the MATLAB environment to solve particular classes of problems. Areas in which toolboxes are available include signal processing, control systems, neural networks, fuzzy logic, wavelets, simulation, and many others. The MATLAB System: The MATLAB system consists of five main parts: Development Environment: This is the set of tools and facilities that help you use MATLAB functions and files. Many of these tools are graphical user interfaces. It includes the MATLAB desktop and Command Window, a command history, an editor and debugger, and browsers for viewing help, the workspace, files, and the search path.

The MATLAB Mathematical Function: This is a vast collection of computational algorithms ranging from elementary functions like sum, sine, cosine, and complex arithmetic, to more sophisticated functions like matrix inverse, matrix eigen values, Bessel functions, and fast Fourier transforms. The MATLAB Language: This is a high-level matrix/array language with control flow statements, functions, data structures, input/output, and object-oriented programming features. It allows both "programming in the small" to rapidly create quick and dirty throw-away programs, and "programming in the large" to create complete large and complex application programs. Graphics: MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and printing these graphs. It includes high-level functions for two-dimensional and three-dimensional data visualization, image processing, animation, and presentation graphics. It also includes low-level functions that allow you to fully customize the appearance of graphics as well as to build complete graphical user interfaces on your MATLAB applications. The MATLAB Application Program Interface (API): This is a library that allows you to write C and Fortran programs that interact with MATLAB. It includes facilities for calling routines from MATLAB (dynamic linking), calling MATLAB as a computational engine, and for reading and writing MAT-files.

MATLAB WORKING ENVIRONMENT: MATLAB DESKTOP:Matlab Desktop is the main Matlab application window. The desktop contains five sub windows, the command window, the workspace browser, the current directory window, the command history window, and one or more figure windows, which are shown only when the user displays a graphic.

The command window is where the user types MATLAB commands and expressions at the prompt (>>) and where the output of those commands is displayed. MATLAB defines the workspace as the set of variables that the user creates in a work session. The workspace browser shows these variables and some information about them. Double clicking on a variable in the workspace browser launches the Array Editor, which can be used to obtain information and income instances edit certain properties of the variable. The current Directory tab above the workspace tab shows the contents of the current directory, whose path is shown in the current directory window. For example, in the windows operating system the path might be as follows: C:\MATLAB\Work, indicating that directory “work” is a subdirectory of the main directory “MATLAB”; WHICH IS INSTALLED IN DRIVE C. clicking on the arrow in the current directory window shows a list of recently used paths. Clicking on the button to the right of the window allows the user to change the current directory. MATLAB uses a search path to find M-files and other MATLAB related files, which are organize in directories in the computer file system. Any file run in MATLAB must reside in the current directory or in a directory that is on search path. By default, the files supplied with MATLAB and math works toolboxes are included in the search path. The easiest way to see which directories are on the search path. The easiest way to see which directories are soon the search paths, or to add or modify a search path, is to select set path from the File menu the desktop, and then use the set path dialog box. It is good practice to add any commonly used directories to the search path to avoid repeatedly having the change the current directory. The Command History Window contains a record of the commands a user has entered in the command window, including both current and previous MATLAB sessions. Previously entered MATLAB commands can be selected and re-executed from the command history window by right clicking on a command or sequence of commands. This action launches a menu from which to select various options in addition to executing the commands. This is useful to select various options in addition to executing the commands. This is a useful feature when experimenting with various commands in a work session.

Implementations 1. Arithmetic operations Entering Matrices The best way for you to get started with MATLAB is to learn how to handle matrices. Start MATLAB and follow along with each example. You can enter matrices into MATLAB in several different ways: • Enter an explicit list of elements. • Load matrices from external data files. • Generate matrices using built-in functions. • Create matrices with your own functions in M-files. Start by entering Dürer’s matrix as a list of its elements. You only have to follow a few basic conventions: • Separate the elements of a row with blanks or commas. • Use a semicolon, to indicate the end of each row. • Surround the entire list of elements with square brackets, [ ]. To enter matrix, simply type in the Command Window A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1] MATLAB displays the matrix you just entered: A= 16 3 2 13 5 10 11 8 9 6 7 12

4 15 14 1 This matrix matches the numbers in the engraving. Once you have entered the matrix, it is automatically remembered in the MATLAB workspace. You can refer to it simply as A. Now that you have A in the workspace,

sum, transpose, and diag You are probably already aware that the special properties of a magic square have to do with the various ways of summing its elements. If you take the sum along any row or column, or along either of the two main diagonals, you will always get the same number. Let us verify that using MATLAB. The first statement to try is sum(A) MATLAB replies with ans = 34 34 34 34

When you do not specify an output variable, MATLAB uses the variable ans, short for answer, to store the results of a calculation. You have computed a row vector containing the sums of the columns of A. Sure enough, each of the columns has the same sum, the magic sum, 34. How about the row sums? MATLAB has a preference for working with the columns of a matrix, so one way to get the row sums is to transpose the matrix, compute the column sums of the transpose, and then transpose the result. For an additional way that avoids the double transpose use the dimension argument for the sum function. MATLAB has two transpose operators. The apostrophe operator (e.g., A') performs a complex conjugate transposition. It flips a matrix about its main diagonal, and also changes the sign of the imaginary component of any complex elements of the matrix. The apostrophe-dot operator (e.g., A'.), transposes without affecting the sign of complex elements. For matrices containing all real elements, the two operators return the same result. So A' produces ans = 16 5 9 4 3 10 6 15 2 11 7 14 13 8 12 1 and sum(A')' produces a column vector containing the row sums ans = 34

34 34 34 The sum of the elements on the main diagonal is obtained with the sum and the diag functions: diag(A) produces ans = 16 10 7 1 and sum(diag(A)) produces ans = 34 The other diagonal, the so-called anti diagonal, is not so important Mathematically, so MATLAB does not have a ready-made function for it. But a function originally intended for use in graphics, fliplr, flips a matrix From left to right: Sum (diag(fliplr(A)))

ans = 34 You have verified that the matrix in Dürer’s engraving is indeed a magic Square and, in the process, have sampled a few MATLAB matrix operations. Operators Expressions use familiar arithmetic operators and precedence rules. + Addition - Subtraction * Multiplication / Division \ Left division (described in “Matrices and Linear Algebra” in the MATLAB documentation) . ^ Power ‘Complex conjugate transpose ( ) Specify evaluation order Generating Matrices MATLAB provides four functions that generate basic matrices. zeros All zeros ones All ones rand Uniformly distributed random elements randn Normally distributed random elements

Here are some examples: Z = zeros (2, 4) Z= 0000 000 F = 5*ones (3, 3) F= 555 555 555 N = fix (10*rand (1, 10)) N= 9264874084 R = randn(4,4) R= 0.6353 0.0860 -0.3210 -1.2316 -0.6014 -2.0046 1.2366 1.0556 0.5512 -0.4931 -0.6313 -0.1132 -1.0998 0.4620 -2.3252 0.3792

Using the MATLAB Editor to create M-Files:

The MATLAB editor is both a text editor specialized for creating M-files and a graphical MATLAB debugger. The editor can appear in a window by itself, or it can be a sub window in the desktop. M-files are denoted by the extension .m, as in pixelup.m. The MATLAB editor window has numerous pull-down menus for tasks such as saving, viewing, and debugging files. Because it performs some simple checks and also uses color to differentiate between various elements of code, this text editor is recommended as the tool of choice for writing and editing M-functions. To open the editor, type edit at the prompt opens the M-file filename.m in an editor window, ready for editing. As noted earlier, the file must be in the current directory, or in a directory in the search path. GETTING HELP: The principal way to get help online is to use the MATLAB help browser, opened as a separate window either by clicking on the question mark symbol (?) on the desktop toolbar, or by typing help browser at the prompt in the command window. The help Browser is a web browser integrated into the MATLAB desktop that displays a HyperText Markup Language (HTML) documents. The Help Browser consists of two panes, the help navigator pane, used to find information, and the display pane, used to view the information. Self-explanatory tabs other than navigator pane are used to perform a search.

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close