Computer Graphics (ii) output graphic element _4_ parallel line drawing algorithm

Source: Internet
Author: User
Tags integer division

Parallel line Drawing algorithm

Originally in Word there is a lower-right number, an editor in the CSDN editor will not be.


the segment generation algorithm discussed above determines the pixel position in sequence. With parallel computers, the pixel position of a segment can be obtained by splitting the computation into multiple processors that are available. One solution to the partitioning problem is to put an existing sequential algorithm on multiple processors. We can also look for other treatments so that pixel locations can be efficiently computed in parallel. In designing parallel algorithms, it is important to consider balancing the processing load between available processors.
Given NP processors, we can create parallel Bresenham line-drawing algorithms by dividing segments into NP sub-segments and generating segments simultaneously in each sub-segment. For segments with a slope of 0 < M < 1.0 and a left endpoint coordinate position (XO,YO), we split the segment along the positive x direction. The distance between the starting X position of the adjacent segment can be calculated as

where x is the horizontal width of the segment, the value of the segment horizontal width XP is calculated using integer division. Segment and processor from 0, 1, 2 until np-1 number, you can calculate the beginning of the K-segment, the coordinates are

For example, x = 15, and with NP = 4 processors, the horizontal width of the segment is 4, and the initial x values for each segment are XO, XO + 4, XO +8, XO + 12. For this segmentation strategy, in some cases the last (rightmost) sub-segment is smaller than the other segment. In addition, if the end point of a segment is not an integer, rounding errors cause the length of the line to produce segments of different widths. In order to use the Bresenham algorithm for each segment, you need to have the initial value of the y-coordinate and the initial values of the decision parameters for each segment. The change in the y direction of the segment y, can be calculated from the segment slope m and the segmented width XP:

Then, the starting y-coordinate of section K is

The initial decision parameters of the Bresenham algorithm at the beginning of section K are obtained from the equation (3.14).

Each processor then computes the pixel position on the specified segment using the initial decision parameter value and the starting coordinate (Xk,yk) of the segment. We can also simplify the floating-point operation in the calculation of YK and PK start values to integer operations by replacing m = y/x and rearranging the items. By segmenting the segments in the y direction and calculating the starting x value of the segments, you can extend the parallel Bresenham algorithm to segments with a slope greater than 1.0. For a negative slope, the coordinate value can be incremented in one direction, while the other side is decremented upward.
Another way to establish parallel algorithms for raster systems is to assign a set of screen pixels to each processor. Each processor can be assigned to a pixel within a screen area as long as there is a sufficient number of processors. This method can be ported to a segment display by assigning a single pixel to a processor in the range of line coordinates and calculating the distance of the pixel from the segment. The number of pixels in the bounding box of the segment is X. y, (see Figure 3.13). In Figure 3.13, the vertical distance d from the segment to the pixel at coordinates (x, y) can be obtained using the following calculation:

which

And

Once the constants A, B, and C of the line segment are estimated, each processor needs only two multiplication and two additions to calculate the pixel distance d. If D is less than the specified segment weight parameter, a pixel is drawn.

In addition to dividing the screen into a single pixel, we can assign one scan line or one column of pixels per processor by the slope of the segment. Each processor then calculates the intersection of the segment with the horizontal or vertical column assigned to the processor. For Slope |m| < 1.0 segments, each processor will simply solve y from the linear equation with the given x value. For segments with a slope value greater than 1.0, the processor solves x from the linear equation based on the given scan line y value. Although this direct method is computationally slow in sequential algorithmic machines, this algorithm can be accomplished efficiently by using multiprocessor.


Computer Graphics (ii) output graphic element _4_ parallel line drawing algorithm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.