CN102682456B - Anti-aliasing straight line drawing method based on non-weighted region sampling - Google Patents
Anti-aliasing straight line drawing method based on non-weighted region sampling Download PDFInfo
- Publication number
- CN102682456B CN102682456B CN201210123982.4A CN201210123982A CN102682456B CN 102682456 B CN102682456 B CN 102682456B CN 201210123982 A CN201210123982 A CN 201210123982A CN 102682456 B CN102682456 B CN 102682456B
- Authority
- CN
- China
- Prior art keywords
- straight line
- sub
- pixel
- display
- pixels
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Landscapes
- Image Generation (AREA)
Abstract
The invention provides an anti-aliasing straight line drawing method based on non-weighted region sampling. The operations on each row, passing through a raster graphic display screen, of the straight line to be drawn can be generalized as follows: (1) determining three display pixels of the current row with nearest distance away from the ideal straight line by a Bresenham algorithm of the drawn straight line, wherein the display pixel with the nearest distance from the straight line certainly has grey scale value, the other two display pixels may have grey scale value, and the rest of display pixels of the current row have no grey scale value; (2) dividing each of the three display pixels into sub-pixels with the number equal to the grey scale level number of the raster display screen; (3) respectively determining two groups of sub-pixels with the nearest distance away from two sides of a rectangle representing the straight line, wherein the two groups of sub-pixels give out the boundary of the coverage area of the rectangle representing the straight line in the current row; (4) respectively carrying out statistics on the number of the sub-pixels, covered by the rectangle region, of the three display pixels; and (5) determining the grey scale value of the display pixels of the current row according to the statistic result. The method is suitable for the raster display screen with multiple grey scale levels, achieves anti-aliasing effect by controlling the slow change of the grey scale value, and is very suitable for the instruments and meters and other fields with higher display quality requirements.
Description
(1) technical field
The present invention relates to a kind of new method of drawing anti-aliasing straight line, belong to computer graphics Anti-aliasing Technology field.
(2) background technology
Along with the develop rapidly of computer graphics techniques, can say that the application of current computer Presentation Function aspect all relates to graph technology to some extent, so the research of computer drawing method also seems more and more important.
Straight line is as forming one of fundamental element of figure, and its method for drafting is the basic content that computer graphics study is maximum.Line generating algorithm in computer graphics typically refers to the method that represents straight line by find a series of discrete pixels nearest apart from straight line on grating display screen.At present, most widely used raster graphic display screen is comprised of the pixel of series of discrete, thereby be finally all able to discrete pixel with the straight line that computing machine generates, shows.Therefore, draw non-level and crenellated phenomena will inevitably appear in non-perpendicular straight line, this because represent continuous quantity and the distortion that produces with discrete magnitude, be just called lose shape (aliasing).For eliminating or the technology of the phenomenon that reduces to lose shape is called anti-aliasing (antialiasing).
It is one of study hotspot of computer graphics that the basic and widespread use of straight line drafting function makes the research for straight line Anti-aliasing Technology field always.
Present stage, straight line Anti-aliasing Technology mainly contains three kinds of methods: improve resolution, the sampling of unweighted area territory and weighting area sampling.
Improve resolution and by the pixel on increase display screen, alleviate the display effect of crenellated phenomena, enhancing straight line, but the method is memory span and the scanning of usining at double obtains good result as cost switching time, therefore will greatly increase the cost of instrument, and the method can only alleviate, and can not eliminate sawtooth problem.
Non-weighting and weighting area sampling all can alleviate and eliminate to a certain extent crenellated phenomena effectively, these two kinds of methods are from the angle of sampling theory, be equivalent to use the wave filter of definite shape, carry out sampling after pre-filtering, therefore the straight line of two kinds of method draftings seems that than directly carry out a straight line that sampling is drawn under equal resolution effect is well a lot of again.
In the various algorithms that use in Anti-aliasing Technology field, the anti-aliasing algorithm of Wu straight line based on area sampling principle is one of method of early use of Anti-aliasing Technology field, though the method can obtain good display effect, the real arithmetics such as but algorithm itself need to do division, round, are difficult to realize with FPGA.And this phenomenon is also the shortcoming place of current numerous algorithms, the present invention is by the characteristic of analysis list pixel wide straight line and propose a kind of simply anti-aliasing straight line rendering algorithm based on the sampling of unweighted area territory, the field that is applicable to display quality to have relatively high expectations in conjunction with Bresenham line algorithm.
(3) summary of the invention
The object of the invention is to propose a kind of anti-aliasing straight line method for drafting based on the sampling of unweighted area territory of easily realizing on FPGA platform, be applicable to the fields such as instrument and meter to showing that smoothness is had relatively high expectations.
Technical scheme of the present invention is that the straight line to drawing is all taked following operation through each row display element of grating display screen: first, by drawing the Bresenham algorithm of straight line, determine three display elements that current column distance ideal line is nearest, the nearest display element of its middle distance straight line must have gray-scale value, two other display element may have gray-scale value, when all the other display elements of prostatitis do not have gray-scale value; Then, each in these three display elements is divided into the sub-pixel that quantity is equal to grating display screen number of greyscale levels; Then, determine the coverage in Dang prostatitis, rectangular area; Finally, add up respectively the quantity of the sub-pixel that three display elements are covered by rectangular area, according to statistics acquired results, determine the gray-scale value when prostatitis display element.
Below technical scheme of the present invention is described further.
The present invention proposes a kind of anti-aliasing straight line method for drafting based on the sampling of unweighted area territory, can be used for showing that smoothness requires the higher fields such as instrument and meter; Each row display element of process all carries out the operation of following steps on raster graphic display screen to it is characterized in that straight line to drawing (situation of slope between 0~1 being only discussed, can be by X-axis and Y-axis are exchanged and processed for other situation here):
Step 1: determine when prostatitis three display elements nearest with the ideal line that will draw;
Step 2: three display elements that step 1 is obtained carry out even partition, obtains some sub-pixels;
Step 3: determine that the rectangle with Yi Ge unit's pixel width that represents straight line is in the coverage when prostatitis;
Step 4: three display elements that statistic procedure one is obtained are respectively by the quantity of the sub-pixel that rectangle covered;
Step 5: the gray-scale value of three display elements that determining step one is obtained.
In step 1, (establishing coordinate is (x to utilize the nearest display element of ideal line that classical Bresenham line algorithm determines that current column distance will draw, y)), owing to representing that the width of the rectangle of drawn straight line is unit display element, therefore in these row, may there is the coordinate of two other display element of gray-scale value to be respectively (x, y+1) and (x, y-1).
Step 2, obtain in step 1 three display elements are cut apart, and each display element is evenly divided into the sub-pixel that quantity is equal to display screen grey progression, for example, for the display screen of 64 gray levels, three display elements are divided into 8 * 8 sub-pixels of square that area is equal.
Step 3, working as prostatitis, by Bresenham line algorithm, determine respectively the two group sub-pixels nearest with two limits (being parallel to rectangle axis) of rectangle that represent straight line, wherein the quantity of every group of sub-pixel equal by a display element cut apart rear generation sub-pixel columns (for example, display screen for 64 gray levels, the quantity of every group of sub-pixel is 8), these two groups of sub-pixels provide the border of the rectangle institute coverage that represents straight line.
In step 4, add up respectively each height in three display elements and be listed as the quantity that sub-pixel is covered by rectangular area, then add up the sum of the sub-pixel that three display elements are covered by rectangular area.
In step 5, according to the result of step 4 statistics, the gray-scale value of three display elements equals respectively by the quantity of the sub-pixel that straight line covered, to be subtracted 1 separately; Distinguishingly, if the capped sub-pixel quantity of certain display element is 0, think that the gray-scale value of this display element is 0.
(4) accompanying drawing explanation
Fig. 1 is the anti-aliasing Line Algorithm process flow diagram of drafting that the present invention proposes.
Fig. 2 is the slope that will draw ideal line and three the nearest display elements of this straight line of current column distance between 0~1, and each display element represents with a square.
Fig. 3 provides each in three display elements is evenly divided into the schematic diagram of 8 * 8 sub-pixels (number of grey levels of supposing display screen is 64).
Fig. 4 is two limit and three display element position distribution situations after over-segmentation that represents the rectangle of straight line.
Fig. 5 is given in when prostatitis (being divided into eight son row) and determines with two limits of rectangle at a distance of two groups of nearest sub-pixels through Bresenham algorithm.
Fig. 6 provides three display elements pixel separately by rectangular area coverage condition, wherein blue region represents the capped situation of the sub-pixel of display element topmost, yellow area is the capped situation of middle display element, and violet region is for working as the prostatitis capped situation of display element bottom.
(5) embodiment
Suppose that the number of greyscale levels that raster graphic display screen adopts is 64, below in conjunction with accompanying drawing, technical scheme of the present invention is described in further detail.
The present invention has designed a kind of simply anti-aliasing straight line method for drafting based on Nonuniform Domain Simulation of Reservoir sampling, mainly adopts Integral additive operation, meets the hard-wired feature of FPGA.As shown in Figure 1, the ideal line of the slope that will draw that the Fig. 2 of now take provides between 0~1 is that instantiation describes implementation step in detail to algorithm flow chart of the present invention.
(1) when prostatitis, determining three display elements nearest with ideal line
Bresenham algorithm is most popular volume algorithm of linear scan conversion in field of Computer Graphics, and this algorithm is simply efficient, can determine fast when prostatitis and the nearest display element of air line distance.
The present invention determines when prostatitis and nearest three display elements of ideal line by this algorithm, concrete steps can be divided into two steps: first, by Bresenham algorithm, determine when prostatitis and the nearest display element of air line distance, the square that this display element corresponding diagram 2 mediates; Then, the upper and lower pixel of this display element is two other that will find may the display element of gray-scale value.For convenience of description, table 1 provides with ideal line at a distance of nearest three display elements and their conventional letters separately.
Three display elements of table 1 and conventional letter separately
Three pixel relative positions | Topmost | Middle | Bottom |
Conventional letter | Pixel_A | Pixel_B | Pixel_C |
(2) even partition display element
The groundwork of this step is that three display elements are all carried out to same cutting operation, makes each display element produce some sub-pixels, and the quantity of sub-pixel equates with the number of greyscale levels of current raster graphic display screen.For example, concerning thering is the display screen of 64 gray shade scales, each display element can be cut apart by Fig. 3, after cutting apart, be obtained 8 * 8 sub-pixels.For other gray shade scale, can to display element, cut apart by similar approach.
(3) determine rectangle coverage
As shown in Figure 4, the rectangle that represents straight line is that two limits by rectangle limit in the coverage when prostatitis, therefore can set about finding from border the overlay area of rectangle.
Owing to will work as prostatitis in step (2), be evenly divided into 8 son row, therefore determine that the coverage of rectangle can be by finding respectively the two group sub-pixels nearest apart from two limits of rectangle in these 8 son row, wherein every group comprises 8 sub-pixels.Consider the superiority of Bresenham algorithm, finding two groups of sub-pixels can complete by this algorithm.
Fig. 5 provides satisfactory 16 sub-pixels, and these 16 sub-pixels provide rectangle on the border when overlay area, prostatitis.
(4) the sub-pixel number that three display elements of statistics are capped separately
Owing to comprising 8 son row when prostatitis, therefore this statistic processes can be divided into 8 stages and completes: first, be to determine by Bresenham algorithm the region that two limits of rectangle limit at first son row, and add up respectively three display elements at the capped sub-pixel number of current son row; Then, the sub-pixel number that three display elements of the statistics that uses the same method are capped at second son row, and cumulative with last sub-row statistics ... until the 8th son row statistics finishes.
Fig. 6 provides three display elements by rectangular area coverage condition, and wherein blue region provides the capped situation of display element Pixel_A, and yellow area provides the capped situation of display element Pixel_B, and violet region provides the capped situation of display element Pixel_C.Table 2 has provided the statistics when three the display element coating lid pixel quantity in prostatitis.
Table 2 display element coating lid pixel statistical conditions
Display element | Pixel_A | Pixel_B | Pixel_C |
Coating lid pixel number | 2 | 62 | 8 |
(5) determine when prostatitis display element gray-scale value
According to the statistics of table 2, directly provide the gray-scale value when all display elements in prostatitis, as shown in table 3.
Table 3 is when all display element gray-scale values in prostatitis
When prostatitis pixel | Pixel_A | Pixel_B | Pixel_C | All the other |
Gray-scale value | 1 | 61 | 7 | 0 |
Claims (1)
1. the anti-aliasing straight line method for drafting based on the sampling of unweighted area territory, is applicable to the instrument field to showing that smoothness is had relatively high expectations; It is characterized in that straight line each the row display element of process on raster graphic display screen to drawing all carries out the operation of following steps, the situation for the slope of straight line between 0~1, can be by X-axis and Y-axis be exchanged to processing for other situation:
Step 1: determine when prostatitis three display elements nearest with the ideal line that will draw;
Step 2: three display elements that step 1 is obtained carry out even partition, obtains some sub-pixels;
Step 3: determine that the rectangle with Yi Ge unit's pixel width that represents straight line is in the coverage when prostatitis;
Step 4: three display elements that statistic procedure one is obtained are respectively by the quantity of the sub-pixel that rectangle covered;
Step 5: the gray-scale value of three display elements that determining step one is obtained;
Wherein, step 1 is specifically carried out as follows: utilize classical Bresenham line algorithm to determine three nearest display elements of ideal line that current column distance will be drawn, establish coordinate and be respectively (x, y), (x, y+1) and (x, y-1);
Wherein, step 2 is specifically carried out as follows: obtain in step 1 three display elements are cut apart, and each display element is evenly divided into the sub-pixel that quantity is equal to display screen grey progression;
Wherein, step 3 is specifically carried out as follows: working as prostatitis, by Bresenham line algorithm, determine respectively the two group sub-pixels nearest with two back gauges of rectangle that represent straight line, these two limits are parallel to rectangle axis, and wherein the quantity of every group of sub-pixel equals a display element to cut apart the columns of the sub-pixel of rear generation;
Wherein, step 4 is specifically carried out as follows: add up respectively each height in three display elements and be listed as the quantity that sub-pixel is covered by rectangular area, then add up the sum of the sub-pixel that three display elements are covered by rectangular area;
Wherein, step 5 is specifically carried out as follows: according to the result of step 4 statistics, the gray-scale value of three display elements equals respectively by the quantity of the sub-pixel that straight line covered, to be subtracted 1 separately.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210123982.4A CN102682456B (en) | 2012-04-25 | 2012-04-25 | Anti-aliasing straight line drawing method based on non-weighted region sampling |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210123982.4A CN102682456B (en) | 2012-04-25 | 2012-04-25 | Anti-aliasing straight line drawing method based on non-weighted region sampling |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102682456A CN102682456A (en) | 2012-09-19 |
CN102682456B true CN102682456B (en) | 2014-07-16 |
Family
ID=46814321
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210123982.4A Expired - Fee Related CN102682456B (en) | 2012-04-25 | 2012-04-25 | Anti-aliasing straight line drawing method based on non-weighted region sampling |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102682456B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103617640B (en) * | 2013-11-13 | 2016-07-20 | 南京航空航天大学 | A kind of bargraphs anti-aliasing display packing |
CN105225258B (en) * | 2015-09-01 | 2018-02-06 | 南京航空航天大学 | A kind of round anti-aliasing display methods |
CN110335215B (en) * | 2019-07-09 | 2021-07-02 | 格兰菲智能科技有限公司 | Image anti-aliasing method and image anti-aliasing device |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101699518A (en) * | 2009-10-30 | 2010-04-28 | 华南理工大学 | Method for beautifying handwritten Chinese character based on trajectory analysis |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6337686B2 (en) * | 1998-01-07 | 2002-01-08 | Ati Technologies Inc. | Method and apparatus for line anti-aliasing |
-
2012
- 2012-04-25 CN CN201210123982.4A patent/CN102682456B/en not_active Expired - Fee Related
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101699518A (en) * | 2009-10-30 | 2010-04-28 | 华南理工大学 | Method for beautifying handwritten Chinese character based on trajectory analysis |
Also Published As
Publication number | Publication date |
---|---|
CN102682456A (en) | 2012-09-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11276233B2 (en) | Rendering in computer graphics systems | |
KR100243174B1 (en) | Apparatus and method of generating sub-pixel mask | |
US20080238947A1 (en) | System and method for non-linear magnification of images | |
CN101911123B (en) | Graphic drawing device and graphic drawing method | |
CN101887592B (en) | Drawing method for vector graphic map symbols | |
JP2010113624A (en) | Device and method for drawing bezier curve and program | |
Št et al. | Connected component labeling in CUDA | |
CN102682456B (en) | Anti-aliasing straight line drawing method based on non-weighted region sampling | |
CN101356548A (en) | Vector graphics anti-distortion | |
CN102682424B (en) | Image amplification processing method based on edge direction difference | |
JP3786995B2 (en) | Method and apparatus for calculating texel values for displaying a texture on an object | |
CN103617640A (en) | Line pattern anti-aliasing display method | |
CN107369190B (en) | Rubble-based thermodynamic diagram accelerated rendering method | |
CN111145286A (en) | Point nine picture mapping drawing method for edge calculation scene based on GPU | |
Mamatha et al. | Antialiased digital pixel plotting for raster scan lines using area evaluation | |
KR19980079591A (en) | Graphics processing unit | |
CN106651819A (en) | Image processing method and apparatus | |
CN110807113B (en) | Non-iterative elimination method for rectangular primitive overlap in visual layout | |
CN106504178B (en) | Image processing method and device | |
CN106873875B (en) | Graphical display method and device of data and computing equipment | |
CN102074004A (en) | Method and device for determining type of barrier of spatial entity | |
CN105225258B (en) | A kind of round anti-aliasing display methods | |
CN106485767A (en) | A kind of method and device of drafting symbol | |
CN113763333B (en) | Sub-pixel positioning method, positioning system and storage medium | |
CA2972449C (en) | Display of intensity profile discs |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20140716 Termination date: 20150425 |
|
EXPY | Termination of patent right or utility model |