当前位置:天才代写 > C++/C代写 > C Processing代写 | Image Processing Homework |CSE 270M

C Processing代写 | Image Processing Homework |CSE 270M

2019-10-24 13:13 星期四 所属: C++/C代写 浏览:48

C Processing代写 This assignment is about implementing your own algorithms for processing images.

CSE 270M – Image Processing Homework – Due: Thursday, October 10, 2019, 11:59pm

Clarification: This assignment is about implementing your own algorithms for processing images.  The Processing language has many methods that do the same things (filter(), rotate(), etc.).  Don’t use any methods that do the processing for you.

 

 

ZIP your submission, which should be your entire Processing sketch folder (not just the files in the folder, but the folder itself).

C Processing代写
C Processing代写

Scoring – 70 points.  

See each problem for its value.  Liberal deductions (up to 25% of the assignment value) for code that is hard to read, poor variable names, lack of comments, and other style issues.  Processing has a keyboard shortcut, Ctrl-T on Windows, Command-T on Macs, that will clean up your source code for you quite a bit.  Press it.  I will charge you 2 points for leaving the pressing to me).

 

Note that each of your filter methods should return a new PImage object, without modifying the PImage object that is passed in as an argument.

 


  1. (10 points)

    Write a PImage soften(PImage src, int strength)method that softens an image by computing the average of a pixel’s color and the colors of its neighboring pixels.

    That is, to compute the new color for a pixel, average the colors of the original pixel and its neighbors (where strength determines how many neighbors).

    The strength refers to the size of the neighborhood of surrounding pixels that will be included.  The greater the strength, the larger the area.  Intuitively, think of a square wrapped around a pixel such that the number of pixels to the right, left, top, and bottom is equal to the strength.  Or, stated another way, with an example, if you use a strength of 3, then imagine a 7 by 7 grid of pixels with your pixel in the middle.

    Or, stated in a fancier way, if the strength is 3, then you should be considering all pixels whose Chebyshev distance to your pixel is less than or equal to 3.  Pixels at or near the border will require special attention.  For example, if you are using a strength of 5, and your pixel is at row 7, column 6, then it is easy to go out 5 in each direction from the center pixel.

    But if you are using a strength of 10, and your center pixel is at row 7, column 6, and you try to move left 10 (or up 6) you will go past the edge of the image.  In those cases, you should still compute the average of all the available pixels whose Chebyshev distance to your pixel is less than or equal to 3

 


  1. (10 points)

    In your soften()method, use millis() to print a measure of the time it takes to soften your image.  Only measure the part of the code that is doing the softening.  In other words, assuming you have a loop where all the calculations are taking place, note the time just before the loop starts, and again immediately after the loop ends, and print the elapsed milliseconds.

    Then, make your soften() method as efficient as possible using techniques from class.  Don’t come up with a different algorithm: you still need to use the algorithm exactly as described above (averaging the colors of surrounding pixels), but find ways to tweak your code so that the algorithm performs as quickly as possible.  (I will, in a sense, grade on a curve, with the most efficient solutions earning the most points.  I will test your code on my own images.)

 


  1. (10 points)

    Write aPImage scramble(PImage src, int xDivs, int yDivs)  method that breaks an image up into rectangles, and then shuffles those rectangles randomly.  xDivs determines the number of horizontal divisions, and yDivs determines the number of vertical divisions.  So, for example, scramble(src, 4, 3) would result in a grid of 12 rectangles (4 columns, 3 rows), and then those rectangles would be scrambled.

 

 

Note that xDivs must divide evenly into the width of the image, and yDivs must divide evenly into the height of the image.  Throw a helpful illegalArgumentException() if xDivs or yDivs is not a good value.  This would be an appropriate exception:

 

IllegalArgumentException: yDivs 7 is not a divisor of the height 300

 


  1. (10 points)

    Write a method PImage bestMatch(PImage src, color[] palette)that returns a new PImage where each pixel in the new image is the color in palette that most closely matches the corresponding pixel in src.

    In other words, imagine you are trying to make a copy of src, but you are limited only to the colors in palette (like, if you were given a box of crayons, and told to use them to reproduce the image).  Find the best matching color in the palette for each pixel.  There are many definitions of “best matching color”, but we will use a straightforward approach: For a given pixel p, compute the Euclidean distance between the R,G,B values of p and the R,G,B values of each color in palette.

    Use the color in palette with the minimum Euclidean distance from p.  Note that Processing has a dist() method that can compute the distance between two 3D points.  An R,G,B color can be thought of as a 3D point, because it has 3 components.

 


  1. (5 points)

    Create a color[] randomPalette(int n)method that creates and returns an array of n random colors.  Modify your bestMatch() method to use the randomPalette() method so that it is easy for your instructor to try various sizes of palettes.

 


  1. (10 points)

    Write a PImage rotate(PImage src, float angle)method that rotates an image a specified number of degrees, about the center of the image.  Note that this will result in an image where some pixels will not have part of the image in it.

 


  1. (10 points)

    Make upat least one additional filter of your own.  Like the other filters, it should take a PImage source, and return a new PImage object, without modifying the original image.  The goal here is originality.  Don’t take an existing filter algorithm and make modifications to it.  Rather, start from scratch to create a filter of your own.

 


  1. (5 points)

    Organize all your work by loading an image and showing a gallery of your results (in rows and columns).  For thesoften() method, call it with several strengths, so that the results can be compared.  So, when you run your program, the user should see a bunch of different versions of the loaded image (along with the time it took for each soften operation).

 

 

最先出自天才代写 cs代写 作业代写 代写c 计算机视觉代写 processing代写 图像处理代写

 

 


天才代写-代写联系方式