Learning DIP – Discussion work project make money

Discuss DIP Digital image processing deals with manipulation of digital images through a digital computer. It is a subfield of signals and systems but focus particularly on images. DIP focuses on developing a computer system that is able to perform processing on an image. The input of that system is a digital image and the system process that image using efficient algorithms, and gives an image as an output. The most common example is Adobe Photoshop. It is one of the widely used application for processing digital images. Learning working make money

Learning DIP – Concept of Edge Detection work project make money

Concept of Edge Detection We have discussed briefly about edge detection in our tutorial of introduction to masks. We will formally discuss edge detection here. What are edges We can also say that sudden changes of discontinuities in an image are called as edges. Significant transitions in an image are called as edges. Types of edges Generally edges are of three types: Horizontal edges Vertical Edges Diagonal Edges Why detect edges Most of the shape information of an image is enclosed in edges. So first we detect these edges in an image and by using these filters and then by enhancing those areas of image which contains edges, sharpness of the image will increase and image will become clearer. Here are some of the masks for edge detection that we will discuss in the upcoming tutorials. Prewitt Operator Sobel Operator Robinson Compass Masks Krisch Compass Masks Laplacian Operator. Above mentioned all the filters are Linear filters or smoothing filters. Prewitt Operator Prewitt operator is used for detecting edges horizontally and vertically. Sobel Operator The sobel operator is very similar to Prewitt operator. It is also a derivate mask and is used for edge detection. It also calculates edges in both horizontal and vertical direction. Robinson Compass Masks This operator is also known as direction mask. In this operator we take one mask and rotate it in all the 8 compass major directions to calculate edges of each direction. Kirsch Compass Masks Kirsch Compass Mask is also a derivative mask which is used for finding edges. Kirsch mask is also used for calculating edges in all the directions. Laplacian Operator Laplacian Operator is also a derivative operator which is used to find edges in an image. Laplacian is a second order derivative mask. It can be further divided into positive laplacian and negative laplacian. All these masks find edges. Some find horizontally and vertically, some find in one direction only and some find in all the directions. The next concept that comes after this is sharpening which can be done once the edges are extracted from the image Sharpening Sharpening is opposite to the blurring. In blurring, we reduce the edge content and in Sharpening, we increase the edge content. So in order to increase the edge content in an image, we have to find edges first. Edges can be find by one of the any method described above by using any operator. After finding edges, we will add those edges on an image and thus the image would have more edges, and it would look sharpen. This is one way of sharpening an image. The sharpen image is shown below. Original Image Sharpen Image Learning working make money

Learning DIP – Sobel operator work project make money

Sobel Operator The sobel operator is very similar to Prewitt operator. It is also a derivate mask and is used for edge detection. Like Prewitt operator sobel operator is also used to detect two kinds of edges in an image: Vertical direction Horizontal direction Difference with Prewitt Operator The major difference is that in sobel operator the coefficients of masks are not fixed and they can be adjusted according to our requirement unless they do not violate any property of derivative masks. Following is the vertical Mask of Sobel Operator: -1 0 1 -2 0 2 -1 0 1 This mask works exactly same as the Prewitt operator vertical mask. There is only one difference that is it has “2” and “-2” values in center of first and third column. When applied on an image this mask will highlight the vertical edges. How it works When we apply this mask on the image it prominent vertical edges. It simply works like as first order derivate and calculates the difference of pixel intensities in a edge region. As the center column is of zero so it does not include the original values of an image but rather it calculates the difference of right and left pixel values around that edge. Also the center values of both the first and third column is 2 and -2 respectively. This give more weight age to the pixel values around the edge region. This increase the edge intensity and it become enhanced comparatively to the original image. Following is the horizontal Mask of Sobel Operator -1 -2 -1 0 0 0 1 2 1 Above mask will find edges in horizontal direction and it is because that zeros column is in horizontal direction. When you will convolve this mask onto an image it would prominent horizontal edges in the image. The only difference between it is that it have 2 and -2 as a center element of first and third row. How it works This mask will prominent the horizontal edges in an image. It also works on the principle of above mask and calculates difference among the pixel intensities of a particular edge. As the center row of mask is consist of zeros so it does not include the original values of edge in the image but rather it calculate the difference of above and below pixel intensities of the particular edge. Thus increasing the sudden change of intensities and making the edge more visible. Now it’s time to see these masks in action: Sample Image Following is a sample picture on which we will apply above two masks one at time. After applying Vertical Mask After applying vertical mask on the above sample image, following image will be obtained. After applying Horizontal Mask After applying horizontal mask on the above sample image, following image will be obtained Comparison As you can see that in the first picture on which we apply vertical mask, all the vertical edges are more visible than the original image. Similarly in the second picture we have applied the horizontal mask and in result all the horizontal edges are visible. So in this way you can see that we can detect both horizontal and vertical edges from an image. Also if you compare the result of sobel operator with Prewitt operator, you will find that sobel operator finds more edges or make edges more visible as compared to Prewitt Operator. This is because in sobel operator we have allotted more weight to the pixel intensities around the edges. Applying more weight to mask Now we can also see that if we apply more weight to the mask, the more edges it will get for us. Also as mentioned in the start of the tutorial that there is no fixed coefficients in sobel operator, so here is another weighted operator -1 0 1 -5 0 5 -1 0 1 If you can compare the result of this mask with of the Prewitt vertical mask, it is clear that this mask will give out more edges as compared to Prewitt one just because we have allotted more weight in the mask. Learning working make money

Learning DIP – Krisch Compass Mask work project make money

Krisch Compass Mask Kirsch Compass Mask is also a derivative mask which is used for finding edges. This is also like Robinson compass find edges in all the eight directions of a compass. The only difference between Robinson and kirsch compass masks is that in Kirsch we have a standard mask but in Kirsch we change the mask according to our own requirements. With the help of Kirsch Compass Masks we can find edges in the following eight directions. North North West West South West South South East East North East We take a standard mask which follows all the properties of a derivative mask and then rotate it to find the edges. For example let’s see the following mask which is in North Direction and then rotate it to make all the direction masks. North Direction Mask -3 -3 5 -3 0 5 -3 -3 5 North West Direction Mask -3 5 5 -3 0 5 -3 -3 -3 West Direction Mask 5 5 5 -3 0 -3 -3 -3 -3 South West Direction Mask 5 5 -3 5 0 -3 -3 -3 -3 South Direction Mask 5 -3 -3 5 0 -3 5 -3 -3 South East Direction Mask -3 -3 -3 5 0 -3 5 5 -3 East Direction Mask -3 -3 -3 -3 0 -3 5 5 5 North East Direction Mask -3 -3 -3 -3 0 5 -3 5 5 As you can see that all the directions are covered and each mask will give you the edges of its own direction. Now to help you better understand the concept of these masks we will apply it on a real image. Suppose we have a sample picture from which we have to find all the edges. Here is our sample picture: Sample Picture Now we will apply all the above filters on this image and we get the following result. North Direction Edges North West Direction Edges West Direction Edges South West Direction Edges South Direction Edges South East Direction Edges East Direction Edges North East Direction Edges As you can see that by applying all the above masks you will get edges in all the direction. Result is also depends on the image. Suppose there is an image, which do not have any North East direction edges so then that mask will be ineffective. Learning working make money

Learning DIP – Concept of Quantization work project make money

