In the C++ programming language write a program capable of playing 3D Tic-Tac-Toe against the user. Your program should use OOP concepts in its design.Use Inheritance to create a derived class from your Lab #9 Tic-Tac-Toe class. You can use ASCII art to generate and display the 3x3x3 playing board. The program should randomly decide who goes first computer or user.Your program should know and inform the user if an illegal move was made (cell already occupied). The program should also keep the score and announce if one of the players wins or if a draw is achieved. While it is desirable for your program to play a strong game, this is not an Artificial Intelligence course so if your program does not play at a world champion level you will not be penalized for it.The object of a 3D-TTT is to get as many 3-in-a-row as possible. You win just like in traditional TTT, except you can also win by getting 3-in-a-raw down each board. Imagine the boards as placed on top of each other. Blank Board: ___|___|___ ___|___|___ | | ___|___|___ ___|___|___ | | ___|___|___ ___|___|___ | | Game in Progress: _x_|_0_|_0_ _x_|_x_|_x_ 0 | 0 | x _0_|___|___ ___|_x_|___ | | ___|___|___ ___|_0_|_0__ | x |
In the C++ programming language write a program capable of playing Tic-Tac-Toe against the user. Your program should use OOP concepts in its design.You can use ASCII art to generate and display the 3×3 playing board. The program should randomly decide who goes first computer or user. Your program should know and inform the user if an illegal move was made (cell already occupied).The program should also announce if one of the players wins or if a draw is achieved. While it is desirable for your program to play a strong game, this is not an Artificial Intelligence course so if your program does not play at a world champion level you will not be penalized for it.
You have worked very hard on your phonebook program for many weeks and it is becoming a popular application with all your friends. You decide you want to compete with facebook.com and the next upgrade of your phonebook software should make contact data accessible even if the user closes your application and returns to it at a later time.Add additional functionality to your phonebook program from lab# 7. Make it possible for users to: 1) Store all entries in the phonebook into a location/file-name specified by the user. 2) Retrieve entries from the location/file-name specified by the user. If the user does not explicitly specify a path to the file, a default location of your choosing should be used.
Add additional functionality to your phonebook program from lab# 6. Make it possible for users to: 1) Alphabetically sort the list of entries by name (first or last).2) Find a phone number for a given name.3) Randomly select a friend from the phonebook for you to call.4) Delete everyone from the phonebook at the same time.
Write a program which generates interactive stories. You program should begin by asking the user a number of questions such as: what is your name?How old are you? What is your favorite color? Etc. After obtaining a sufficient amount of personal information your program should output a short story (at least one paragraph) which incorporates user’s personal information you have obtained via questioning. (The topic of the story is up to you, but please keeps it clean.)The generated story should be somewhat different every time the program is run (randomly generate alternative endings, randomly select different descriptions of objects (blue car, green car, red car), etc. Your program should make use of pointers and arrays to deal with strings.Sample Output: What is your name? Roman How old are you? 30 What is your favorite color? black Roman is a 30 year old who likes his black laptop… Sample Output (second run of the same program): What is your name? Roman How old are you? 30 What is your favorite color? black Roman is a 30 year old who likes his black Toyota Corolla…
Write a program that uses an array of structures to hold contact information for your friends. The program should allow the user to enter as many friends as the user wants.Create functions to add or delete entries in the phone book and to print valid phone book entries. Do not display phone book entries that are invalid or NULL (0). You can assume that all people have unique names. Make sure you allocate and free memory as necessary.Output example: Phone Book Application 1) Add friend 2) Delete friend 3) Show phone book What do you want to do: 1 First name: Bob Last name: Smith Phone number: 123-4567 Record added to the phone bookPhone Book Application 1) Add friend 2) Delete friend 3) Show phone book What do you want to do: 1 First name: John Last name: Doe Phone number: 893-4567 Record added to the phone book Phone Book Application 1) Add friend 2) Delete friend 3) Show phone book What do you want to do: 3 Phone Book Entries: Bob Smith 123-4567 John Doe 893-4567 Dr. Roman V. Yampolskiy CECS-130-1,2 Phone Book Application 1) Add friend 2) Delete friend 3) Show phone book What do you want to do: 2 First name: John Last name: Doe Record deleted from the phone book Phone Book Application 1) Add friend 2) Delete friend 3) Show phone book What do you want to do: 3 Phone Book Entries: Bob Smith 123-4567
Rewrite your lab 3 calculator program using functions. Each mathematical operation in the menu should be represented by a separate function. In addition to all operations your calculator had to support in lab 3, please add additional functionality to your calculator.Include the ability to compute the factorial of an integer (Example: 4! = 1 * 2 * 3 *4 = 24), and an integer power of a number (Example: 53 = 5 * 5 * 5 = 125).Finally, add an interesting mathematical function of your choosing which computes the first n numbers of a sequence of numbers and utilizes an array to store the result before displaying it (Examples of mathematical sequences: Fibonacci, Primes).Example of the output follows: Calculator Menu: (1) Addition (2) Subtraction (3) Multiplication (4) Division (5) Modulus (integers only) (6) Test if prime (integers only) (7) Factorial (integers only) (8) Power (9) Your function (0) ExitPlease choose an operation: 8 Enter the first number: 5 Enter the second number: 3 5^3 = 125 Calculator Menu: (1) Addition (2) Subtraction (3) Multiplication (4) Division (5) Modulus (integers only) (6) Test if prime (integers only) (7) Factorial (integers only) (8) Power (9) Your function (0) ExitPlease choose an operation: 0 Good Bye! You program MUST be bug-free, user friendly (verify input from the user), well commented (Including author information, program description, lab section, date, etc.)
Write a computer program in C which will simulate a calculator. Your calculator needs to support the five basic operations (addition, subtraction, multiplication, division and modulus) plus primality testing (natural number is prime if it has no non-trivial divisors).Example of the output follows: Calculator Menu: (1) Addition (2) Subtraction (3) Multiplication (4) Division (5) Modulus (integers only) (6) Test if prime (integers only) (7) ExitPlease choose an operation: 2 Enter the first number: 18 Enter the second number: 20 18 – 20 = -2 Calculator Menu: (1) Addition (2) Subtraction (3) Multiplication (4) Division (5) Modulus (integers only) (6) Test if prime (integers only) (7) ExitPlease choose an operation: 6 Enter the number to be tested: 22 Not prime: 2 x 11 = 22 Calculator Menu: (1) Addition (2) Subtraction (3) Multiplication (4) Division (5) Modulus (integers only) (6) Test if prime (integers only) (7) ExitPlease choose an operation: 7 Good Bye! You program MUST be bug-free, well commented (Including author information, program description, lab section, date, etc.)
Write a computer program in C which will request the user to enter a number representing the amount of foreign currency he/she would like to exchange.Your program should output a foreign currency conversion table for at least 6 different currencies, showing how much of each type of foreign currency can be obtained for the amount the user enters.The example below shows a foreign currency exchange table for one unit of foreign currency. Your program is interactive and so should work for any input amount from the user not just 1.00. In the example table, the number entered by the user is 1, and it shows that 1 USD is equal to 0.547525 GBP, while 1 GBP is equal to 2.11928 AUD and so forth.If the user enters 2, your table should show how much 2 USD is in GBP, CAD, EUR, etc. along with how much 2 CAD would be in EUR, GBP, USD, etc, for each of the 6 currencies. The example uses real graphics not ASCII-art so it is ok if your table is not as visually pleasing.USD GBP CAD EUR AUD 1 1.8264 0.949938 1.46849 0.861801 0.547525 1 0.520114 0.80404 0.471857 1.0527 1.92265 1 1.54588 0.907218 0.680967 1.24371 0.646876 1 0.586858 1.16036 2.11928 1.10227 1.70398 1 Friday, August 29, 2008All exchange rates in your program must be current and coded as constants. Make sure you display a nice looking table using escape sequences and your ability to produce beautiful ASCII-art. You program MUST be bug-free and well commented (Including author information, program description, lab section, date, etc.)
Write a computer program in C which will generate an original ASCII-art picture, more specifically, a representation of your instructor Dr. Yampolskiy.You program MUST be bug-free, well commented (Including author’s information, program description, lab section, date, etc.) and must demonstrate use of different escape sequences. Some examples from students enrolled in CECS130 in the prior semesters follow:
Ability to work in teams is essential for a successful career in computer science. Begin this Final Project by finding a partner who has completed lab#10. You can work with anyone registered for CECS130 from either Tuesday or Thursday lab section.Your assignment is to create (in the C++ programming language using good OOP principles (namespaces, etc.)) a Competition class which inherits from yours and your partner’s 3D TTT classes.Assuming both 3DTTT classes have a function which asks computer to make a move it should be possible with very little rewriting to create a competition between two computer players. Set it up so the two game bots play 10 games in a row against each other and a winner is determined and announced at the end of this competition. Give your computer players names which correspond to the names of the two programmers who created them.In the header comments to you program please clearly identify the names of the two programmers comprising your team. Obviously you and your partner will only get one (same) grade for the lab.
In this question you will try to understand the working of DCT in the context of JPEG. Below is an 8×8 luminance block of pixel values and its corresponding DCT coefficients. 188 180 155 149 179 116 86 96 168 179 168 174 180 111 86 95 150 166 175 189 165 101 88 97 163 165 179 184 135 90 91 96 170 180 178 144 102 87 91 98 175 174 141 104 85 83 88 96 153 134 105 82 83 87 92 96 117 104 86 80 86 90 92 103• Using the 2D DCT formula, compute the 64 DCT values. Assume that you quantize your DCT coefficients using the luminance quantization table K1 on page 143 of the uploaded ITU-T JPEG standard. What does your table look like after quantization? (5 points)• In the JPEG pipeline, the quantized DCT values are then further scanned in a zigzag order. Ignoring your DC value, show the resulting zigzag scan AC values. (2 points). • For this zigzag AC sequence, write down the intermediary notation (5 points)• For these are luminance values, write down the resulting JPEG bit stream. You will need to consult standard luminance code tables on page 150 of the ITU-T JPEG standard. (6 points) • What compression ratio do you get for this luminance block? (2 points)This programming assignment will help you gain an understanding of issues that relate to image compression using wavelets. You will read an RGB file and convert the image pixel to a DWT representation (as used in the JPEG2000 implementation) for each channel. Depending on the second parameter n you will decode both the representations using only n levels of the low pass coefficients and display the output. Remember all input files will have the same format as explained to the class website.They will be of size 512×512 (intentionally square and a power of 2 to facilitate easy encoding and decoding). Your algorithm, whether encoding or decoding, should work on each channel independently. Input to your program will be 2 parameters where:• The first parameter is the name of the input image rgb file. (file format is similar to previous assignments). • The second parameter n is an integral number from 0 to 9 that defines the low pass level to be used in your decoding. For a given n, this translates to using 2n low pass coefficients in rows and columns respectively to use in the decoding process . Additionally, n could also take a value of -1 to show progressive decoding. Please see the implementation section for an explanationTypical invocations to your program would look like MyExe Image.rgb 9 This the level 9 or the highest level and as such corresponds to your entire image. Here you are making use of 2 9 = 512 coefficients in rows and 512 coefficients in columns, which essentially is the input image itself and so the output should look just like the input.MyExe Image.rgb 8 This is level 8 and the first level of the wavelet encoded hierarchy in rows and columns. Here you are making use of 28 = 256 low pass coefficients in rows and 256 low pass coefficients in columns, MyExe Image.rgb 1This is level 1 and the eight level in the wavelet encoded hierarchy in rows and columns . Here you are making use of 22 = 4 low pass coefficients in rows and 4 low pass coefficients in columns, Encoding ImplementationFor the DWT encoding process, convert each row (for each channel) into low pass and high pass coefficients followed by the same for each column applied to the output of the row processing. Recurse through the process as explained in class through rows first then the columns next at each recursive iteration, each time operating on the low pass section until you reach the appropriate levelDecoding Implementation: Once you reach the appropriate level, zero out all the high pass coefficients. Then perform a recursive IDWT from the encoded level upto level 9 which is the image level. Yu need to appropriately decode by zeroing out the unrequested coefficients (just setting the coefficients to zero) and then perform an IDWT.Progressive Encoding-Decoding Implementation This is when n = -1. In this case you will go through the creation of the entire DWT representation till level 0. Then decode each level recursively and display the output. The first display will be at level 0, then level 1 and so on till you reach level 9. You should see the image progressively improving with details.What should you submit? • Your source code, and your project file or makefile. Please confirm submission procedure from the TAs. Please do not submit any binaries or data sets. We will compile your program and execute our tests accordingly. • Along with the program, also submit an electronic document (word, pdf, pagemaker etc) for the written part and any other extra credit explanations.
A Rubik’s cube is a cube-shaped puzzle with 6 different 3×3 colored tiled sides: white, green, red, blue, orange, and yellow. The goal of the puzzle is to rotate sides and make each face have 3×3 tiles of the same color. When held under different colored lights (white, red, green, blue) the cube looks very interesting and vivid, see below:• The chromaticity diagram in (x, y) represents the normalized color matching functions X, Y and Z. Prove that (2 points) Z = [ (1-x-y)/y ] YHere you are tasked with mapping the gamut of a printer to that of a color CRT monitor. Assume that gamuts are not the same, that is, there are colors in the printer’s gamut that do not appear in the monitor’s gamut and vice versa. So in order to print a color seen on the monitor you choose the nearest color in the gamut of the printer.Answer the following questions • Explain why this happened. Why do some tiles look bright, almost glowing, while others appear muted and devoid of their original color? (4 points)• Assuming ideal conditions, you have the following lighting conditions to solve the puzzle – under pure yellow light or under red light. Which of these two light choices make it harder to solve? Give reasons for your choice of answer. (6 points)• Comment (giving reasons) whether this algorithm will work effectively? (2 points) • You have two images – a cartoon image with constant color tones and a real image with varying color tones? Which image will this algorithm perform better – give reasons? (2 points) • Can you suggest improvements rather than just choosing the nearest color? (4 points)Consider a communication system that gives out only two symbols X and Y. Assume that the parameterization followed by the probabilities are P(X) = xk and P(Y) = (1-x k )• Write down the entropy function and plot it as a function of x for k=2. (1 points) • From your plot, for what value of x with k=2 does H become a minimum? (1 points)• Your plot visually gives you the minimum value of x for k=2, find out a generalized formula for x in terms of k for which H is a minimum (3 points). • From your plot, for what value of x with k=2 does H become a maximum? (1 points)• Your plot visually gives you the maximum value of x for k=2, find out a generalized formula for x in terms of k for which H is a maximum (4 points).Bob has a pen pal, Alice, who has been learning about information theory and compression techniques. Alice decides from now on that they should exchange letters as encoded signals so they can save on ink.The following is a letter that Alice sends to Bob on her trip to Paris: • Find and show a Huffman code for the body of Alice’s postcard (i.e. exclude “Dear Bob” and “Alice”). Treat each word as a symbol, and don’t include punctuation. What is the average code length? (3 points)Bob, having just learned about the telegram in history class, suggests to Alice that they can try writing their letters as telegram messages to shorten them even more. He sends Alice what her postcard might look like as a telegram: Dear Bob, Hello from Paris!I got this postcard from the Louvre. You would love Paris! I hope to hear from you.Alice • Find a Huffman code for the telegram message. What is the average code length? How does it compare to the original letter? (3 points)• Which version of the message, postcard, or telegram, contains more information? Show quantitatively and explain qualitatively where the difference (if any) comes from. (4 points)This assignment will help you gain a practical understanding of analyzing color channels especially as it pertains to image segmentation. While image segmentation is a challenging task in the field of image processing and computer vision, the process has been made simpler via the use of green screen and chroma keying techniques. I am sure you are all too familiar with online video conferencing applications such as zoom, webex where you can change your background with or without a green screen. Here you will implement similar functionality and hopefully get an opportunity to explore color and color spaces.You will be given two input videos in the same rgb format – each video will be a 640×480 video that plays at 24 fps for a total of 20 seconds (480 frames). The frames are named with a base name and indexed by frame number eg basename.0001.rgb, basename.0002.rgb … basename.0600.rgb. You are free to use extend the display code sample given of assignment 1 to display a sequence of images at the frame rate of display and implement the color algorithms needed in this video. (no scripting languages such as MATLAB or python please!).To invoke your program we will compile it and run it at the command line as YourProgram.exe C:/myDir/foreGroundVideo C:/myDir/backGroundVideo mode Where,• foreGroundVideo is the base name for a green screened foreground video, which has a foreground element (actor, object) captured in front of a green screen. • backGroundVideo is any normal video • mode is a mode that can take values 1 or 0. 1 indicating that the foreground video has a green screen, and 0 indicating there is no green screen.IN PARIS POSTCARD FROM LOUVRE STOP YOU WOULD LOVE STOP HOPE HEAR FROM YOU STOPImplementation details for mode 1: In this mode you have a green screen used in the foreground video. While the color of screen used is intended to be constant, practically it never is and has slight variations that come across in the captured video. While a specific color might have been used, the actual RGB pixel values of the screen can vary depending on lighting conditions, shadows cast, noise and quantization in the capture process etc. Normally thresholds may be used to decide how to detect green screen pixels. In your implemented you need to arrive at these thresholds by analyzing your video.For all frames write a process that will detect the green screen pixels in the foreground video and replace them with the corresponding background video pixels in all the frames.Image taken from https://en.wikipedia.org/wiki/Chroma_key Some thoughts that you might want to consider • How do you detect the thresholds to label a pixel as a green screen pixels given that the screen pixels might have noise, shadows etc.• You can certainly make this work by processing in the RGB color space, but other color spaces might work better like HSV. Here are references that were shared in the class and should give you an understanding of these spaces. https://en.wikipedia.org/wiki/HSL_and_HSV https://www.cs.rit.edu/~ncs/color/• To have good quality at the boundaries of the composition (where foreground regions and background video meet), can you think how you to blend boundary pixels correctly, so that the foreground element does not appear stuck on a background but blends in nicelyImplementation details for mode 0: In this mode your foreground video does not have any constant colored green screen and while this is a hard problem to find automatically, the foreground videos we give you will have the foreground element (actor, object) moving in every frame while the camera is static. In other words, you should be able to arrive at your green screen pixels by comparing two frames where – pixels that are constant (not changing within some threshold) can be assumed to be “green screen” pixels and hence can be replaced by the corresponding pixels in the background video. This algorithm is known as background subtraction.For example, shown below are two frames from a static camera. Comparing corresponding pixels in frame1 and frame2 (for each x,y), you should be able to assess pixels that have “not changed” and hence can serve as “green screen” pixels. Also, pixels that have changed and hence are foreground pixels. You may then proceed to composite the other video’s corresponding frame with this extracted green screen. Note – while the camera may be static, under changing conditions of lighting, motion etc, you might not get “perfect” results, especially in at the boundaries of the areas in motion. Also, if there is no motion, then you will not be able to extract this foreground.Frame 1 Frame 2 Foreground What should you submit? • Your source code, and your project file or makefile, if any, using the submit program. Please do not submit any binaries or images. We will compile your program and execute our tests accordingly. • If you need to include a readme.txt file with any special instructions on compilation, that is fine too.
Question 1: (5 points) The following sequence of real numbers has been obtained sampling an audio signal: 1.8, 2.2, 2.2, 3.2, 3.3, 3.3, 2.5, 2.8, 2.8, 2.8, 1.5, 1.0, 1.2, 1.2, 1.8, 2.2, 2.2, 2.2, 1.9, 2.3, 1.2, 0.2, -1.2, -1.2, -1.7, -1.1, -2.2, -1.5, -1.5, -0.7, 0.1, 0.9 Quantize this sequence by dividing the interval [-4, 4] into 32 uniformly distributed levels by placing the level 0 at -3.75, the level 1 at -3.5, and so on and level 31 at 4.00. Also, remember that quantization should result in least error Write down the quantized sequence. (4 points) How many bits do you need to transmit it? (1 points)Question 2: (10 points) A high-definition film color camera has 1080 lines per frame, 1920 pixels per line, with a 24 Hz capture frame rate. Each pixel is quantized with 12 bits per channel during the quantization process.The capture pipeline employs the follow sequence 1. YUV 4:2:0 color subsampling scheme 2. An optional feature, to the signal to standard definition CIF (352×288) 3. An obligatory MPEG2 compression phase 4. Disk write with a varying disk write speed (12 to 36 Mbytes per second).Answer the following questions If the second optional feature is off, what minimal compression ratio needs be achieved by the third compression step process? (4 points) If the second optional feature is turned on to produce CIF format, how does your previous answer change? (3 points) If original pixels were square, how do the pixel stretch with the second optional feature turned on.? (3 points)Question 3: (15 points) Temporal aliasing can be observed when you attempt to record a rotating wheel with a video camera. In this problem, you will analyze such effects. Assume there is a car moving at 36 km/hr and you record the car using a film, which traditionally records at 24 frames per second. The tires have a diameter of 0.4244 meters. Each tire has a white mark to gauge the speed of rotation. (15 points) If you are watching this projected movie in a theater, what do you perceive the rate of tire rotation to be in rotations/sec? (3 points) If you use your camcorder to record the movie in the theater and your camcorder is recording at one third film rate (ie 8 fps), at what rate (rotations/sec) does the tire rotate in your video recording (6 points) The driver decides to participate in race, and buys tires that safely allow a max speed of 180 km/hr. What must be the diameter of the tire if no temporal aliasing needs to be witnessed in the recording? (6 points)This assignment will help you gain a practical understanding of Quantization and Subsampling to analyze how it affects visual media types like images and video. We have provided you with a Microsoft Visual C++ project and a java class to display two images side by side (original on the left and a processed output on the right). Currently both left and right correspond to the same input image. You are free to any of these as a start.Your program will be invoked using seven parameters where YourProgram.exe C:/myDir/myImage.rgb Y U V Sw Sh A The first parameter is the name of the image, which will be provided in an 8 bit per channel RGB format (Total 24 bits per pixel).You may assume that all images will be of the same size for this assignment (HD size = 1920wx1080h), more information on the image format will be placed on the class website The next three parameters are integers control the subsampling of your Y U and V spaces respectively.For sake of simplicity, we will follow the convention that subsampling occurs only along the width dimension and not the height. Each of these parameters can take on values from 1 to n for some n, 1 suggesting no sub sampling and n suggesting a sub sampling by n The next two parameters are single precision floats Sw and Sh which take positive values < 1.0 and control the scaled output image width and height independently. Finally a integer A ( 0 or 1) to suggest that antialiasing (prefiltering needs to be performed). 0 indicates no antialiasing and vice versaExample invocations shown below should give you a fair idea about what your input parameters do and how your program will be tested. 1. YourProgram,exe image1.rgb 1 1 1 1.0 1.0 0 No subsampling in the Y, U or V, and no scaling in w and h and no antialiasing, which implies that the output is the same as the input2. YourProgram,exe image1.rgb 1 1 1 0.5 0.5 1 No subsampling in Y, U or V, but the image is one fourth its original size (antialiased)3. YourProgram,exe image1.rgb 1 2 2 1.0 1.0 0 The output is not scaled in size, but the U and V channels are subsampled by 2. No subsampling in the Y channels.Now for the details – In order the display an image on a display device, the normal choice is an RGB representation. Here is the dataflow pipeline that illustrates all the steps. 1.Read Input Image (RGB) Display Input Image 2. Convert to YUV space 3. Process YUV subsampling 4. Adjust up sampling for display 5. Convert back to RGB space Display Output ImageThis code is already provided to you, if you choose to make use of it The RGB to YUV with the conversion matrix is given below Sub sample Y U and V separately according to the input parameters 6. Scale RGB image with Sw & Sh respecting choice of AAdjust sample values. Although samples are lost, prior to further process, all values must be interpolated in place Apply the inverse matrix to get the RGB data Scale the RGB image and display final output Conversion of RGB to YUV Given R, G and B values the conversion from RGB to YUV is given by a matrix multiplication Y 0.299 0.587 0.114 R U = 0.596 -0.274 -0.322 G V 0.211 -0.523 0.312` BRemember that if RGB channels are represented by n bits each, then the YUV channels are also represented by the same number of bits.Conversion of YUV to RGB Given R, G and B values the conversion from RGB to YUV is given by the inverse matrix multiplication R 1.000 0.956 0.621 Y G = 1.000 -0.272 -0.647 U B 1.000 -1.106 1.703 VSub sampling of YUV & processing Sub sampling, as you know will reduce the number of samples for a channel. Eg for the input parametersYourProgram.exe image1.rgb 1 2 2 256In this example, the YUV image is not subsampled in Y, but by 2 in U and by 2 in V resulting in When converting back to the RGB space, all the YUV channels have to be of the same size.However the sampling throws away samples, which have to be filled in appropriately by average the neighborhood values. For example, for the above case a local image area would look like Y11U11V11 Y12 Y13U13V13 Y14 . . . . . line 1 Y21U21V21 Y22 Y23U23V23 Y24 . . . . . line 2 Y31U31V31 Y32 Y33U33V33 Y34 . . . . . line 3 Y41U41V41 Y42 Y43U43V43 Y44 . . . . . line 4The missing values may be filled in using filters. Here is an example U12 = (U11 + U13)/2 V12 = (V11 + V13)/2 U14 = (U13 + U15)/2 V14 = (V13 + V15)/2Or you may choose to invent your own filter using appropriate valid neighborhood samples Y11U11V11 Y12U12V12 Y13U13V13 Y14U14V14 . . . . . line1 Y21U21V21 Y22U22V22 Y23U23V23 Y24U24V24 . . . . . line 2 Y31U31V31 Y32U32V32 Y33U33V33 Y34U34V34 . . . . . line 3 Y41U41V41 Y42U42V42 Y43U43V43 Y44U44V44 . . . . . line 4Note the samples that you take to fill in values will change depending on the subsampling parameters. The YUV components can now be converted to RGB space.Scaling with Antialiasing Your output image width and height will change to a new (smaller) value depending on scale factors Sw and Sh. You will need to create the output image by resampling the input image. This can be achieved by inverse mapping all destination pixel indexes [i,j] to their source location indexes. Depending on whether you need to perform antialiasing the destination resampled pixel value can be the value of your inverse mapped source pixel (A=0) or the average of small neighborhood around the inverse mapped source pixel (A=1). To compute the average, you may use a 3×3 kernel.What should you submit ? Your source code, and your project file or makefile, if any, using the submit program. Please do not submit any binaries or data files. We will compile your program and execute our tests accordingly. Along with the program, also submit an electronic document (word, pdf, pagemaker etc format) using the submit program that answers the fore-mentioned analysis questions. You may use any (or all) input images for this analysis.
Write a program to compare the performance of the LRU and the Optimal page replacement algorithms. The program will take a reference string and the number of frames as inputs.Assume the maximum length of a reference string is 20 and there are 5 diffent pages from page 1 to page 5. The reference string can be randomly generated and the number of frames is entered through the keyboard.For example, the system generates a reference string 2 1 3 4 5 2 3 …5 and you enter the number of frames 3. Compare the number of page faults generated by the Optimal and LRU algorithms. Print out the page replacement process and you can see how LRU differs from the optimal.Submission:In order not to lose any files, you’d better zip all your files into a .zip file.Submit your project to TRACS before the deadline. Homework will NOT be accepted through emails. You should write a readme textfile telling the grader how to run your programs. Without this file, it is very likely that your project will not be run properly.
Three students are competing for a scholarship of $4,000. Suppose the scholarship is awarded in a FCFS fashion. Each time each one can get 25% of the available fund.Use three threads to simulate this. Each thread should execute in a loop. When the fund runs out, stop all the threads and terminate the program. And then you add all the money given out, if the total does not add up to $4000, your program is not correct.a. Write the program without considering the mutual exclusion. Run the program several times to show that mutual exclusion is not guaranteed and the result is not correct.b. Write the program again considering the mutual exclusion. Run the program several times to show that mutual exclusion is guaranteed.To make longer execution of threads, use some sleep(n) functions in the program. Experiment with n to choose the best one to show the results.The following is an example. Your results may not be exactly the same.Example of an incorrect result:A=1000 B=750 C=750 B=375 A=375… Finally, the total money given out is not equal to $4000.Example of a correct result:A=1000 B=750 C=563 (round up to the ceiling of the number if the result is not an integer) A=422 C=317 B=237 A=178 A=134 B=100 C=75 B=56 C=42 A=32 C=24 B=18 C=13 C=10 A=8 C=6 B=4 A=3 A=2 B=2 C=1 B=1 C=1 A=1Total given out: 4000Submission:In order not to lose any files, you’d better zip all your files into a .zip file.Submit your project to TRACS before the deadline. Homework will NOT be accepted through emails. You should write a readme textfile telling the grader how to run your programs. Without this file, it is very likely that your project will not be run properly.
In this project, we are going to build a component of a Command and Control (C2C) server that is used to allow agents in a multi-agent system to become aware of each other.In particular, the C2C server should be able to maintain a list of active agents and respond to various actions as issued by the agents. For example, the agents could be a group of UAVs and the C2C server could be a satellite.The agents would need to communicate through the satellite if they are out-of-range of each other. The C2C server will run on a particular port (supplied by a command line argument) and should be able to respond to TCP connections from agents. Agents send various actions to the server to update the information maintained. The agent code is supplied in this assignment and is written in C.An agent can issue one of those actions: 1- #JOIN When the C2C server receives a join request, it will add this agent to its current list of active agents and responds with “$OK”. An agent can only join once before it leaves. If an agent tries to join while it is already an active agent, the C2C server should respond with an error message “$ALREADY MEMBER”2- #LEAVE When the C2C server receives a leave request, it deletes the corresponding agent from its list of active agents and responds with “$OK”. An agent cannot leave if it has not already joined and the server responds with an error message “$NOT MEMEBER” 3- #LISTWhen the C2C server receives a list request, it responds with the list of all active agents (agents that have joined, but not already left). The C2C server can only respond to list actions from active agents (otherwise ignored and no response is given). The list contains the IP address and duration in seconds (how many seconds since an agent joined) for each agent. Each entry should be in the form of . You may assume that each agent has a unique IP. Requests generated from the same IP address are treated as a single agent.4- #LOG When the C2C server receives a log request, it responds with the log file (log.txt) to the agent. Similar to list, only active agents can issue log requests. You can assume that the log requests itself should be logged into the log file before its gets sent to the agent. Note that the log file could be quite large, so make sure not to try to load it into a buffer all at once.The agent takes three arguments in its command line: the C2C server IP, server port and the action string. It sends the action string and writes the response, if any, to the screen. The agent code is listed under resources on TRACS.The agent would connect to the server on its listening port and waits for a response to its actions before it exits. All actions start with a ‘#’ and all responses start with ‘$’ followed by the data/message.The C2C server should be able to listen for actions on the port it is running on and once a request is received, the server responds with the information/confirmation based on its current state (e.g., active list of agents, when they joined and the agent requesting the information) and records its interactions in the log file. Notice that the C2C server will never exit; it continues listening and servicing requests.The C2C needs to maintain a log file the records any information about any given connection along with a time stamp (up to millisecond granularity) and the response sent (if any). You can assume the file is called log.txt. For example: “TIME”: Received a “#JOIN” action from agent “147.26.143.22” “TIME”: Responded to agent “147.26.143.22” with “$OK” “TIME”: Received a “#LIST” action from agent “147.26.12.11” “TIME”: No response is supplied to agent “147.26.12.11” (agent not active)3. Where to start First, you need to get familiar with Internet programming API. This will be based on the material discussed in class.Given the agent application provided, start working on the server part. To test your C2C server, you need to generate multiple actions from different agents by running them from different machines. You can run a number of agents from different terminals, but all of them will have the same IP address and thus would be treated as the same agent. You need to handle different cases such as a “#LEAVE” without joining, a “#LIST” from an inactive agent, among many others.4. Submission • You need to turn in a short design document stating the overall design decisions you made, and the data structures used. • Please provide a single command line to test your code and make sure to provide a working example of the command line.• Please provide the output log file for 2 or 3 agents (using different terminals from different machines such as zeus, eros and your machine) that perform the following actions in that order: 1- Agent 1 joins 2- Agent 2 joins 3- Agent 3 joins 4- Agent 1 issues list 5- Agent 1 leaves 6- Agent 1 issues list 7- Agent 2 leaves 8- Agent 2 leaves 9- Agent 3 issues list 10- Agent 3 issues log5. Notes for future extensions [not required]– In a real-world setting, we will need to add a layer of authentication in which the C2C server can verify that it is really communicating with an agent (as opposed to an attacker) and vice versa. Also, communication should be encrypted between them.Finally, the server should be a multithreaded one, so it can respond to various agents in parallel (for example by using pthreads).
1. Write small c programs.a). The first program “pre.c” should read in a list of student names and their GPAs. To be simple, you can just input the students’ first names. Enter the inputs through the keyboard and display the outputs on the screen. The inputs end when an EOF (generated by Ctrl-D) is encountered. The outputs of the program should display the students whose GPAs are above 3.0.For example, the following are the inputs to “pre.c”.Susan 3.1 John 2.0 David 3.5 Jessica 3.4 Ctrl-D (press the keys to terminate the inputs.)then “pre.c” produces the output: Susan David JessicaNote: an EOF is usually ‘sent’ to a process by hitting a CTRL_D. If you type stty -a on your unix command line, you can get info that tells you which keyboard keys mean what. FYI, in c, to put values to standard_out use printf(). To get values from standard_in use scanf() or getchar().b). The second program “sort.c” reads in a list of student names from the keyboard and displays them in alphabetical order on the screen. Assume the sequence is read until an EOF is encountered.If the inputs are:Susan David Jessica Ctrl-D (press the keys to terminate the inputs.)The outputs should be:David Jessica Susan2. Write a c program to set up a child-TO-parent pipe; the child should ‘exec’ to perform a “pre” process and its output should be connected to the pipe connected to the parent, which should ‘exec’ to perform a “sort” process.3. Write a program to take a UNIX command from the command line and fork() a child to execute it. The command can be a simple command like: $ls or $ps, Or it can be a command with options such as $ls -t -l. Use argc and argv[] in the main function to pass parameters. When the child process is executing the command, the parent process simply waits for the termination of the child process. The process id of the parent and the child should be printed out using getpid() and getppid() functions.Submission:In order not to lose any files, you’d better zip all your files into a .zip file.Submit your project to TRACS before the deadline. Homework will NOT be accepted through emails. You should write a readme textfile telling the grader how to run your programs. Without this file, it is very likely that your project will not be run properly.