 So, today we are going to discuss handling of digital images and related file formats very specifically concerned with the course projects which is about using of digital fingerprints. We have discussed some issues in image processing earlier, but today we shall specifically look at image representation in some standard file formats. I briefly mentioned the tools and utilities which are available and we specifically discuss a file format called XPM file format or X pixel map as it was then called. We will then thoroughly discuss a sample program which I have written to demonstrate how grayscale images can be conveniently represented in a .XPM file, how such files can be created and finally how one can interface with the hardware device that we had demonstrated some time earlier in the class for digital fingerprinting. As you know that device contains a lot of embedded software which captures the digital image which captures two different types of templates, can compile templates and give a match score and so on. But essentially to the external world what is provided is an application programmers interface which can transfer the captured image to some computer's memory which you have allocated in your functional program. From then on it is our job to get that image, store it in a file or analyze it for whatever purpose we want. Unfortunately the application programmer interfaces which they gave were very rudimentary. What they had given was a sample application which we saw the other day, but the sample application was supplied only in binary form. So that means you cannot do anything with that particular application just run it. So in order to access the image which is captured by that device a whole lot of painful hacking had to be done by using some very low level interfaces which they had provided. I actually succeeded after days and nights of work yesterday morning at around 9 o'clock. Since then I have been capturing images because that module in fact three of such units will be kept in the lab for your project work. So let us go on with the further discussion on general representation problem and how we handle it in files. We will specifically also look at a few new features which we have not seen earlier. These are actually features of file processing and features of character manipulation as done in the classical C style not C++ style. So here we go, this is something we have already seen a digital image is a collection of pixel values these are typically arranged in an array width by height. So whatever is the width multiplied by height is the total size of the image. Does it mean that we have so many bytes not necessarily we have so many pixels but each pixel can be represented in the simplest case just by one bit which means it's a black or white image. In fact most of the fingerprint images that you will get will have to be reduced to zero one images in order to do any meaningful processing. The one bit kind of representation is called a monocolor representation typically represented by M. So this is black and white. So black is zero, white is one. You can have eight bit gray scale which means that the pixels are actually represented by a tone value varying between zero to 255. These are the gray scales, black is zero and 255 is white. You can see that for representing our fingerprints this is probably the best representation because each pixel or picture element can be represented by one byte value or single byte if it stores unsigned integer then it can have a value between zero to 255 which is all possible gray levels here. The real life images which are color images are stored in 24 bits per pixel. So actually each pixel is represented as a combination of red, blue and green value. In fact if you see a picture point, this is a very enlarged picture point it's actually a small dot on any television or computer monitor or for that matter on a printer photographic paper every point is actually a picture point and it has components of red, components of blue, I don't have blue, imagine this is blue for a moment. So as a matter of fact on a computer monitor every point physically on the hardware actually is lit by three different colors red, blue and green and each one can vary in intensity that is how you get variety of colors seen at every point in fact the point can actually represent a very large number of colors depending upon the combination of values for red, green and blue. As you can see if I have to vary the level of any one color between zero to 255 as I have added between black and white for example I will have zero to 255 values here, zero to 255 values here and zero to 255 values here. The combination is 256 into 256 into 256 and that is what gives you almost 16 million possible colors that every point can have or can represent, can reflect. Usually low photograph will have all possible colors I mean obviously every point in a picture has to have a different color then there has to be as many points in the picture as many possible pixel values are there you generally have a much smaller picture and therefore these multiple millions of colors that you can have are not really required. As a matter of fact in a typical photograph you usually will never have more than 2000 to 4000 different colors for different points in fact many points in the picture will have very similar color and as a matter of fact with most representations up to 256 different colors are more than adequate to represent the full color image by having different combinations of these. In fact although each pixel can be represented by red, blue and green a combination where exactly the same proportion of red, same proportion of green and same proportion of blue exists that corresponds to actually black and white shares. A pure white for example is when red has to 55 value, green has to 55 value and blue has to 55. A pure black for example will have 0 red, 0 green and 0 blue. Consequently if you can store the representation of a pixel intensity by 3 bytes 1 byte representing a value of red between 0 to 255, another byte representing a similar value for green and a third one representing for blue you have all possible shades of color. More specifically if you choose 256 combinations of these three red, blue, green colors which actually have exactly the same value for red, blue and green 0, 0, 0, 1, 1, 1, 2, 2, 2, right up to 255, 255, 255 then what you get is a gray scale from black so resulting back to the slides as I said one can have 16 million colors but usually they are limited to 200 to 2000 colors. So what is done is a color pilot is used to map a pixel value to a specific color. So for example you might have let us say 100,000 pixel points in a picture. Now they have to be represented by only maybe 200 color combinations because that's all you need. Now what you need to do therefore is every pixel value whatever combination of red, green and blue may exist for that pixel has to be mapped onto one of these colors. These 200 colors which are chosen to replay in the image are called a color pilot. So a color pilot is used to map a pixel value to a specific color. Multiple pixel values may map to the same color that may happen once in a while. Now since you have millions of points and each point is represented by three bytes, you have a huge plethora of information and you need some kind of compression. Compression can be of two form, lossy compression and lossless compression. A lossy compression is where some information about image is lost. A lossless compression is no information is lost. Still picture can be substantially compressed. Just to see the importance of compression if you have any modern 12 megapixel camera and assume that it takes a photograph corresponding to 12 million pixels in that photograph since each pixel can be reprinted by three bytes. A single picture will occupy 36 megabytes. You will notice that no camera will actually have a 36 megabyte pixel picture normally. What happens is it is converted into a particular compressed format called JPEG which is actually a slightly lossy format but is more than adequate for human eye. So that is why you get JPEG pictures which are much smaller in size. So when you want to store information about image in a file, what is the information that you require? You require to know the width and height of the image. You require the type of colors present and values for each pixel in terms of these colors, not necessarily in terms of original colors. Several fight formats have come about in the last few years. These are the various names, Rob, PNG, BMP, TIFF, JIF, JPEG, XMP. JPEG for example is a lossy format where you might lose some information. In case you have grayscale images and in case the images are small, which is what fingerprints would normally be, then since each pixel is reprinted by just one byte, a value between 0 to 255 of various graysheds, that is more than adequate to correctly reprint the entire picture. No compression is required there. Without overwhelming size of a file, you can actually store that image as is. And therefore, any format such as BMP or PNG would be useful. However, these are all internal formats. You can't read that file. The file which contains an image, if you have to see a picture, you require some application program which will read that file and convert it into a visible image. That is called raster graphics and there are many tools. For example, Microsoft Paint or even a fax or photograph viewer. These are tools which can read a JPEG file or a BMP file or a PNG file and display it so that you can see it. But ordinarily if you have to look inside the files to understand what those bytes contain, that will be all gibberish because they will mostly be stored in an internal format. In the early days of raster graphics, there was a time by the way where there were no graphic terminals connected to computers. There were no graphic terminals, period. So people are only computers and large ASCII printers. But when graphic terminals started evolving, different people at different research labs started developing their own file formats, which were all internal file formats. A particular group in France, they decided that they needed an ASCII file format to represent an image. An ASCII file format which can be edited easily. Small files can be created quickly, representing some pictures. What kind of pictures would you like to edit and create? After all you have to define each pixel point by point, etc. So obviously you can't do that for very large images. But there is a need to prepare icons. You know icon, a small symbol, representing something. These icons generally do not have a plethora of colours. It is not a colourful scene or something like that. It's not a photograph. They are simple icons. And people said creating icons by painting digitally or scanning, those days scanners and printers were not available as easily as they are available today. So this particular team, Daniel Dadail and Colas Nawaabu, this is the group, bull computer manufacturers. Bull was a major computer manufacturer of Europe. Now you don't hear of them. But they had a good research lab. And in there they developed an ASCII representation for an image file. How does that ASCII representation look like? The ASCII representation has, this is the first row. It is slash star, xpn slash star. Then static cap, star, pxmap name. The square brackets indicate an array by the way equal to then open braces and string, string, string, string, string which I shall discuss, close braces, semicolon. Please note that this looks exactly like a C program component. It was indeed intended to be a C program segment which was to be included in a C source code. And that source code was to be directly combined to generate a, to take that image and then display it using some other mechanism. Here is a format detail. Please note that this string has three types of string. One is value string, there is only one string of this type. Then there are color strings which define the color coding for every different colors that is used. There could be hundred colors, two hundred colors, five colors, two colors as many as you want. Then finally there are pixel strings. For each row of the image, there will be one string and in that string will be color codes that are used to define the color key. We shall explain this in a moment. Value string is just a single string which contains a numerical value for width, a numerical value for height, a numerical value for n colors and numerical value for characters per pixel. Then there is an array of key and color values. Each element typically will be like this, a key which could be a single character, two characters, three characters. This is the heart of the coding value. This key is actually a printable or visible character which can be edited, A, B, C, whatever. It could be one character, two characters, depends upon how many characters you have defined per pixel. And for each character, player or triplet or single character, you have a code C followed by hexadecimal value of the color. Hexadecimal value is always given in red, green and blue order, R, G, B. So, two hexadecimal digits for R and two for B. Key is the color code characters and then each picture can have its own color code. The tool which actually analyzes an XP M5 can map every color code using this key map into the appropriate colors. And then this is followed by picture strings. Like each one in an image has one line in the file. A line may have X dot, X dot, A, A, A, A, B, Q, B, W, B, Q assuming that there are two characters used to represent a particular color. Now, the fingerprint images that we use are in scale as I mentioned. Each one has a one byte pixel value. So, gray state can be represented by color value which has identical red, green and blue pixel as I mentioned. For example, hexadecimal 00000 is black. Hexadecimal FF, FF, FF which is nothing but 255, 255, 255. Maximum value a byte can contain. This will represent white. 808080, for example, is some intermediate gray state. Like all gray states can be represented exactly. So, you need exactly 256 color values to map every pixel. Unfortunately, 256 keys in single printable character are not possible. The ASCII code has only 127 characters out of which printable characters are hardly 100 which can be easily recognized. So, what people do is they use two character codes to represent every particular color. Here is a sample dot image. So, here you can see there is a first string here which says slash star xpm star slash. Notice that this is a C command. So, it will be written as a C command. The next one says static char star dot equal to. So, dot is the name of the file. Dot is the name of the image. So, it is a character pointer. Character pointer as I had mentioned earlier every character array actually represents a character pointer. So, dot represents an image which could be any number of bytes long depending upon width and height. In this particular case, the value sting is 5521. What it means is that the width is 5, height is 5. There are two colors only and there is one character per pixel used. Which are the two colors. One color is represented by dot, another color is represented by x. These are the two colors. So, these two lines actually represent the color code array. After that, there are lines of pixels. How many lines? Because the width is 5 and height is 5, there will be 5 lines each containing 5 bytes. So, this is the first line. Blank, blank, x, blank, blank. Blank, x, x, x, blank. Blank, no, blank. Here x, x, x, x, x. Blank, x, x, x, blank. And blank, blank, x, blank, blank. That means there is no dot that is used. There is x that is used. But the blank also should be represented in a color. So, instead of this dot, you can use the blank character. Blank character is not usable. So, what actually this 5 should contain is dot, dot, x, dot, dot. Dot, x, x, x, dot. X, x, x, x, x. Dot, x, x, x, dot. Dot, dot, x, dot, dot. Because dot represents one color, which is black. And x represents not white. What is this color, can you guess? FF 0000. Red. Because the first byte represents red. Red is maximum intensity. Blue and green are 00. So, it's a full red. So, you will actually get a red dot on your, on your machine if you look at this. Here is a sample image. This sample image I have created, which is 256 by 256 just for convenience. This entire portion is black and this portion is white. So, you can see that this is actually a grayscale image. And the grayness changes from column to column. The first column is all black, the last column is all white. And in between, they are growing shares. Obviously, there are 256 possible shares. So, this sample image represents all possible shares that can be there. Our job is to create an XPM file, which represents this image. Later on, we can see that that XPM file, when it is given to a tool, which can understand XPM, can actually produce the same image on a computer screen. So, here is the program to create XPM files. The first set of things are very standard and straightforward. I include IO stream, F stream, string, C string, math, and namespace STD. You will notice that I am using C string also because string, permit me to define string variables, which we can say this string equal to that plus this, etc., etc., in a C plus plus time because strings are objects. However, there are occasions where you need to use the C type strings, which are actually character arrays. So, a string is stored in a character array terminated by a null value, that is, backslash 0 value. You need both in most cases. And we have so far been using character arrays for manipulation, but strings for simple concatenation and things like that. I have continued using both. Actually, strings are objects, which we have not yet discussed formally. Whereas character arrays are part and parcel of the C, C plus plus standard report time. Here is my main program which starts. Now, you will notice some interesting thing here. I have said unsigned char star image. Image is going to be very large. How big it is going to be? Since I plan 256 pixels by 256, obviously the image size is 256 by 256. Height into width, number of pixels. Even if each pixel is represented by one byte, I will require 256 by 256 bytes. The point is, here I am declaring only a pointer to image, a character pointer. How large it is, I will determine dynamically. And I will allocate an array also dynamically. This is a feature we have never seen earlier. This is called dynamic memory allocation. We shall see that feature now. Then I have defined unsigned in n-width, n-height, and val. By the way, it is not uncommon to use in large variable names certain capital letters, so that the variable is immediately readable and understandable. n-width and n-height written like this, where actually the variables use in the equipments APIs which I just mentioned. Because ultimately I have to connect this particular program version to interface it to that device. Care symbols 256-2. What are these? Remember I mentioned that there will be a character coding I will use for representing different colors or different shades of gear. Since there are 256 shares, I require 256 keys or 256 character combinations, one combination represents one color. Since each combination I propose to use two characters, I have to declare an array of elements 0, 1, and 2. Because each character array will contain two characters and a slash null character, which is terminator of that particular symbol. So I have these symbols which I have defined as 256 symbols. Each is a three character array. Base one, base two, CH1, CH2 are characters which we shall use later in the program. Similarly, IJK, POS, and SIMPOS, etc. we shall see in a moment. Now I want to create an XPM file so I have to define what is a color palette. I can arbitrarily choose any characters by the way. But searching for those characters from an XPM image would become very difficult because I have to ultimately map when I read an XML file XPM file I have to map each pixel of the image into a value. Here I am mapping a value into a key. So both kind of transformations should be easy and numerically computable. That is why what I have chosen is a scheme which uses codes like A, A, B, A, C, etc. up to A, Y then B, A, B, B, C, etc. up to B, Y C, A, C, C, C, B, etc. up to C, Y, and so on. Notice that A to Y there are 25 characters. So if I take 25, 25, 25 characters repeating again the first character changes after every 25 symbols. So I don't require capital A to capital Z. Capital A, capital B, capital C, capital D, E, F, G, H, probably I. That will be more than sufficient to 100 to 256 colors. Individually the second character will change before I get adequate number of keys to be played my colors. This is how I calculate various keys. There is an interesting squiggle because characters can be treated as integer numbers. Notice that I am choosing base one which was declared as a character variable to have a value capital A base to have a value small a. Notice that the ASCII codes for these characters are in sequence. If capital A is base one, then capital A plus one will be base two, will be character B. Capital A plus two will be character C and so on. So I can generate all capital letters by adding one to that base one. Similarly by adding one, two, three, four to base two I can generate all small letters in the sequence. Since I need to generate 256 key values I set up a loop for 0 to 255 and I set K0 which is the first character of the symbol as base one plus K by 25. What will these do? For values of K between 0 to 24 this K by 25 will be 0. That means only base one, character A will be occupying a symbol 001020 etc. The first character will be A for 25 symbol. The moment K becomes 26 for example this will become one. 26 by 25 is one, integer to be. And I will add one to base one which will make this whole value as character B and then B will go into that particular first element of the symbol I for 26 to 51. Again 52 onwards, sorry, 26 to 50. Again 51 onwards different things, C will happen, D will happen and so on. Notice that for base two I am using K% 25. This is modulo 25. So any value which is more than 25 if it is 25 the modulo will be 0 and again it will go 0, 1, 2, 3, 4, 5, 6, 7, 8 up to 24 then again 0, 1, 2, 3, 4, 5, 6, 7, 8 up to 24 that is how the second character of a symbol will vary from small a to small b, small c, small d, etc. In a simple arithmetic operation I am able to create keys of this kind. I have not assigned colors to keys but I have generated unique pairs of characters which can be used to represent colors. I have of course put a slash null to say that each one of the elements of the symbols two dimensional array is actually a character string. I am playing these symbols just to make sure that I get whatever I want. Please note I am printing symbols 0. Symbol is actually two dimensional array. Now when I say symbols 0 it treats this as a character pointer and it treats the entire contents of that whole array. That is why I cannot ordinarily you see out if I wanted to print only a single character. If I wanted to print a single character I had to take special precaution to print a single character. Anyway, now I start I need an image which I want to encode in XP M5. I don't have an image. Originally I will get a fingerprint from that device. Here I am creating an image on my own. I want to create that sample image. So just go back to this point this is width and this is height. If I have an eye so let us say this is eye throw and this is jth column. This particular pixel is eye, j. What will be the grade scale value at this point? Notice that I wanted to fill up this entire set with 00 sorry black here so 255 here maybe oh no sorry 0 is black so I wanted 0000 like that I wanted 111 like that and I wanted 256, 255, 255, 255 like that. You agree that this is what will give me the sample image? So what should be the value for the eye, jth element? If I have a single dimensional array called image the image contents will be 256 into 256. So technically I want to set eye, jth element but this is not a two dimensional array. How do I convert the value of eye and j into a single dimensional value? Within this array I have to calculate a position in terms of eye and j. My contention is the position will be given by eye multiplied by w plus j. Do you agree with this? This entire thing is one width, second width, third width so when I have completed three widths I have got three times width pixels gone since it starts with 0, 1, 2 if I multiply eye into w I am actually at the eye at the beginning and I add j to it so that I get this pixel value. This is how I am assigning pixel values here so if you go back to the screen all that I am saying is j varies from 0 to n width width is 256 here so I am actually putting up a value j percent 256 will be 0, 1, 2, 3, 4 up to 255 as j varies and that is what I want to push along the particular row 0 value here maximum value at the other corner and I want to do it for every row all that I do is for 0 to n height I will put this value but where should I put it? So I put it in a position called pos which I calculate as eye into n width plus j this is exactly will generate a picture value of the pixel value which is of the kind that we saw in the sample image this is just an artificial power in real life I will neither know the width nor know the height nor I will be able to put any value that I want in an image actually I will get this image captured from some device and I expect that device to tell me what is the width of the image what is the length of the image since it is a grayscale image I assume that the values which are supplied by that device for that entire array I will get a fill up array from that device those values will be between 0 to 255 since this is an artificial image I am generating I have put these values like this here now I want to write the file in the xpm format notice the file open statement this is the standard one which we have seen there sample 1, sample i, sorry this is a capital i sample i dot xpm that is the file name I have chosen ios colon colon out this is actually an additional information which is given for iostream objects so my file actually is a c++ object of the type iostream and the characteristic of this particular object is that it is an output file that is what is meant from this description the rest of it is standard we have been doing that if my file is open then I start writing if it is not then I will say my file can be open, shut off the business so the rest of the entire program is written as part of this if and what does this if say it says that first of all write this comment line remember this is to be the first comment line in that xpm file then it writes the next line which is static cal, star, sample i this equal to opening brass this was the second line of the xpm file notice that I am able to write this because everything is standard ascii characteristic so I write the second line now I write a comment the comment says width, height, encoders and cast per pixel these are not values this is just a plain comment as indicated by star, star, star, star I am just inserting a comment I can insert any number of comments in xpm file there is ultimately going to be a c source file so all comments will be ignored by the c compiler later never forget to put a end of line at end of each line now I write the image header information the image header information has to contain width, height number of colors and number of bytes per color number of colors I have already predecided to 56 number of bytes per color I have predecided two bytes but height and width I have written as variable because I want to use the same program later even if I get any new image which will have its own width, its own height now that will be known by this time however in terms of the variable values of n width and n height so I am keeping them there notice that every line in the subsequent lines of xpm file has to start with an opening quote line, closing quotation double quote and comma that is the format of each line how do I insert a double quote at the beginning that is why you notice because double quote is required to start a string anyway which I want to output but since the first character I want to output is a double quote itself I put a backslash before that which is a escape character backslash double quote means Mr. C compiler please don't treat this double quote as the normal double quote of C++ but treat this as a character which is to be inserted in that string you will see that again and again towards the end of this line I have backslash double quote yeah so I want to insert this insertion operator will give me n width I have two blanks here then n height the value will go on to my file then again I have new insertion operation two blanks again a value two blanks again a value and a string which contains a closing double quote and a comma followed by end of one so this will create the next line now I want to write color palette so I write a header again another command slash star color slash now I am inserting color palette so you can see how the color palette is being inserted notice that I have to write two 56 lines in that xpm file each line should contain the key value the two character code followed by a vector C which means that it is a color not G or not M and then the color value is hexadecimal so see what I do I first put a backslash double quote as required then I put character casted symbols i0 please note symbols i0 is a pointer and it would have printed a large string but when I say cab in front of it the whole value is converted into a single character and a single character therefore will output this casting is very useful you have any expression it generates a value of a certain type if you want to force a conversion of that type into any compatible type for example you can convert into a float you can convert character into integer you can convert integer into character you can convert a pointer etc then you write the desired final type of the expression value in brackets in parenthesis just in front of that expression this is called typecasting and is a extremely important characteristic of cc++ program so I typecast this character as a single character here and output it notice that for the ith symbol I would have succeeded in printing the first character and the second character the key value so far on my file notice that my file does not automatically put either blanks or the line unless I explicitly do that so that is why I have two blanks followed by c followed by two blanks so I have constructed half the line of a character code just the two character key blank blank c blank blank now I have to put a hex value for the corresponding color I know what is the corresponding color what is the line number then red blue and green should have I I I that will be the value of the gray scale red I blue I and green I so if I is 4 it will be 4 4 4 if I is 255 255 255 255 all that I need to do is write 6 hexadecimal characters representing the same value of R 3 types however I have a problem normally if I say my file R then the value will come out in decimal I don't want it I want it in hexadecimal that is where you see another use of setting what is known as format flags my file dot setf will set certain format flags that we choose each file in c++ objects in object stream comes with its own format flags there are default values which you don't normally need to know because c in and c out normally function as formatted file objects only so they have associated format flags normally you don't bother with it but we know that whenever we output a value of a variable it will come in decimal there is a format flag which is called basefade format flag if the basefade ordinarily is decimal I want to convert it into hex from this point onwards any numerical value that I print will come out in hex and yes I reset it for which I use another operation here my file dot unsetf IOS colon colon hex this means that for the IOS stream whichever flags were set by me unset them make them into default value ordinary I would have simply said my file less less hash less less I less less I less less I hash represents hexadecimal you notice that in the sample file that we saw I want hash sign 2 bytes of hexadecimal red 2 bytes of hexadecimal green 2 bytes of hexadecimal blue and ordinarily I will translate into 2 bytes except for values of how which are less than 16 the values of how less than 16 require only 1 hexadecimal digit 0 1 2 3 4 5 6 7 8 9 a b c d e f that's it but I need 2 characters the second character should be 0 so it should be 0 1 0 2 0 3 0 f for the first 16 value I can't force a 0 by any formatting conveniently so notice what I am doing if I is less than 16 I am actually forcing a 0 before every value of I so the first 16 lines will contain 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 2 0 2 etc 0 f 0 f 0 f 0 f then we will start 1 0 1 0 1 0 which will naturally fall in this way I complete the entire color code or color palette insertion and end up with a semicolon command end there so all the rows are written like this now I have to output the lines containing the coded pixel values for each row in the image so I now scan the image for I equal to 0 to N which is the height notice that when we are sitting here I want to write this row first then this row then third row and so on till all the height rows are written so one row at a time and each row has to be represented by two character color code for each pixel since I have 256 pixels or N width pixels I will write N width pairs of characters these are to be preceded by an opening double code has to be succeeded by closing double code and a comma this is exactly what I do here I first put an opening double code then for each row I compose the remaining line notice how the remaining line is composed for j equal to 0 to N width I first get a pixel value the position is calculated as earlier and the value of the pixel is simply the position of value of image position of value of image image is a character string notice that each character is equivalent of an unsigned integer so I cast this value into an unsigned in and assign it to value so I now get a numerical value between 0 to 255 now I locate two character symbols for this pixel so what is the position of the symbol I can do it with arithmetic I can also search that array of symbols for the characters there so depending upon the value I derive this value by 25 multiply by 25 I will get the index for the first character plus value more 25 I will get the index for the second character so 25 times this index plus 25 times plus remainder will be actually the position so I simply say symbols sin plus 0 this is my first character notice that this is a pointer so I cast it in care then I cast it in care assign it in CH2 and I say my file less less CH1 less less CH2 I could have also written this entire expression here on a slide it is not convenient to write a long expression so therefore I have cast these in cares and assigned them to care CH1 and CH2 it's a small time simplificate now I push closing quotes a new line and then I have completed my entire picture writing now I will now write the last line in the file which is which has a closing brass and semicolon because the entire file has to be actually a part of the C program source somewhere and I close the file so this is the program which will write the file these are portions of XPM file which I have written so when I execute this program this file is generated and this file says XPM static cast of sample I with height N colors cast per pixel notice that these comment lines all these lines are generated by writing some fixed C out of my file out statements then these are the actual values 256 256 256 is with 256 is height there are 256 colors and each color is represented by two characters then I have come in line for colors this is how the color key will come this is my color palette AA represents 0, AB represents 1 AC represents 2 and so on this will continue till all color palette is exhausted then for each row there will be one line and finally the last line will have etcetera etcetera etcetera and it will end into KF you will notice that KF will correspond to the maximum value 255 and AA will correspond to 0 and finally I have this this file will be actually created it is an artificial sample but if I have an actual image instead of the artificially created image this same program would have created an XPM file for that image as well as we shall see in a moment as some sample output when I give this XPM file to any imaging tool it will actually display that image I can also convert it into BMP file to be used along with more popular Microsoft tools Microsoft tools do not ordinarily recognize the XPM file so you can use a convert utility to convert it into any form JPEG or whatever using such conversion I get this sample image again now this time I have not constructed it by hand or something this is what the program actually represents now I have used the same program incorporating it inside the interface to that device which we saw the other day except now I cannot every time create the same file called sample I after all different individual's finger prints will be collected each individual may be finger printed for 3 or 4 fingers so how to have variable file names to create these variable file names I have this simple mechanism I define a string called file name and I define a string called file name with extension I can get a file name for fingerprint storage by saying give a file name without extension and see in file name whatever I type a single name without extension will go in and will sit inside here as the file name the final file name which I want to open a file output file will contain an extension in C++ objects which strings are I can simply say file name with extension equal to cross dot xpm so this will create file name dot xpm as their name however when I open the file by saying my file dot open I cannot give just that file name with extension because if I did that then that is treated as a string object and is not considered valid for an open statement in C file system you have to give actually a C style string for that file name but I have a function here which says dot C underscore str they actually a method for the object called string all that it does is it takes the C++ style string and converts it into a C style string which is required for my open this will open that file IOS is again stated as now so if I insert this code into the same program the program will work and will work for any file and now instead of artificial file if I put this program along with the application program that device integrated and connect that device to my machine and run this program every captured fingerprint will come out as an xpm file here is a fingerprint xpm file that I have created I have chosen names in a very funny fashion LT means left thumb 0 means 0 with impression because the same fellow can later one come again with the thumb I will call it LT 1, LT 2 for comparison purpose I have person 1, person 2, person 3 practically everybody in the house and all guests who are visiting me yesterday have been fingerprinted and I have files notice that width height is given by the device 352 bytes width 544 bytes height that is the height and width that is written by that device I have not created this artificial the color code is of course my own and this is followed by the actual pixels so when I put that and create a dot xpm file convert it into dot pmp for example this is the fingerprint of a person I get you will be getting such fingerprints when you do your registration part of the project and you will be using such fingerprints for analysis duplicate checking application whatever whatever just to show you here is a fingerprint of another person even visually you can see that these two fingerprints are different but you have to handle that computer programming and that is not an easy job that is why you have to define certain templates, calculate those templates and then there is a plethora of matching process which you will have to discover and apply here is the same person at different times this is to illustrate that you can't take an image to image direct comparison byte by byte it will never match because there is a small displacement of the hand and finger when you capture the fingerprint laterally or horizontally and if that displacement happens there will be subtle differences for example you will notice that this world is here whereas this is somewhere here this rich bifurcation is happening here whereas it is happening somewhere here nearer so point by point comparison is completely useless in image comparison that is why you have to translate these images by some pre-processing into some templates and do your work ok we will close this now thank you