Concept of Quantization We have introduced quantization in our tutorial of signals and system. We are formally going to relate it with digital images in this tutorial. Lets discuss first a little bit about quantization. Digitizing a signal As we have seen in the previous tutorials, that digitizing an analog signal into a digital, requires two basic steps. Sampling and quantization. Sampling is done on x axis. It is the conversion of x axis (infinite values) to digital values. The below figure shows sampling of a signal. Sampling with relation to digital images The concept of sampling is directly related to zooming. The more samples you take, the more pixels, you get. Oversampling can also be called as zooming. This has been discussed under sampling and zooming tutorial. But the story of digitizing a signal does not end at sampling too, there is another step involved which is known as Quantization. What is quantization Quantization is opposite to sampling. It is done on y axis. When you are quantizing an image, you are actually dividing a signal into quanta(partitions). On the x axis of the signal, are the co-ordinate values, and on the y axis, we have amplitudes. So digitizing the amplitudes is known as Quantization. Here how it is done You can see in this image, that the signal has been quantified into three different levels. That means that when we sample an image, we actually gather a lot of values, and in quantization, we set levels to these values. This can be more clear in the image below. In the figure shown in sampling, although the samples has been taken, but they were still spanning vertically to a continuous range of gray level values. In the figure shown above, these vertically ranging values have been quantized into 5 different levels or partitions. Ranging from 0 black to 4 white. This level could vary according to the type of image you want. The relation of quantization with gray levels has been further discussed below. Relation of Quantization with gray level resolution: The quantized figure shown above has 5 different levels of gray. It means that the image formed from this signal, would only have 5 different colors. It would be a black and white image more or less with some colors of gray. Now if you were to make the quality of the image more better, there is one thing you can do here. Which is, to increase the levels, or gray level resolution up. If you increase this level to 256, it means you have an gray scale image. Which is far better then simple black and white image. Now 256, or 5 or what ever level you choose is called gray level. Remember the formula that we discussed in the previous tutorial of gray level resolution which is, We have discussed that gray level can be defined in two ways. Which were these two. Gray level = number of bits per pixel (BPP).(k in the equation) Gray level = number of levels per pixel. In this case we have gray level is equal to 256. If we have to calculate the number of bits, we would simply put the values in the equation. In case of 256levels, we have 256 different shades of gray and 8 bits per pixel, hence the image would be a gray scale image. Reducing the gray level Now we will reduce the gray levels of the image to see the effect on the image. For example Lets say you have an image of 8bpp, that has 256 different levels. It is a grayscale image and the image looks something like this. 256 Gray Levels Now we will start reducing the gray levels. We will first reduce the gray levels from 256 to 128. 128 Gray Levels There is not much effect on an image after decrease the gray levels to its half. Lets decrease some more. 64 Gray Levels Still not much effect, then lets reduce the levels more. 32 Gray Levels Surprised to see, that there is still some little effect. May be its due to reason, that it is the picture of Einstein, but lets reduce the levels more. 16 Gray Levels Boom here, we go, the image finally reveals, that it is effected by the levels. 8 Gray Levels 4 Gray Levels Now before reducing it, further two 2 levels, you can easily see that the image has been distorted badly by reducing the gray levels. Now we will reduce it to 2 levels, which is nothing but a simple black and white level. It means the image would be simple black and white image. 2 Gray Levels Thats the last level we can achieve, because if reduce it further, it would be simply a black image, which can not be interpreted. Contouring There is an interesting observation here, that as we reduce the number of gray levels, there is a special type of effect start appearing in the image, which can be seen clear in 16 gray level picture. This effect is known as Contouring. Iso preference curves The answer to this effect, that why it appears, lies in Iso preference curves. They are discussed in our next tutorial of Contouring and Iso preference curves. Learning working make money

Learning DIP – Histograms Introduction work project make money

Histograms Introduction Before discussing the use of Histograms in image processing, we will first look at what histogram is, how it is used and then an example of histograms to have more understanding of histogram. Histograms A histogram is a graph. A graph that shows frequency of anything. Usually histogram have bars that represent frequency of occurring of data in the whole data set. A Histogram has two axis the x axis and the y axis. The x axis contains event whose frequency you have to count. The y axis contains frequency. The different heights of bar shows different frequency of occurrence of data. Usually a histogram looks like this. Now we will see an example of this histogram is build Example Consider a class of programming students and you are teaching python to them. At the end of the semester, you got this result that is shown in table. But it is very messy and does not show your overall result of class. So you have to make a histogram of your result, showing the overall frequency of occurrence of grades in your class. Here how you are going to do it. Result sheet Name Grade John A Jack D Carter B Tommy A Lisa C+ Derek A- Tom B+ Histogram of result sheet Now what you are going to do is, that you have to find what comes on the x and the y axis. There is one thing to be sure, that y axis contains the frequency, so what comes on the x axis. X axis contains the event whose frequency has to be calculated. In this case x axis contains grades. Now we will how do we use a histogram in an image. Histogram of an image Histogram of an image, like other histograms also shows frequency. But an image histogram, shows frequency of pixels intensity values. In an image histogram, the x axis shows the gray level intensities and the y axis shows the frequency of these intensities. For example The histogram of the above picture of the Einstein would be something like this The x axis of the histogram shows the range of pixel values. Since its an 8 bpp image, that means it has 256 levels of gray or shades of gray in it. Thats why the range of x axis starts from 0 and end at 255 with a gap of 50. Whereas on the y axis, is the count of these intensities. As you can see from the graph, that most of the bars that have high frequency lies in the first half portion which is the darker portion. That means that the image we have got is darker. And this can be proved from the image too. Applications of Histograms Histograms has many uses in image processing. The first use as it has also been discussed above is the analysis of the image. We can predict about an image by just looking at its histogram. Its like looking an x ray of a bone of a body. The second use of histogram is for brightness purposes. The histograms has wide application in image brightness. Not only in brightness, but histograms are also used in adjusting contrast of an image. Another important use of histogram is to equalize an image. And last but not the least, histogram has wide use in thresholding. This is mostly used in computer vision. Learning working make money

