CN111028140B - Method for realizing rectangular scaling and overturning of GPU pixels - Google Patents
Method for realizing rectangular scaling and overturning of GPU pixels Download PDFInfo
- Publication number
- CN111028140B CN111028140B CN201911125560.9A CN201911125560A CN111028140B CN 111028140 B CN111028140 B CN 111028140B CN 201911125560 A CN201911125560 A CN 201911125560A CN 111028140 B CN111028140 B CN 111028140B
- Authority
- CN
- China
- Prior art keywords
- new
- line
- pixels
- scaling
- row
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 12
- 238000005070 sampling Methods 0.000 claims abstract description 27
- 230000003044 adaptive effect Effects 0.000 claims description 3
- 230000000694 effects Effects 0.000 abstract description 3
- 230000006870 function Effects 0.000 abstract description 3
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/18—Image warping, e.g. rearranging pixels individually
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/40—Scaling of whole images or parts thereof, e.g. expanding or contracting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/60—Rotation of whole images or parts thereof
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20112—Image segmentation details
- G06T2207/20132—Image cropping
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
- Controls And Circuits For Display Device (AREA)
Abstract
The invention relates to the technical field of computer graphics, in particular to a method for realizing scaling and overturning of a GPU pixel rectangle, which comprises the following steps: 1) Adaptively calculating new graph clipping: 2) Sampling of row pixels: 3) And selecting row pixels. The invention solves the problem of rectangular scaling and overturning of the GPU pixels, and comprises the steps of carrying out self-adaptive cutting according to the video memory, reducing the operation amount to the greatest extent on the premise of not losing the effect, and greatly improving the hardware performance of the GPU. The invention realizes the functions of arbitrarily amplifying, reducing and turning the image aiming at the support of the OpenGL API (glPixelZoom ()).
Description
Technical Field
The invention belongs to the technical field of computer graphics, and relates to a method for realizing scaling and overturning of a GPU pixel rectangle.
Background
In a graphics processor chip (GPU) design, the image pipeline of the GPU includes pixel storage, transfer operations, and scaling flip, while the glPixelZoom () function defined by the OpenGL API supports arbitrary zooming in, zooming out, and flipping of the image, the algorithm of the image scaling flip is not defined. When the image is relatively large, if the calculation amount of the algorithm is large, the performance of the GPU is seriously degraded. How to improve the GPU performance without losing any scaling and overturning effect of any multiple of any image is a technical problem to be solved.
Disclosure of Invention
The invention aims to provide a method for realizing scaling and overturning of a GPU pixel rectangle.
The technical scheme of the invention is as follows:
the method for realizing the scaling and overturning of the GPU pixel rectangle comprises the following steps:
1) Adaptively calculating new graph clipping: calculating the actual position and the range of the new image in the video memory after scaling and overturning according to the video memory, and adaptively cutting the new image;
2) Sampling of row pixels: sampling and scaling each row of pixels of the original image according to the configuration of scaling and overturning to generate new rows of pixels;
3) Selection of row pixels: calculating a scaled line number according to the scaled and flipped configuration and the line number of the generated new line pixel in the original image, and further selecting the generated new line pixel by comparing the scaled line number with the line number to be drawn of the new image.
Further, the step 1) includes the following steps:
1.1 Calculating a new image position:
calculating the drawing range of the new image according to the original width and height of the image and the parameters of scaling and overturning;
1.2 Setting drawing coordinates:
respectively judging original drawing coordinates of the new image, and if the original drawing coordinates are smaller than the boundary, assigning 0 to the drawing coordinates in the corresponding direction; otherwise, the drawing coordinates are the same as the original drawing coordinates;
1.3 Adaptive new graph clipping:
according to the starting and ending positions of the new image actually drawn in the display memory in the row direction and the column direction, 6 situations exist in the new image and the display memory in each direction, the new image is classified as the new image is completely outside the display memory, a unidirectional part is outside the display memory, the unidirectional part is completely inside the display memory, 12 positional relations are shared in the x direction and the y direction, the cutting range of the self-adaptive display memory of the new image under each relation is calculated respectively, and the starting and ending rows and columns are obtained.
1.4 A line buffer is established:
a line buffer 0 and a line buffer 1 are established and initialized to 0 for storing new line pixels with complete scaling flip.
Further, the step 2) includes the following steps:
2.1 Line buffer copy):
copying pixels of line buffer 0 to line buffer 1;
2.2 Pixel sampling:
calculating the scaling factor of each row of pixels, reversely pushing the position of the sampling pixels in the original pixel row according to the pixel serial number of the new row and the scaling factor, reading, and sequentially writing the read sampling pixels into a row buffer zone 0;
2.3 Calculating coordinates:
calculating new coordinates of the sampling pixels in the video memory according to the overturn configuration, the drawing coordinates and the new line pixel serial numbers;
wherein the new line pixel sequence number indicates the position of the sampling pixel in the new line.
Further, the step 3) includes the following steps:
3.1 Calculating a scaled line number):
calculating a scaled line number and a line number of the last line of the new line pixels generated in the original image according to the scaling and overturning configuration, and if the scaled line number is smaller than the line number to be drawn of the new image, continuing to sample the line pixels in the step 2), and starting scaling and overturning of the new line pixels; otherwise, calculating the average value of the scaled line number and the line number of the previous line after scaling;
3.2 Selecting a new row of pixels):
comparing the line number to be drawn of the new map with the average value calculated in step 3.1), and if the line number is smaller than the average value, selecting the pixel line of the line buffer area 1 by the new map; otherwise, the new map selects the pixel row of row buffer 0;
3.3 Updating coordinates:
updating the new coordinates of the pixel rows in the video memory according to the configuration of scaling and overturning, the drawing coordinates and the row numbers to be drawn of the new drawing, adding 1 to the row numbers to be drawn of the new drawing, and finishing the scaling and overturning of the GPU pixel rectangles if all the rows of the image are processed; otherwise, go to step 2) to sample the row pixels of the next row.
The invention has the beneficial effects that:
the invention solves the problem of rectangular scaling and overturning of the GPU pixels, and comprises the steps of carrying out self-adaptive cutting according to the video memory, reducing the operation amount to the greatest extent on the premise of not losing the effect, and greatly improving the hardware performance of the GPU. The invention realizes the functions of arbitrarily amplifying, reducing and turning the image aiming at the support of the OpenGL API (glPixelZoom ()).
Drawings
FIG. 1 is a flow chart of an algorithm of the present invention;
fig. 2 is a positional relationship diagram of the new image and the video memory after scaling and flipping, which is described in claim 2.
Detailed Description
The technical scheme of the invention is clearly and completely described below with reference to the accompanying drawings and the specific embodiments. It is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments, and that all other embodiments obtained by a person skilled in the art without making creative efforts based on the embodiments in the present invention are within the protection scope of the present invention.
The invention provides a method for realizing scaling and overturning of a GPU pixel rectangle, which comprises the following steps:
1) Adaptively calculating new graph clipping: calculating the actual position and the range of the new image in the video memory after scaling and overturning according to the video memory, and adaptively cutting the new image;
1.1 Calculating a new image position:
calculating the drawing range of the new image according to the original width and height of the image and the parameters of scaling and overturning;
1.2 Setting drawing coordinates:
respectively judging original drawing coordinates of the new image, and if the original drawing coordinates are smaller than the boundary, assigning 0 to the drawing coordinates in the corresponding direction; otherwise, the drawing coordinates are the same as the original drawing coordinates;
1.3 Adaptive new graph clipping:
according to the starting and ending positions of the new image actually drawn in the display memory in the row direction and the column direction, 6 situations exist in the new image and the display memory in each direction, the new image is classified as the new image is completely outside the display memory, a unidirectional part is outside the display memory, the unidirectional part is completely inside the display memory, 12 positional relations are shared in the x direction and the y direction, the cutting range of the self-adaptive display memory of the new image under each relation is calculated respectively, and the starting and ending rows and columns are obtained.
1.4 A line buffer is established:
a line buffer 0 and a line buffer 1 are established and initialized to 0 for storing new line pixels with complete scaling flip.
2) Sampling of row pixels: sampling and scaling each row of pixels of the original image according to the configuration of scaling and overturning to generate new rows of pixels;
2.1 Line buffer copy):
copying pixels of line buffer 0 to line buffer 1;
2.2 Pixel sampling:
calculating the scaling factor of each row of pixels, reversely pushing the position of the sampling pixels in the original pixel row according to the pixel serial number of the new row and the scaling factor, reading, and sequentially writing the read sampling pixels into a row buffer zone 0;
2.3 Calculating coordinates:
calculating new coordinates of the sampling pixels in the video memory according to the overturn configuration, the drawing coordinates and the new line pixel serial numbers;
wherein the new line pixel sequence number indicates the position of the sampling pixel in the new line.
3) Selection of row pixels: calculating a scaled line number according to the scaled and flipped configuration and the line number of the generated new line pixel in the original image, and further selecting the generated new line pixel by comparing the scaled line number with the line number to be drawn of the new image:
3.1 Calculating a scaled line number):
calculating a scaled line number and a line number of the last line of the new line pixels generated in the original image according to the scaling and overturning configuration, and if the scaled line number is smaller than the line number to be drawn of the new image, continuing to sample the line pixels in the step 2), and starting scaling and overturning of the new line pixels; otherwise, calculating the average value of the scaled line number and the line number of the previous line after scaling;
3.2 Selecting a new row of pixels):
comparing the line number to be drawn of the new map with the average value calculated in step 3.1), and if the line number is smaller than the average value, selecting the pixel line of the line buffer area 1 by the new map; otherwise, the new map selects the pixel row of row buffer 0;
3.3 Updating coordinates:
updating the new coordinates of the pixel rows in the video memory according to the configuration of scaling and overturning, the drawing coordinates and the row numbers to be drawn of the new drawing, adding 1 to the row numbers to be drawn of the new drawing, and finishing the scaling and overturning of the GPU pixel rectangles if all the rows of the image are processed; otherwise, go to step 2) to sample the row pixels of the next row.
Examples:
the present invention will be described in further detail with reference to fig. 1-2.
A method for realizing rectangular scaling and overturning of GPU pixels comprises the following steps:
step 1, adaptively calculating new image cutting, firstly calculating the position of a new image according to the configuration of width and height of an original image and scaling overturning, then respectively judging the original drawing coordinates of the new image, and if the original drawing coordinates are smaller than a boundary, assigning 0 to the drawing coordinates in the corresponding direction; otherwise, the drawing coordinates are the same as the original drawing coordinates. The initial and final positions of the new image actually drawn in the video memory are calculated according to the comparison between the new image position and the video memory range, 6 situations exist between the new image and the video memory in each direction, and 12 positional relations are totally obtained, as shown in fig. 2. Finally, a line buffer 0 and a line buffer 1 are established and initialized to 0 for storing new line pixels after scaling flip is completed.
Step 2, sampling the pixels of the row,
firstly, copying pixels of a line buffer area 0 to a line buffer area 1, then calculating a scaling factor of each line of pixels, reversely pushing the position of sampling pixels in an original pixel line according to a new line of pixel serial numbers and the scaling factor, reading, and sequentially writing the read sampling pixels into the line buffer area 0. Finally, calculating new coordinates of the sampling pixels in the video memory according to the overturn configuration, the drawing coordinates and the new line pixel serial numbers; wherein the new line pixel sequence number indicates the position of the sampling pixel in the new line.
Step 3, selecting row pixels, namely calculating a scaled row number and a row number of the previous row scaled according to the scaling and overturning configuration and the generated row number of the new row pixels in the original image, and if the scaled row number is smaller than the row number to be drawn of the new image, continuing to sample the row pixels in step 2, and starting the scaling and overturning of the new row pixels; otherwise, calculating the average value of the scaled line number and the line number of the previous line after scaling. Then, comparing the line number to be drawn of the new image with the calculated average value, and if the line number is smaller than the average value, selecting the pixel line of the line buffer area 1 by the new image; otherwise, the new map selects the pixel row of row buffer 0. Finally, updating new coordinates of pixel rows in a video memory according to the configuration of scaling and overturning, the drawing coordinates and the row numbers to be drawn of the new image, adding 1 to the row numbers to be drawn of the new image, and finishing the scaling and overturning of the GPU pixel rectangles if all the rows of the image are processed; otherwise, go to step 2 to sample the row pixels of the next row.
Claims (3)
1. A method for realizing rectangular scaling and overturning of GPU pixels is characterized by comprising the following steps: the method comprises the following steps:
1) Adaptively calculating new graph clipping: calculating the actual position and the range of the new image in the video memory after scaling and overturning according to the video memory, and adaptively cutting the new image;
2) Sampling of row pixels: sampling and scaling each row of pixels of the original image according to the configuration of scaling and overturning to generate new rows of pixels;
3) Selection of row pixels: calculating scaled line number according to the scaling and turning configuration and the line number of the generated new line pixel in the original image, comparing the scaled line number with the line number to be drawn of the new image, further selecting the generated new line pixel,
said step 2) comprises the steps of:
2.1 Line buffer copy):
copying pixels of line buffer 0 to line buffer 1;
2.2 Pixel sampling:
calculating the scaling factor of each row of pixels, reversely pushing the position of the sampling pixels in the original pixel row according to the pixel serial number of the new row and the scaling factor, reading, and sequentially writing the read sampling pixels into a row buffer zone 0;
2.3 Calculating coordinates:
calculating new coordinates of the sampling pixels in the video memory according to the overturn configuration, the drawing coordinates and the new line pixel serial numbers;
wherein the new line pixel sequence number indicates the position of the sampling pixel in the new line.
2. The method for implementing the GPU pixel rectangular scaling flip according to claim 1, wherein: the step 1) comprises the following steps:
1.1 Calculating a new image position:
calculating the drawing range of the new image according to the original width and height of the image and the parameters of scaling and overturning;
1.2 Setting drawing coordinates:
respectively judging original drawing coordinates of the new image, and if the original drawing coordinates are smaller than the boundary, assigning 0 to the drawing coordinates in the corresponding direction; otherwise, the drawing coordinates are the same as the original drawing coordinates;
1.3 Adaptive new graph clipping:
according to the starting and ending positions of a new image actually drawn in the display memory in the row direction and the column direction, 6 conditions exist in the new image and the display memory in each direction, the new image is classified as being completely outside the display memory, a single-direction part is outside the display memory, the single direction part is completely inside the display memory, 12 positional relations are shared in the x direction and the y direction, and the cutting range of the self-adaptive display memory of the new image under each relation is calculated respectively;
1.4 A line buffer is established:
a line buffer 0 and a line buffer 1 are established and initialized to 0 for storing new line pixels with complete scaling flip.
3. The method for implementing the GPU pixel rectangular scaling flip according to claim 1, wherein: said step 3) comprises the steps of:
3.1 Calculating a scaled line number):
calculating a scaled line number and a line number of the last line of the new line pixels generated in the original image according to the scaling and overturning configuration, and if the scaled line number is smaller than the line number to be drawn of the new image, continuing to sample the line pixels in the step 2), and starting scaling and overturning of the new line pixels; otherwise, calculating the average value of the scaled line number and the line number of the previous line after scaling;
3.2 Selecting a new row of pixels):
comparing the line number to be drawn of the new map with the average value calculated in step 3.1), and if the line number is smaller than the average value, selecting the pixel line of the line buffer area 1 by the new map; otherwise, the new map selects the pixel row of row buffer 0;
3.3 Updating coordinates:
updating the new coordinates of the pixel rows in the video memory according to the configuration of scaling and overturning, the drawing coordinates and the row numbers to be drawn of the new drawing, adding 1 to the row numbers to be drawn of the new drawing, and finishing the scaling and overturning of the GPU pixel rectangles if all the rows of the image are processed; otherwise, go to step 2) to sample the row pixels of the next row.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911125560.9A CN111028140B (en) | 2019-11-18 | 2019-11-18 | Method for realizing rectangular scaling and overturning of GPU pixels |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911125560.9A CN111028140B (en) | 2019-11-18 | 2019-11-18 | Method for realizing rectangular scaling and overturning of GPU pixels |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111028140A CN111028140A (en) | 2020-04-17 |
CN111028140B true CN111028140B (en) | 2023-06-13 |
Family
ID=70200316
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911125560.9A Active CN111028140B (en) | 2019-11-18 | 2019-11-18 | Method for realizing rectangular scaling and overturning of GPU pixels |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111028140B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW200802181A (en) * | 2006-06-16 | 2008-01-01 | Sonix Technology Co Ltd | System and method for rotating 2D image |
CN101179671A (en) * | 2006-11-10 | 2008-05-14 | 上海奇码数字信息有限公司 | Image scaling device and image scaling method |
CN101520887A (en) * | 2009-03-30 | 2009-09-02 | 北京中星微电子有限公司 | Image zooming method, device and chip |
CN101950523A (en) * | 2010-09-21 | 2011-01-19 | 上海大学 | Adjustable rectangular window image scaling method and device |
JP2014034129A (en) * | 2012-08-07 | 2014-02-24 | Ricoh Co Ltd | Information processing device, information processing method, system, and program |
CN104461439A (en) * | 2014-12-29 | 2015-03-25 | 联想(北京)有限公司 | Information processing method and electronic equipment |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050249435A1 (en) * | 2004-05-06 | 2005-11-10 | Rai Barinder S | Apparatuses and methods for rotating an image |
-
2019
- 2019-11-18 CN CN201911125560.9A patent/CN111028140B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW200802181A (en) * | 2006-06-16 | 2008-01-01 | Sonix Technology Co Ltd | System and method for rotating 2D image |
CN101179671A (en) * | 2006-11-10 | 2008-05-14 | 上海奇码数字信息有限公司 | Image scaling device and image scaling method |
CN101520887A (en) * | 2009-03-30 | 2009-09-02 | 北京中星微电子有限公司 | Image zooming method, device and chip |
CN101950523A (en) * | 2010-09-21 | 2011-01-19 | 上海大学 | Adjustable rectangular window image scaling method and device |
JP2014034129A (en) * | 2012-08-07 | 2014-02-24 | Ricoh Co Ltd | Information processing device, information processing method, system, and program |
CN104461439A (en) * | 2014-12-29 | 2015-03-25 | 联想(北京)有限公司 | Information processing method and electronic equipment |
Non-Patent Citations (2)
Title |
---|
杨玉婷 ; 康厚良 ; .2D图形引擎中的平面多边形内外点判别.图学学报.2013,(03),104-109. * |
覃方涛等.CUDA并行技术与数字图像几何变换.计算机系统应用.2010,第19卷(第10期),171. * |
Also Published As
Publication number | Publication date |
---|---|
CN111028140A (en) | 2020-04-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP3407279B2 (en) | Method and system for rendering primitives | |
CN105354809B (en) | A kind of pre-distortion method and device based on output image location of pixels index | |
US20080316211A1 (en) | Adaptive and Dynamic Text Filtering | |
CN109886866B (en) | Self-adaptive affine transformation processing method and device | |
CN101510421B (en) | Method and apparatus for regulating dot-character size, and embedded system | |
CN110992246A (en) | Pyramid layered slicing method for image | |
CN107291413A (en) | Display terminal, picture contrast improve method and computer-readable recording medium | |
US20080303825A1 (en) | System and method for dilation for glyph rendering | |
US9754344B2 (en) | Forward late predictive rendering in a graphics system | |
CN111028140B (en) | Method for realizing rectangular scaling and overturning of GPU pixels | |
WO2013021525A1 (en) | Image processing device, image processing method, program, and integrated circuit | |
CN108280801B (en) | Remapping method and device based on bilinear interpolation and programmable logic device | |
CN108073548B (en) | Convolution operation device and convolution operation method | |
CN116312412A (en) | Bicubic interpolation circuit based on FPGA | |
US20180174359A1 (en) | Frame difference generation hardware in a graphics system | |
CN108629734B (en) | Image geometric transformation method and device and terminal | |
US20020101428A1 (en) | Graphic engine and method for reducing idle time by validity test | |
US20230186442A1 (en) | Image processing method, image processing system, and non-transitory computer readable storage medium | |
CN110992462A (en) | Batch processing drawing method for 3D simulation scene image based on edge calculation | |
US20030122850A1 (en) | Method and apparatus for determining bins to be updated for polygons, including triangles | |
CN115526903A (en) | Hardware computing system and method for image upsampling based on Canny algorithm | |
CN111028126B (en) | Method for realizing convolution filtering of GPU image processing | |
CN113269882B (en) | Terrain rendering method and system based on virtual texture | |
CN118043842A (en) | Rendering format selection method and related equipment thereof | |
CN113284053A (en) | Method and medium for realizing arbitrary angle rotation of 2D (two-dimensional) graph |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |