Disclosure of Invention
The embodiment of the invention provides an image scaling method, an image scaling device, a sending card and a medium in an LED sending card, which are used for reducing the calculated amount of an image scaling process on the basis of adopting a bilinear interpolation method with a good effect, thereby reducing the resource occupation amount and reducing the cost of synchronous sending cards.
In a first aspect, an embodiment of the present invention provides a method for scaling an image in an LED sending card, where the method includes:
acquiring source image data input by a data source;
amplifying a bilinear interpolation formula by using a preset amplification coefficient to obtain an amplified formula, wherein the bilinear interpolation formula is used for determining coordinate values of reference pixel points which are corresponding to interpolation calculation in a source image according to the coordinate values of the pixel points to be processed in a target image;
performing precision compensation on the amplified formula according to the width ratio remainder part and the height ratio remainder part between the source image and the target image to obtain a compensated formula;
and performing image scaling according to the source image data based on the compensated formula by adopting a bilinear interpolation method to obtain the target image.
Optionally, the bilinear interpolation formula adopts a geometric center point coincidence correspondence formula.
Optionally, the formula after compensation is:
Dx=((Sw*N)/desw*desx)/N+Tw*desx+Tw/2-N/2;
Dy=((Sh*N)/desh*desy)/N+Th*desy+Th/2-N/2;
Wherein Dx represents an X-axis coordinate calculation value of the reference pixel, dy represents a Y-axis coordinate calculation value of the reference pixel, sw represents the N-times amplified width ratio remainder portion, sh represents the N-times amplified height ratio remainder portion, tw represents the N-times amplified width ratio integer portion, th represents the N-times amplified height ratio integer portion, N represents the preset amplification factor, desw represents the width of the target image, desh represents the height of the target image, desx represents an X-axis coordinate value of the pixel to be processed, and desy represents a Y-axis coordinate value of the pixel to be processed.
Optionally, the performing image scaling according to the source image data based on the compensated formula by using a bilinear interpolation method to obtain the target image includes:
Calculating a coordinate calculation value of the reference pixel point based on the compensated formula, and storing the coordinate calculation value in the first bit width data; the first high-order bit of the first bit width data is determined according to the maximum value of the width and height of the target image and is used for storing an integer part which corresponds to the coordinate calculated value of the reference pixel point and is not amplified by the preset amplification factor, and the first low-order bit of the first bit width data is determined according to the preset amplification factor and is used for storing a decimal part which corresponds to the coordinate calculated value of the reference pixel point and is amplified by the preset amplification factor;
Determining an interpolation calculation formula parameter according to the coordinate calculation value of the reference pixel point stored in the first bit width data, and determining a pixel value of the reference pixel point according to the interpolation calculation formula parameter and the source image data;
Performing interpolation calculation according to the pixel value of the reference pixel point and the interpolation calculation formula parameter to obtain a pixel calculation value of the pixel point to be processed, and storing the pixel calculation value in second bit width data; and the second high bit of the second bit width data is determined according to the bit width of the pixel single color component and is used for storing the pixel value single color component of the pixel point to be processed, and the second low bit of the second bit width data is determined according to the preset amplification factor.
Optionally, before the performing image scaling according to the source image data based on the compensated formula by using the bilinear interpolation method to obtain the target image, the method further includes:
sequentially storing the source image data in a plurality of RAMs according to rows;
The method for obtaining the target image by performing image scaling according to the source image data based on the compensated formula by adopting a bilinear interpolation method comprises the following steps:
Calculating to obtain a reference pixel point Y-axis coordinate calculation value based on the compensated formula;
determining a target RAM where the reference pixel point is located according to the Y-axis coordinate calculated value of the reference pixel point;
Calculating to obtain a reference pixel point X-axis coordinate calculation value based on the compensated formula;
And reading the pixel value of the reference pixel point from the target RAM according to the X-axis coordinate calculated value of the reference pixel point to perform interpolation calculation.
Optionally, the reading the pixel value of the reference pixel point from the target RAM according to the calculated value of the X-axis coordinate of the reference pixel point to perform interpolation calculation includes:
reading pixel values of a plurality of reference pixel points from each target RAM in each clock period, wherein the output bit width of the RAM is set according to the number of single-period reading;
Correspondingly, the calculating the reference pixel point X-axis coordinate calculated value based on the compensated formula comprises the following steps:
and calculating corresponding one or more reference pixel point X-axis coordinate calculated values by using one or more groups of compensated formulas according to the single-period reading quantity.
In a second aspect, an embodiment of the present invention further provides an image scaling device in an LED sending card, where the device includes:
The source image data acquisition module is used for acquiring source image data input by a data source;
The formula amplifying module is used for amplifying the bilinear interpolation formula by using a preset amplifying coefficient to obtain an amplified formula, wherein the bilinear interpolation formula is used for determining coordinate values of reference pixel points which are corresponding to and participate in interpolation calculation in the source image according to the coordinate values of the pixel points to be processed in the target image;
The formula compensation module is used for carrying out precision compensation on the amplified formula according to the width ratio remainder part and the height ratio remainder part between the source image and the target image to obtain a compensated formula;
And the image scaling module is used for performing image scaling according to the source image data based on the compensated formula by adopting a bilinear interpolation method to obtain the target image.
In a third aspect, an embodiment of the present invention further provides an LED synchronous transmitting card, where the LED synchronous transmitting card includes:
one or more processors;
a memory for storing one or more programs;
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method for image scaling in an LED sending card provided by any embodiment of the present invention.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium having stored thereon a computer program, which when executed by a processor, implements the image scaling method in the LED transmitting card provided by any embodiment of the present invention.
In a fifth aspect, embodiments of the present invention further provide a computer program product, which includes a computer program, which when executed by a processor implements the image scaling method in the LED transmitting card provided by any embodiment of the present invention.
The embodiment of the invention provides an image scaling method in an LED (light emitting diode) sending card, which comprises the steps of firstly acquiring source image data input by a data source, then amplifying a bilinear interpolation formula to be used for image scaling by using a preset amplification coefficient, and then carrying out precision compensation on the amplified formula according to a width ratio remainder and a height ratio remainder between a source image before scaling and a target image after scaling, thereby adopting a bilinear interpolation method, and carrying out image scaling according to the source image data based on the compensated formula to obtain the target image. According to the image scaling method in the LED transmitting card, the image scaling is carried out by using the bilinear interpolation formula after the precision compensation, so that a smaller amplification factor can be used, on the basis of ensuring a better scaling effect, the calculated amount is reduced, namely the resource occupation amount is reduced, further, the image scaling based on the bilinear interpolation method with a better effect can be directly and completely realized on a main control FPGA chip in the synchronous transmitting card of 130 ten thousand or 260 ten thousand total load numbers of the LED synchronous transmitting card, the additional chip or FPGA special for image processing is not needed, the cost of the synchronous transmitting card is reduced, the product competitiveness is improved, and the synchronous transmitting card with the same cost and the same load capacity commonly used at present generally does not have the scaling function.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart depicts steps as a sequential process, many of the steps may be implemented in parallel, concurrently, or with other steps. Furthermore, the order of the steps may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Example 1
Fig. 1 is a flowchart of an image scaling method in an LED transmitting card according to an embodiment of the present invention. The present embodiment is applicable to the case where the image scaling function based on bilinear interpolation is implemented in an LED synchronous transmission card in a low-cost manner. The method can be executed by the image scaling device in the LED transmitting card provided by the embodiment of the invention, and the device can be realized by hardware and/or software and can be generally integrated in the LED synchronous transmitting card. As shown in fig. 1, the method specifically comprises the following steps:
S11, acquiring source image data input by a data source.
Specifically, a data source supported by an arbitrary synchronous transmitting card can be accessed to obtain source image data to be scaled. Alternatively, after the source image data is obtained, clock domain conversion may be performed on the source image data first, and because the clock of the data source is not fixed due to the influence of EDID, when the clock of the data source is a low-frequency clock, performing image amplification operation may increase output image pixels, and the low-frequency clock may cause insufficient code efficiency, so that the clock domain of the data source may be converted to the local without using the clock domain of the data source. After the clock domain conversion is completed, the source image data can be used for carrying out the subsequent bilinear interpolation scaling process.
And S12, amplifying the bilinear interpolation formula by using a preset amplification factor to obtain an amplified formula, wherein the bilinear interpolation formula is used for determining coordinate values of reference pixel points which are corresponding to interpolation calculation in the source image according to the coordinate values of the pixel points to be processed in the target image.
The preset amplification factor can be a specified small multiplying power, the value is the power of 2, and the specific numerical value can be set according to a bilinear interpolation formula amplified by the preset amplification factor by using the main control FPGA chip residual resource realization calculation as a standard. The preset magnification factor may be, for example, 16-256, preferably 256. The value of the preset amplification factor can influence the use amount of the DSP resources of the multipliers in the calculation process, the preset amplification factor smaller than or equal to 256 can ensure that the use amount of the DSP resources of each multiplier is 1, and the preset amplification factor larger than 256 can enable the calculation to be more accurate, but can increase the use amount of the DSP resources of the multipliers. Under the calculation with the subsequent precision compensation, the preset amplification factor as low as 16 can still ensure a certain scaling effect, but the DSP resource usage of the 16-256 preset amplification factor multiplier is 1, so 256 is preferable to obtain a better effect.
The bilinear interpolation formula can adopt a basic formula, and preferably, the bilinear interpolation formula adopts a geometric center point coincidence corresponding formula so as to further improve the zooming effect. The bilinear interpolation formula is used for determining coordinate values of reference pixel points needing to participate in interpolation calculation in the source image according to the coordinate values of the pixel points to be processed to be output in the target image, and the number of the required reference pixel points is 4 when a bilinear interpolation method is generally adopted. Specifically, a reference pixel coordinate calculated value can be obtained according to a bilinear interpolation formula, then a first reference pixel can be determined according to an integer part of the reference pixel coordinate calculated value, and then the other three reference pixels can be obtained by adding one to the X axis, one to the Y axis and one to the X axis and one to the Y axis of the reference pixel. Wherein, the basic formula is:
srcx=desx*srcw/desw;
srcy=desy*srch/desh;
Wherein srcx denotes a reference pixel X-axis coordinate calculation value under the basic formula, srcy denotes a reference pixel Y-axis coordinate calculation value under the basic formula, desx denotes an X-axis coordinate value of a pixel to be processed, desy denotes a Y-axis coordinate value of a pixel to be processed, srcw denotes a width of a source image, srch denotes a height of a source image, desw denotes a width of a target image, and desh denotes a height of a target image.
The geometrical center point coincidence corresponding formula is as follows:
srcx=(desx+0.5)*srcw/desw-0.5;
srcy=(desy+0.5)*srch/desh-0.5;
Correspondingly, srcx represents the X-axis coordinate calculation value of the reference pixel point under the geometric center point coincidence corresponding formula, srcy represents the Y-axis coordinate calculation value of the reference pixel point under the geometric center point coincidence corresponding formula, and the other basic formulas are the same. Because the FPGA has no decimal, the bilinear interpolation formula is needed to be amplified by using the preset amplification coefficient, namely, the preset amplification coefficient is multiplied by two sides of the equation at the same time to obtain an amplified formula, and meanwhile, the preset amplification coefficient can be smaller than that of the traditional scheme due to the fact that the precision compensation is carried out later.
And S13, performing precision compensation on the amplified formula according to the width ratio remainder part and the height ratio remainder part between the source image and the target image to obtain a compensated formula.
Specifically, for a specified image scaling process, the sizes of the source image and the target image are determined, that is, in the bilinear interpolation formula, the width and height of the source image, the width and height of the target image, and the preset magnification factor are all fixed values, so that the portions can be calculated separately for later use. Specifically, the calculation may be performed for (srcw/desw) N and (srch/desh) N (fixed part) in the amplified formula, where N represents a preset amplification factor. Further, tw represents ⌊ srcw/desw ⌋ ×n, i.e., a width ratio integer portion amplified by N times, th represents ⌊ srch/desh ⌋ ×n, i.e., a height ratio integer portion amplified by N times, sw represents (srcw% desw) ×n, i.e., a width ratio remainder portion amplified by N times, and Sh represents (srch% desh) ×n, i.e., a height ratio remainder portion amplified by N times, may be set. The integer part and the remainder part of srcw/desw and srch/desh can be considered in the process of calculating the fixed part, the srcw/desw and srch/desh are not required to be completely amplified to the integer by a preset amplification coefficient, and the amplified formula can be subjected to precision compensation according to the width ratio remainder part and the height ratio remainder part to obtain a compensated formula. Specifically, tw, sw, th and Sh can be substituted into the amplified formula to obtain the compensated formula. Optionally, when a geometric center point coincidence corresponding formula is adopted, the formula after compensation is:
Dx=((Sw*N)/desw*desx)/N+Tw*desx+Tw/2-N/2;
Dy=((Sh*N)/desh*desy)/N+Th*desy+Th/2-N/2;
Wherein Dx represents an X-axis coordinate calculated value (under a formula after compensation) of the reference pixel point, dy represents a Y-axis coordinate calculated value (under a formula after compensation) of the reference pixel point, sw represents the width-to-remainder portion after N-fold amplification, sh represents the height-to-remainder portion after N-fold amplification, tw represents the width-to-integer portion after N-fold amplification, th represents the height-to-integer portion after N-fold amplification, N represents the preset amplification factor, desw represents the width of the target image, desh represents the height of the target image, desx represents an X-axis coordinate value of the pixel point to be processed, and desy represents a Y-axis coordinate value of the pixel point to be processed. In the compensated formula, if the height ratio remainder or the width ratio remainder is divided by the height of the target image, the value is too small to be correctly involved in the calculation process, so the height ratio remainder and the width ratio remainder are amplified by N times and then calculated, and then divided back by N to obtain a correct value. Assuming that the preset amplification factor is 256, less resources can be used in the scaling calculation process, but accuracy is lost, and the accuracy is compensated for a remainder part through the compensated formula, so that the requirement of calculating accuracy can be met under the condition of using less resources.
S14, performing image scaling according to the source image data based on the compensated formula by adopting a bilinear interpolation method to obtain the target image.
Specifically, after the compensated formula is obtained, on the basis of the existing image scaling based on the bilinear interpolation method, the compensated formula can be used for image scaling instead of the original bilinear interpolation formula, so that the required target image is obtained. Specifically, for each pixel point to be processed in the target image, a reference pixel point coordinate calculation value is calculated by using a compensated formula, then four reference pixel points corresponding to interpolation calculation are determined according to the reference pixel point coordinate calculation value, pixel values of all the reference pixel points are determined according to source image data, and meanwhile, a decimal part (namely, offset of a virtual pixel point corresponding to the reference pixel point coordinate calculation value relative to a specified reference pixel point) required in the interpolation calculation formula is determined according to the reference pixel point coordinate calculation value, so that the pixel value of the pixel point to be processed can be calculated according to the decimal part, coordinate values of the four reference pixel points and the pixel value by using the interpolation calculation formula.
On the basis of the above technical solution, optionally, the performing image scaling according to the source image data to obtain the target image based on the compensated formula by using a bilinear interpolation method includes: calculating a coordinate calculation value of the reference pixel point based on the compensated formula, and storing the coordinate calculation value in the first bit width data; the first high-order bit of the first bit width data is determined according to the maximum value of the width and height of the target image and is used for storing an integer part which corresponds to the coordinate calculated value of the reference pixel point and is not amplified by the preset amplification factor, and the first low-order bit of the first bit width data is determined according to the preset amplification factor and is used for storing a decimal part which corresponds to the coordinate calculated value of the reference pixel point and is amplified by the preset amplification factor; determining an interpolation calculation formula parameter according to the coordinate calculation value of the reference pixel point stored in the first bit width data, and determining a pixel value of the reference pixel point according to the interpolation calculation formula parameter and the source image data; performing interpolation calculation according to the pixel value of the reference pixel point and the interpolation calculation formula parameter to obtain a pixel calculation value of the pixel point to be processed, and storing the pixel calculation value in second bit width data; and the second high bit of the second bit width data is determined according to the bit width of the pixel single color component and is used for storing the pixel value single color component of the pixel point to be processed, and the second low bit of the second bit width data is determined according to the preset amplification factor.
Specifically, the reference pixel point coordinate calculated value (Dx and Dy as described above) is calculated based on the compensated formula, the calculation process is performed after the preset amplification factor is amplified, the total bit width may depend on the maximum parameter supported by the target image and the selected preset amplification factor, after determining the corresponding first bit width (i.e., the total bit width required by the reference pixel point coordinate calculated value), the calculated reference pixel point coordinate calculated value may be stored in the first bit width data, and specifically, the X-axis coordinate calculated value and the Y-axis coordinate calculated value may be respectively stored in the respective first bit width data. For example, the width maximum value and the height maximum value of the scaled target image are 3840, the power 12 of 2 is 4096, and the value is greater than 3840, and the preset magnification factor is 256, that is, the power 8 of 2, then the first bit width may be set to 12+8=20, where the first high (that is, the high 12 bits) stored value (that is, the small part of the reference pixel point theoretical coordinate calculated value) corresponding to the integer part (that is, the integer part of the reference pixel point coordinate calculated value reduced by 256 times) that is not amplified by the preset magnification factor, and the first low (that is, the low 8 bits) stored value (that is, the small part of the reference pixel point coordinate calculated value reduced by 256 times) corresponding to the small part (that is, the small part of the reference pixel point theoretical coordinate calculated value reduced by 256 times) are amplified by 256 times.
After obtaining the reference pixel coordinate calculation value, the interpolation calculation formula parameter may be determined according to the reference pixel coordinate calculation value stored in the first bit width data, for example, the coordinate values of the four reference pixels and the required decimal part in the interpolation calculation formula may be included. For example, the reference pixel coordinate calculation values include an X-axis coordinate calculation value Dx and a Y-axis coordinate calculation value Dy, let x=dx fractional assignment (first low-order part data in first-order wide data corresponding to Dx), y=dy fractional assignment (first low-order part data in first-order wide data corresponding to Dy), x1=dx integer assignment (data after first low-order part zero in first-order wide data corresponding to Dx), y1=dy integer assignment (data after first low-order part zero in first-order wide data corresponding to Dy), and the required fractional parts of X and Y can be obtained, and the first reference pixel coordinate is (X1, Y1), and let x2=x1+1, y2=y1+1, and the other three reference pixel coordinates can be obtained as (X2, Y1), (X1, Y2) and (X2, Y2), respectively. Pixel values f11, f21, f12, and f22 of the corresponding reference pixel points can be found from the coordinate values in the source image data. Then, the interpolation calculation formula f=f11 (x 2-x) (y 2-y) +f21 (x-x 1) (y 2-y) +f12 (x 2-x) (y-y 1) +f22 (x-x 1) (y-y 1) may be substituted for the interpolation calculation to obtain the pixel calculation value F of the corresponding pixel to be processed. In the calculation process, since the interpolation calculation formula parameters x, x1, x2, y1 and y2 are all values obtained by amplifying the preset amplification factor, the values obtained by the interpolation calculation formula are amplified by the square of the preset amplification factor. The total bit width (i.e., the second bit width) required by the pixel calculation value of the pixel to be processed may be determined according to the bit width of the pixel single color component and the preset amplification factor, after determining the corresponding second bit width, the calculated pixel calculation value of the pixel to be processed may be stored in the second bit width data, and specifically, the calculated value of each color component (e.g., the output data is in RGB format, and may be obtained by substituting the value of each color component of the reference pixel into the respective interpolation calculation formula) may be stored in the respective second bit width data. For example, if the preset amplification factor is 256, 256×256=65536, i.e. the power of 16 of 2, and the bit width of the pixel single color component of the general output data is 8, the second bit width may be determined to be 16+8=24, where the second highest bit stores, i.e. the value of the corresponding color component.
On the basis of the above technical solution, optionally, before the performing image scaling according to the source image data based on the compensated formula by using the bilinear interpolation method to obtain the target image, the method further includes: sequentially storing the source image data in a plurality of RAMs according to rows; the method for obtaining the target image by performing image scaling according to the source image data based on the compensated formula by adopting a bilinear interpolation method comprises the following steps: calculating to obtain a reference pixel point Y-axis coordinate calculation value based on the compensated formula; determining a target RAM where the reference pixel point is located according to the Y-axis coordinate calculated value of the reference pixel point; calculating to obtain a reference pixel point X-axis coordinate calculation value based on the compensated formula; and reading the pixel value of the reference pixel point from the target RAM according to the X-axis coordinate calculated value of the reference pixel point to perform interpolation calculation.
Specifically, as shown in fig. 2, only three RAMs (RAMA, RAMB, RAMC) may be used, each RAM stores one line of source image data, each stored line of data counts is incremented by one, and RAM input selection may be performed according to the count value to determine the RAM storing the next line of source image data, and specifically, the RAMs may be sequentially stored in the three RAMs according to the line until the storage is completed, that is, every two consecutive lines are not stored in the same RAM. In the scaling process, dy calculation can be performed by using a compensated formula to obtain a reference pixel point Y-axis coordinate calculation value, so that a currently required line of the reference pixel point in the source image data can be determined according to the reference pixel point Y-axis coordinate calculation value, and a target RAM in which the reference pixel point is stored can be determined through RAM output selection. And then, dx calculation can be performed by using a compensated formula to obtain a reference pixel X-axis coordinate calculation value, so that the pixel value of the reference pixel can be read from the target RAM according to the reference pixel X-axis coordinate calculation value to perform interpolation calculation, and the pixel value output of the pixel to be processed is obtained. The target RAM may be two, that is, two lines of data are needed for one interpolation calculation, and each line of data is used for two pixel points.
Further optionally, the reading the pixel value of the reference pixel point from the target RAM according to the calculated value of the X-axis coordinate of the reference pixel point to perform interpolation calculation includes: reading pixel values of a plurality of reference pixel points from each target RAM in each clock period, wherein the output bit width of the RAM is set according to the number of single-period reading; correspondingly, the calculating the reference pixel point X-axis coordinate calculated value based on the compensated formula comprises the following steps: and calculating corresponding one or more reference pixel point X-axis coordinate calculated values by using one or more groups of compensated formulas according to the single-period reading quantity.
Specifically, in interpolation calculation, two rows of four reference pixel points are required to calculate to obtain a pixel value of a pixel point to be processed which is currently output. In the conventional RAM usage method, the input/output ports are 24 bits, and under the condition that each RAM registers one row, two clock cycles are required to read out two reference pixel points of the required row. Under the image amplifying operation, the amplified whole pixel points become more, and each clock period can not ensure to output one pixel point to be processed, or only output one pixel point to be processed, so that the output efficiency is insufficient, the output of an image after one frame of amplifying can not be completed under 16.6 milliseconds, the current frame is not output, the next frame data arrives, and the image data errors are caused. The pixel values of a specified number of reference pixel points (i.e., a single-cycle read number) may be read from each target RAM in each clock cycle based on the number of pixel points to be processed that one clock cycle wants to calculate, and, illustratively, the pixel values of two reference pixel points are read from each target RAM in each clock cycle, one pixel point to be processed can be output at maximum in each clock cycle, the pixel values of four reference pixel points are read from each target RAM in each clock cycle, two pixel points to be processed can be output at maximum in each clock cycle, and the like. And meanwhile, DSP resources required by calculation are considered, after each time of target RAM is determined, a reference pixel X-axis coordinate calculation formula of corresponding groups of numbers can be set according to the number of the pixel to be processed which is required to be calculated in one clock period, and the corresponding calculated reference pixel X-axis coordinate calculation values are correspondingly calculated, so that interpolation calculation of the corresponding groups of numbers is carried out, and output of the corresponding numbers of the pixel to be processed is obtained. Therefore, the condition that one or more pixel points to be processed are required to be output in one clock period can be avoided, the plurality of RAMs are used for registering the same row of data, and occupation of logic resources and DSP resources is further reduced.
The output bit width of the RAM may be further set according to the number of single-cycle reads, and specifically, the output bit width may be set to be M times the input bit width, where M is the number of single-cycle reads. For example, the maximum width of the image input source of the 130 ten thousand or 260 ten thousand synchronous sending card is 3840, so that the depth of the writing end of the RAM is 3840, the bit width is 24, when the required single-period reading number is 4, the output bit width can be set to 96, and the depth is 960, then 4 reference pixel points can be read out in one clock period, correspondingly, the 4 reference pixel points can perform two groups of interpolation calculation, namely, two groups (namely, half of the single-period reading number) of reference pixel points in the compensated formula can be correspondingly set, and the corresponding two reference pixel point X-axis coordinate calculation values can be obtained by correspondingly setting the reference pixel point X-axis coordinate calculation formula in the formula, so that the two groups of reference pixel points can be respectively read from the target RAM for interpolation calculation.
According to the technical scheme provided by the embodiment of the invention, source image data input by a data source is firstly obtained, then a bilinear interpolation formula to be used for image scaling is firstly amplified by using a preset amplification coefficient, and then the amplified formula is subjected to precision compensation according to a width ratio remainder and a height ratio remainder between a source image before scaling and a target image after scaling, so that a bilinear interpolation method is adopted, and image scaling is performed according to the source image data based on the compensated formula to obtain the target image. The image scaling is carried out by using the bilinear interpolation formula after the precision compensation, a smaller amplification factor can be used, so that on the basis of ensuring a better scaling effect, the calculated amount is reduced, namely the resource occupation amount is reduced, further, the image scaling with a better effect based on the bilinear interpolation method can be directly realized on a main control FPGA chip in an LED synchronous transmitting card, such as a 130 ten thousand-point or 260 ten thousand-point synchronous transmitting card, without additionally adding a chip or FPGA special for image processing, the cost of the synchronous transmitting card is reduced, the product competitiveness is improved, and the synchronous transmitting card with the same cost and the same carrying capacity commonly used at present generally does not have the scaling function.
Example two
Fig. 3 is a schematic structural diagram of an image scaling device in an LED sending card according to a second embodiment of the present invention, where the device may be implemented in hardware and/or software, and may be generally integrated in an LED synchronous sending card, for executing the image scaling method in an LED sending card according to any embodiment of the present invention. As shown in fig. 3, the apparatus includes:
a source image data acquisition module 31 for acquiring source image data input by a data source;
The formula amplification module 32 is configured to amplify a bilinear interpolation formula by using a preset amplification factor, so as to obtain an amplified formula, where the bilinear interpolation formula is used to determine coordinate values of reference pixel points in the source image, which are corresponding to and participate in interpolation calculation, according to coordinate values of pixel points to be processed in the target image;
a formula compensation module 33, configured to perform precision compensation on the amplified formula according to a width ratio remainder part and a height ratio remainder part between the source image and the target image, so as to obtain a compensated formula;
an image scaling module 34, configured to perform image scaling according to the source image data based on the compensated formula by using bilinear interpolation, so as to obtain the target image.
According to the technical scheme provided by the embodiment of the invention, source image data input by a data source is firstly obtained, then a bilinear interpolation formula to be used for image scaling is firstly amplified by using a preset amplification coefficient, and then the amplified formula is subjected to precision compensation according to a width ratio remainder and a height ratio remainder between a source image before scaling and a target image after scaling, so that a bilinear interpolation method is adopted, and image scaling is performed according to the source image data based on the compensated formula to obtain the target image. The image scaling is carried out by using the bilinear interpolation formula after the precision compensation, a smaller amplification factor can be used, so that on the basis of ensuring a better scaling effect, the calculated amount is reduced, namely the resource occupation amount is reduced, further, the image scaling with a better effect based on the bilinear interpolation method can be directly realized on a main control FPGA chip in an LED synchronous transmitting card, such as a 130 ten thousand-point or 260 ten thousand-point synchronous transmitting card, without additionally adding a chip or FPGA special for image processing, the cost of the synchronous transmitting card is reduced, the product competitiveness is improved, and the synchronous transmitting card with the same cost and the same carrying capacity commonly used at present generally does not have the scaling function.
Based on the technical scheme, optionally, the bilinear interpolation formula adopts a geometric center point coincidence corresponding formula.
On the basis of the above technical solution, optionally, the compensated formula is:
Dx=((Sw*N)/desw*desx)/N+Tw*desx+Tw/2-N/2;
Dy=((Sh*N)/desh*desy)/N+Th*desy+Th/2-N/2;
Wherein Dx represents an X-axis coordinate calculation value of the reference pixel, dy represents a Y-axis coordinate calculation value of the reference pixel, sw represents the N-times amplified width ratio remainder portion, sh represents the N-times amplified height ratio remainder portion, tw represents the N-times amplified width ratio integer portion, th represents the N-times amplified height ratio integer portion, N represents the preset amplification factor, desw represents the width of the target image, desh represents the height of the target image, desx represents an X-axis coordinate value of the pixel to be processed, and desy represents a Y-axis coordinate value of the pixel to be processed.
Based on the above technical solution, optionally, the image scaling module 34 includes:
the reference pixel point coordinate calculated value storage unit is used for calculating a reference pixel point coordinate calculated value based on the compensated formula and storing the reference pixel point coordinate calculated value in the first bit width data; the first high-order bit of the first bit width data is determined according to the maximum value of the width and height of the target image and is used for storing an integer part which corresponds to the coordinate calculated value of the reference pixel point and is not amplified by the preset amplification factor, and the first low-order bit of the first bit width data is determined according to the preset amplification factor and is used for storing a decimal part which corresponds to the coordinate calculated value of the reference pixel point and is amplified by the preset amplification factor;
An interpolation calculation formula parameter determining unit, configured to determine an interpolation calculation formula parameter according to the reference pixel point coordinate calculation value stored in the first bit width data, and determine a pixel value of the reference pixel point according to the interpolation calculation formula parameter and the source image data;
The interpolation calculation unit is used for carrying out interpolation calculation according to the pixel value of the reference pixel point and the interpolation calculation formula parameter, so that the pixel calculation value of the pixel point to be processed is stored in second bit width data; and the second high bit of the second bit width data is determined according to the bit width of the pixel single color component and is used for storing the pixel value single color component of the pixel point to be processed, and the second low bit of the second bit width data is determined according to the preset amplification factor.
On the basis of the above technical solution, optionally, the image scaling device in the LED sending card further includes:
The source image data storage module is used for sequentially storing the source image data in a plurality of RAMs according to rows before the target image is obtained by performing image scaling according to the source image data based on the compensated formula by adopting a bilinear interpolation method;
image scaling module 34, comprising:
the Y-axis coordinate calculation unit is used for calculating and obtaining a Y-axis coordinate calculation value of the reference pixel point based on the compensated formula;
A target RAM determining unit, configured to determine a target RAM where the reference pixel point is located according to the reference pixel point Y-axis coordinate calculation value;
The X-axis coordinate calculation unit is used for calculating and obtaining an X-axis coordinate calculation value of the reference pixel point based on the compensated formula;
And the pixel value reading unit is used for reading the pixel value of the reference pixel point from the target RAM according to the X-axis coordinate calculation value of the reference pixel point to perform interpolation calculation.
On the basis of the above technical solution, optionally, the pixel value reading unit is specifically configured to:
reading pixel values of a plurality of reference pixel points from each target RAM in each clock period, wherein the output bit width of the RAM is set according to the number of single-period reading;
Correspondingly, the X-axis coordinate calculation unit is specifically configured to:
and calculating corresponding one or more reference pixel point X-axis coordinate calculated values by using one or more groups of compensated formulas according to the single-period reading quantity.
The image scaling device in the LED sending card provided by the embodiment of the invention can execute the image scaling method in the LED sending card provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
It should be noted that, in the embodiment of the image scaling device in the LED transmitting card, each unit and module included are only divided according to the functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be realized; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present invention.
Example III
Fig. 4 is a schematic structural diagram of an LED synchronous transmitting card according to a third embodiment of the present invention, and shows a block diagram of an exemplary LED synchronous transmitting card suitable for implementing an embodiment of the present invention. The LED synchronous transmitting card shown in fig. 4 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention. As shown in fig. 4, the LED synchronous transmission card includes a processor 41, a memory 42, an input device 43 and an output device 44; the number of processors 41 in the LED synchronous transmission card may be one or more, and in fig. 4, one processor 41 is taken as an example, and the processors 41, the memory 42, the input device 43 and the output device 44 in the LED synchronous transmission card may be connected by a bus or other manners, and in fig. 4, the connection by a bus is taken as an example.
The memory 42 is a computer readable storage medium, and may be used to store software programs, computer executable programs, and modules, such as program instructions/modules corresponding to the image scaling method in the LED sending card in the embodiment of the present invention (for example, the source image data acquisition module 31, the formula amplification module 32, the formula compensation module 33, and the image scaling module 34 in the image scaling device in the LED sending card). The processor 41 executes various functional applications and data processing of the LED synchronous transmission card by running software programs, instructions and modules stored in the memory 42, i.e., implements the image scaling method in the LED transmission card described above.
The memory 42 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for functions; the storage data area may store data created according to the use of the LED synchronous transmission card, or the like. In addition, memory 42 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 42 may further include memory remotely located with respect to processor 41, which may be connected to the LED synchronous transmit card via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 43 may be used to acquire source image data input from a data source, and to generate key signal inputs related to user settings and function control of the LED synchronous transmission card, and the like. The output device 44 may be used to send the scaled target image data to a display screen, or the like.
Example IV
A fourth embodiment of the present invention also provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are for performing a method of image scaling in an LED send card, the method comprising:
acquiring source image data input by a data source;
amplifying a bilinear interpolation formula by using a preset amplification coefficient to obtain an amplified formula, wherein the bilinear interpolation formula is used for determining coordinate values of reference pixel points which are corresponding to interpolation calculation in a source image according to the coordinate values of the pixel points to be processed in a target image;
performing precision compensation on the amplified formula according to the width ratio remainder part and the height ratio remainder part between the source image and the target image to obtain a compensated formula;
and performing image scaling according to the source image data based on the compensated formula by adopting a bilinear interpolation method to obtain the target image.
The storage medium may be any of various types of memory devices or storage devices. The term "storage medium" is intended to include: mounting media such as CD-ROM, floppy disk or tape devices; computer system memory or random access memory such as DRAM, DDR RAM, SRAM, EDO RAM, lanbus (Rambus) RAM, etc.; nonvolatile memory such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in a computer system in which the program is executed, or may be located in a different second computer system connected to the computer system through a network (such as the internet). The second computer system may provide program instructions to the computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations (e.g., in different computer systems connected by a network). The storage medium may store program instructions (e.g., embodied as a computer program) executable by one or more processors.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present invention is not limited to the method operations described above, and may also perform the related operations in the image scaling method in the LED transmitting card provided in any embodiment of the present invention.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
From the above description of embodiments, it will be clear to a person skilled in the art that the present invention may be implemented by means of software and necessary general purpose hardware, but of course also by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a FLASH Memory (FLASH), a hard disk, or an optical disk of a computer, etc., and include several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments of the present invention.
Example five
The fifth embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program (may also be called code or instructions), and the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program is used to perform the image scaling method in the LED transmitting card provided in any of the foregoing embodiments, and has the corresponding beneficial effects of the execution method.
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.