Learning DIP – High Pass vs Low Pass Filters work project make money

High Pass vs Low Pass Filters In the last tutorial, we briefly discuss about filters. In this tutorial we will thoroughly discuss about them. Before discussing about let’s talk about masks first. The concept of mask has been discussed in our tutorial of convolution and masks. Blurring masks vs derivative masks We are going to perform a comparison between blurring masks and derivative masks. Blurring masks A blurring mask has the following properties. All the values in blurring masks are positive The sum of all the values is equal to 1 The edge content is reduced by using a blurring mask As the size of the mask grow, more smoothing effect will take place Derivative masks A derivative mask has the following properties. A derivative mask have positive and as well as negative values The sum of all the values in a derivative mask is equal to zero The edge content is increased by a derivative mask As the size of the mask grows , more edge content is increased Relationship between blurring mask and derivative mask with high pass filters and low pass filters. The relationship between blurring mask and derivative mask with a high pass filter and low pass filter can be defined simply as. Blurring masks are also called as low pass filter Derivative masks are also called as high pass filter High pass frequency components and Low pass frequency components The high pass frequency components denotes edges whereas the low pass frequency components denotes smooth regions. Ideal low pass and Ideal High pass filters This is the common example of low pass filter. When one is placed inside and the zero is placed outside , we got a blurred image. Now as we increase the size of 1, blurring would be increased and the edge content would be reduced. This is a common example of high pass filter. When 0 is placed inside, we get edges, which gives us a sketched image. An ideal low pass filter in frequency domain is given below. The ideal low pass filter can be graphically represented as Now let’s apply this filter to an actual image and let’s see what we got. Sample image Image in frequency domain Applying filter over this image Resultant Image With the same way, an ideal high pass filter can be applied on an image. But obviously the results would be different as, the low pass reduces the edged content and the high pass increase it. Gaussian Low pass and Gaussian High pass filter Gaussian low pass and Gaussian high pass filter minimize the problem that occur in ideal low pass and high pass filter. This problem is known as ringing effect. This is due to reason because at some points transition between one color to the other cannot be defined precisely, due to which the ringing effect appears at that point. Have a look at this graph. This is the representation of ideal low pass filter. Now at the exact point of Do, you cannot tell that the value would be 0 or 1. Due to which the ringing effect appears at that point. So in order to reduce the effect that appears is ideal low pass and ideal high pass filter, the following Gaussian low pass filter and Gaussian high pass filter is introduced. Gaussian Low pass filter The concept of filtering and low pass remains the same, but only the transition becomes different and become more smooth. The Gaussian low pass filter can be represented as Note the smooth curve transition, due to which at each point, the value of Do, can be exactly defined. Gaussian high pass filter Gaussian high pass filter has the same concept as ideal high pass filter, but again the transition is more smooth as compared to the ideal one. Learning working make money

Learning DIP – ISO Preference curves work project make money

