关于图像识别:COMP4033-图形算法

3次阅读

共计 1828 个字符,预计需要花费 5 分钟才能阅读完成。

COMP4033 Project 1 – Algorithms for Drawing 2D Primitives (10%)
Due: 11:59pm, 27 March 2021
Complete the following two exercises by writing a Java program for each:

  1. Replace the drawLine method based on Bresenham’s algorithm and listed almost at the end of Section
    4.1 with an even faster version that benefits from the symmetry of the two halves of the line. For
    example, with endpoints P and Q satisfying Equation (4.1), and using the integer value xMid halfway
    between xP and xQ, we can let the variable x run from xP to xMid and also use a variable x2, which at
    the same time runs backward from xQ to xMid. In each iteration of the loop, x is increased by 1 and x2
    is decreased by 1. Note that there will be either one point or two points in the middle of the line,
    depending on the number of pixels to be plotted being odd or even. Be sure that no pixel of the line is
    omitted and that no pixel is put twice on the screen. To test the latter, you can use XOR mode so that
    writing the same pixel twice would have the same effect as omitting a pixel.
  2. Extend the program in Q1 to handle lines at any angle, call it “FasterBres”, and take two endpoints
    from the mouse input. The purpose of this part is to compare the speed of FasterBres and the standard
    Bresenham algorithm. So you add the standard Bresenham algorithm into your program such that both
    your FasterBres and the standard one will draw the same line. Make sure each line is drawn by the two
    algorithms as two identical lines (so you may be unable to distinguish on the screen). Your program
    should finally display the total counts for both algorithms in such a form: “FasterBres: N cycles;
    Bresenham: M cycles.”, where N and M are the total counts for the corresponding algorithms.
    Q1 and Q2 could be in a single program, in that case, you should state clearly as comments on top of
    your program which parts have been accomplished and which parts do not work. Ideally, you should
    also explain how your program is implemented as comments on top of your program.
    Put the 2 Java source programs in a ZIP file and name it as“Ass2_1234567890″ (replace
  3. with your student ID number). Submit your ZIP file through iSpace before the due
    time. Late submissions will NOT be accepted.
正文完
 0