ISO preference curves What is contouring? As we decrease the number of gray levels in an image, some false colors, or edges start appearing on an image. This has been shown in our last tutorial of Quantization. Lets have a look at it. Consider we, have an image of 8bpp (a grayscale image) with 256 different shades of gray or gray levels. This above picture has 256 different shades of gray. Now when we reduce it to 128 and further reduce it 64, the image is more or less the same. But when re reduce it further to 32 different levels, we got a picture like this If you will look closely, you will find that the effects start appearing on the image.These effects are more visible when we reduce it further to 16 levels and we got an image like this. These lines, that start appearing on this image are known as contouring that are very much visible in the above image. Increase and decrease in contouring The effect of contouring increase as we reduce the number of gray levels and the effect decrease as we increase the number of gray levels. They are both vice versa VS That means more quantization, will effect in more contouring and vice versa. But is this always the case. The answer is No. That depends on something else that is discussed below. Isopreference curves A study conducted on this effect of gray level and contouring, and the results were shown in the graph in the form of curves, known as Iso preference curves. The phenomena of Isopreference curves shows, that the effect of contouring not only depends on the decreasing of gray level resolution but also on the image detail. The essence of the study is: If an image has more detail, the effect of contouring would start appear on this image later, as compare to an image which has less detail, when the gray levels are quantized. According to the original research, the researchers took these three images and they vary the Gray level resolution, in all three images. The images were Level of detail The first image has only a face in it, and hence very less detail. The second image has some other objects in the image too, such as camera man, his camera, camera stand, and background objects e.t.c. Whereas the third image has more details then all the other images. Experiment The gray level resolution was varied in all the images, and the audience was asked to rate these three images subjectively. After the rating, a graph was drawn according to the results. Result The result was drawn on the graph. Each curve on the graph represents one image. The values on the x axis represents the number of gray levels and the values on the y axis represents bits per pixel (k). The graph has been shown below. According to this graph, we can see that the first image which was of face, was subject to contouring early then all of the other two images. The second image, that was of the cameraman was subject to contouring a bit after the first image when its gray levels are reduced. This is because it has more details then the first image. And the third image was subject to contouring a lot after the first two images i-e: after 4 bpp. This is because, this image has more details. Conclusion So for more detailed images, the isopreference curves become more and more vertical. It also means that for an image with a large amount of details, very few gray levels are needed. Learning working make money

Learning DIP – History of Photography work project make money

History of Photography Origin of camera The history of camera and photography is not exactly the same. The concepts of camera were introduced a lot before the concept of photography Camera Obscura The history of the camera lies in ASIA. The principles of the camera were first introduced by a Chinese philosopher MOZI. It is known as camera obscura. The cameras evolved from this principle. The word camera obscura is evolved from two different words. Camera and Obscura. The meaning of the word camera is a room or some kind of vault and Obscura stands for dark. The concept which was introduced by the Chinese philosopher consist of a device, that project an image of its surrounding on the wall. However it was not built by the Chinese. The creation of camera obscura The concept of Chinese was bring in reality by a Muslim scientist Abu Ali Al-Hassan Ibn al-Haitham commonly known as Ibn al-Haitham. He built the first camera obscura. His camera follows the principles of pinhole camera. He build this device in somewhere around 1000. Portable camera In 1685, a first portable camera was built by Johann Zahn. Before the advent of this device , the camera consist of a size of room and were not portable. Although a device was made by an Irish scientist Robert Boyle and Robert Hooke that was a transportable camera, but still that device was very huge to carry it from one place to the other. Origin of photography Although the camera obscura was built in 1000 by a Muslim scientist. But its first actual use was described in the 13th century by an English philosopher Roger Bacon. Roger suggested the use of camera for the observation of solar eclipses. Da Vinci Although much improvement has been made before the 15th century , but the improvements and the findings done by Leonardo di ser Piero da Vinci was remarkable. Da Vinci was a great artist , musician , anatomist , and a war enginner. He is credited for many inventions. His one of the most famous painting includes, the painting of Mona Lisa. Da vinci not only built a camera obscura following the principle of a pin hole camera but also uses it as drawing aid for his art work. In his work , which was described in Codex Atlanticus , many principles of camera obscura has been defined. His camera follows the principle of a pin hole camera which can be described as When images of illuminated objects penetrate through a small hole into a very dark room you will see [on the opposite wall] these objects in their proper form and color, reduced in size in a reversed position, owing to the intersection of rays. First photograph The first photograph was taken in 1814 by a French inventor Joseph Nicephore Niepce. He captures the first photograph of a view from the window at Le Gras, by coating the pewter plate with bitumen and after that exposing that plate to light. First underwater photograph The first underwater photograph was taken by an English mathematician William Thomson using a water tight box. This was done in 1856. The origin of film The origin of film was introduced by an American inventor and a philanthropist known as George Eastman who is considered as the pioneer of photography. He founded the company called as Eastman Kodak , which is famous for developing films. The company starts manufacturing paper film in 1885. He first created the camera Kodak and then later Brownie. Brownie was a box camera and gain its popularity due to its feature of Snapshot. After the advent of the film , the camera industry once again got a boom and one invention lead to another. Leica and Argus Leica and argus are the two analog cameras developed in 1925 and in 1939 respectively. The camera Leica was built using a 35mm cine film. Argus was another camera analog camera that uses the 35mm format and was rather inexpensive as compared by Leica and became very popular. Analog CCTV cameras In 1942 a German engineer Walter Bruch developed and installed the very first system of the analog CCTV cameras. He is also credited for the invention of color television in the 1960. Photo Pac The first disposable camera was introduced in 1949 by Photo Pac. The camera was only a one time use camera with a roll of film already included in it. The later versions of Photo pac were water proof and even have the flash. Digital Cameras Mavica by Sony Mavica (the magnetic video camera) was launched by Sony in 1981 was the first game changer in digital camera world. The images were recorded on floppy disks and images can be viewed later on any monitor screen. It was not a pure digital camera , but an analog camera. But got its popularity due to its storing capacity of images on a floppy disks. It means that you can now store images for a long lasting period , and you can save a huge number of pictures on the floppy which are replaced by the new blank disc , when they got full. Mavica has the capacity of storing 25 images on a disk. One more important thing that mavica introduced was its 0.3 mega pixel capacity of capturing photos. Digital Cameras Fuji DS-1P camera by Fuji films 1988 was the first true digital camera Nikon D1 was a 2.74 mega pixel camera and the first commercial digital SLR camera developed by Nikon , and was very much affordable by the professionals. Today digital cameras are included in the mobile phones with very high resolution and quality. Learning working make money

Learning DIP – Image Transformations work project make money

Image Transformations Before we discuss, what is image transformation, we will discuss what a transformation is. Transformation Transformation is a function. A function that maps one set to another set after performing some operations. Digital Image Processing system We have already seen in the introductory tutorials that in digital image processing, we will develop a system that whose input would be an image and output would be an image too. And the system would perform some processing on the input image and gives its output as an processed image. It is shown below. Now function applied inside this digital system that process an image and convert it into output can be called as transformation function. As it shows transformation or relation, that how an image1 is converted to image2. Image transformation. Consider this equation G(x,y) = T{ f(x,y) } In this equation, F(x,y) = input image on which transformation function has to be applied. G(x,y) = the output image or processed image. T is the transformation function. This relation between input image and the processed output image can also be represented as. s = T (r) where r is actually the pixel value or gray level intensity of f(x,y) at any point. And s is the pixel value or gray level intensity of g(x,y) at any point. The basic gray level transformation has been discussed in our tutorial of basic gray level transformations. Now we are going to discuss some of the very basic transformation functions. Examples Consider this transformation function. Lets take the point r to be 256, and the point p to be 127. Consider this image to be a one bpp image. That means we have only two levels of intensities that are 0 and 1. So in this case the transformation shown by the graph can be explained as. All the pixel intensity values that are below 127 (point p) are 0, means black. And all the pixel intensity values that are greater then 127, are 1, that means white. But at the exact point of 127, there is a sudden change in transmission, so we cannot tell that at that exact point, the value would be 0 or 1. Mathematically this transformation function can be denoted as: Consider another transformation like this Now if you will look at this particular graph, you will see a straight transition line between input image and output image. It shows that for each pixel or intensity value of input image, there is a same intensity value of output image. That means the output image is exact replica of the input image. It can be mathematically represented as: g(x,y) = f(x,y) the input and output image would be in this case are shown below. Learning working make money