A data processing method, device and electronic equipment
By recombining valid and invalid pixel values in the original image and writing them into the destination image, the problem of invalid pixel values in OpenCL image data copying is solved, improving the image data copying quality and CPU resource utilization.
Patent Information
- Application Number
- CN202111626042.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2041-12-28
AI Technical Summary
When using OpenCL to copy image data on a Linux device, invalid pixel values outside the copy frame may be read, resulting in invalid pixel values in the target image and reducing the quality of image data copying.
When the image data obtained from the original image contains both valid and invalid pixel values, it is recombined with the invalid pixel values in the target image and the recombined image data is written to the target image to avoid writing the invalid pixel values of the original image into the corresponding area of the target image.
It improves the quality of image data copying, avoids the writing of invalid pixel values, and enhances CPU resource utilization and application performance.
Smart Images

Figure CN114372928B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data processing, and in particular to a data processing method and device and electronic equipment. BACKGROUND
[0002] In computer image processing and security industry, image data processing is often used, and image data copying is a common image data processing method. Generally, the CPU resources of Linux devices are limited, and the time consumption of application programs is high. However, when image data copying is frequently performed or data copying is performed on a large amount of image data, a large amount of CPU resources will be consumed, and the time consumption of the application program will be increased. In this case, device hardware units are usually used for acceleration processing, which can not only save a large amount of CPU resources, but also improve the overall performance of the application program.
[0003] The hardware resources of the image processor (Graphics Processing Unit, GPU) supporting Open Computing Language (OpenCL) are commonly used acceleration units in Linux devices, and are usually used for optimization and acceleration. However, in the process of copying the row data using OpenCL, only a fixed number of pixel values can be read when reading the pixel values corresponding to each pixel point each time. Therefore, when copying the boundary data of the region corresponding to the original image, the pixel values outside the copy frame may be read, and these pixel values outside the copy frame are invalid pixel values. At this time, if the read image data is directly written to the copy destination image, the region corresponding to the copy destination image will have invalid pixel values outside the copy frame in the original image, thereby reducing the image data copying quality. SUMMARY
[0004] The present application provides a data processing method, device and electronic equipment. When the image data obtained from the original image contains valid pixel values and invalid pixel values, the valid pixel values are reorganized with the invalid pixel values in the copy destination image, and the reorganized image data is written to the copy destination image. This method can avoid writing the invalid pixel values corresponding to the original image to the region corresponding to the copy destination image, thereby improving the image data copying quality.
[0005] In a first aspect, the present application provides a data processing method, which comprises:
[0006] obtaining first image data corresponding to a row of the original image, the first image data containing N pixel values, wherein N is determined according to the pixel reading performance and the number of pixel points of the original image;
[0007] extracting a second invalid pixel value corresponding to the first invalid pixel value in the copy destination image when it is determined that the first image data contains valid pixel values and the first invalid pixel value;
[0008] recombining the valid pixel values and the second invalid pixel value to obtain second image data, and writing the second image data into the copy destination image.
[0009] By the above method, the invalid pixel value corresponding to the copy original image is replaced by the invalid pixel value corresponding to the copy destination image, so as to avoid writing the invalid pixel value corresponding to the copy original image into the region corresponding to the copy destination image, thereby improving the image data copy quality.
[0010] In a possible design, when it is determined that the first image data contains valid pixel values and the first invalid pixel value, the second invalid pixel value corresponding to the first invalid pixel value in the copy destination image is extracted, including:
[0011] determining whether a pixel reading end position is outside the copy frame in the copy original image;
[0012] if yes, it is determined that the first image data contains the valid pixel values and the first invalid pixel value;
[0013] if no, it is determined that the first image data contains only the valid pixel values.
[0014] By the above method, it can be determined whether the image data obtained currently contains valid pixel values and invalid pixel values.
[0015] In a possible design, the determination of the valid pixel values and the first invalid pixel value contained in the first image data includes:
[0016] calculating the number of valid pixel values in the first image data according to a width value corresponding to the copy frame and an N value, wherein the width value represents the number of pixel points contained in one row of image data;
[0017] extracting the number of valid pixel values in the first image data according to a preset rule;
[0018] taking data other than the valid pixel values in the first image data as the first invalid pixel value.
[0019] By the above method, the invalid pixel value in the obtained image data can be determined.
[0020] In a possible design, the extraction of the second invalid pixel value corresponding to the first invalid pixel value in the copy destination image includes:
[0021] determining a pixel writing start point corresponding to the valid pixel value in the copy destination image;
[0022] reading a third image data containing N pixel values in a row in the copy destination image according to the pixel writing start point;
[0023] extracting second invalid pixel values in the third image data according to the number of pixel values corresponding to the first invalid pixel value, wherein the arrangement position of the second invalid pixel values in the third image data is consistent with the arrangement position of the first invalid pixel value in the first image data.
[0024] By the above method, the invalid pixel value in the copy destination image is obtained, which is used to recombine with the valid pixel value in the copy original image and then write into the copy destination image, thereby avoiding writing the invalid pixel value corresponding to the copy original image into the copy destination image in the subsequent process, and improving the image data copy quality.
[0025] In a possible design, after the second image data is written into the copy destination image, the method further includes:
[0026] when it is determined that only valid pixel values are contained in the first image data, writing the first image data into the copy destination image;
[0027] when it is determined that only invalid pixel values are contained in the first image data, canceling the first image data.
[0028] In a second aspect, the present application provides a data processing apparatus, which includes:
[0029] an obtaining module, configured to obtain first image data containing N pixel values in a row corresponding to a copy original image, wherein the value of N is determined according to the pixel reading performance and the number of pixel points in the copy original image;
[0030] an extracting module, configured to, when it is determined that the first image data contains valid pixel values and first invalid pixel values, extract second invalid pixel values corresponding to the first invalid pixel values in a copy destination image;
[0031] a writing module, configured to recombine the valid pixel values and the second invalid pixel values to obtain second image data, and write the second image data into the copy destination image.
[0032] In a possible design, the apparatus further includes:
[0033] a judging module, configured to judge whether a pixel reading end position is outside a copy frame in the copy original image;
[0034] determining that the first image data contains the valid pixel value and the first invalid pixel value if the pixel reading end position is outside the copy frame; and determining that the first image data contains only the valid pixel value if the pixel reading end position is inside the copy frame.
[0035] In a possible design of the extraction module, the extraction module is further configured to:
[0036] calculate a number of valid pixel values in the first image data according to a width value corresponding to the copy frame and the N value, wherein the width value represents a number of pixel points in one row of image data;
[0037] extract the number of valid pixel values from the first image data according to a preset rule;
[0038] take data other than the valid pixel values in the first image data as the first invalid pixel value.
[0039] In a possible design of the extraction module, the extraction module is further configured to:
[0040] determine a pixel writing start position of the valid pixel value in the copy destination image;
[0041] read third image data containing N pixel values in one row from the copy destination image according to the pixel writing start position;
[0042] extract second invalid pixel values with a number of pixel values corresponding to the first invalid pixel value from the third image data, wherein the second invalid pixel values are arranged in the third image data in the same way as the first invalid pixel values are arranged in the first image data.
[0043] In a possible design of the apparatus, the apparatus further includes:
[0044] a processing module configured to write the first image data into the copy destination image if it is determined that the first image data contains only valid pixel values, and to discard the first image data if it is determined that the first image data contains only invalid pixel values.
[0045] In a third aspect, the present application provides an electronic device, including:
[0046] a memory configured to store a computer program;
[0047] a processor configured to execute the computer program stored in the memory to implement the data processing method.
[0048] In a fourth aspect, the present application provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the data processing method.
[0049] Based on the data processing method, when the image data obtained from the copy original image contains valid pixel values and invalid pixel values, the valid pixel values are recombined with the invalid pixel values in the copy target image, and the recombined image data is written into the copy target image. This method can avoid writing the invalid pixel values corresponding to the copy original image into the area corresponding to the copy target image, thereby improving the image data copy quality. BRIEF DESCRIPTION OF DRAWINGS
[0050] Figure 1 A flowchart of a data processing method provided by the present application is shown in FIG. 1.
[0051] Figure 2a A current work item diagram of a copy original image provided by the present application is shown in FIG. 2.
[0052] Figure 2b A current work item diagram of a copy target image provided by the present application is shown in FIG. 3.
[0053] Figure 2c A recombination result diagram in a copy target image provided by the present application is shown in FIG. 4.
[0054] Figure 3 A structural diagram of a data processing device provided by the present application is shown in FIG. 5.
[0055] Figure 4 A structural diagram of an electronic device provided by the present application is shown in FIG. 6. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings. The specific operation method in the method embodiment can also be applied to the device embodiment or the system embodiment. It should be noted that in the description of the present application, “multiple” is understood as “at least two”. “And / or” describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which means that there are three cases: A exists alone, A and B exist together, and B exists alone. A and B are connected, which means that A and B are directly connected and A and B are connected through C. In addition, in the description of the present application, “first”, “second”, etc. are used only for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can it be understood as indicating or implying order.
[0057] The embodiments of the present application will be described in detail below with reference to the drawings.
[0058] In the process of copying the row data using OpenCL, each time the pixel value corresponding to the number of pixels is read, a fixed number of pixel values can only be read, and therefore, when copying the region boundary data corresponding to the original copy, the pixel value outside the copy frame can be read. At this time, if the read image data is written into the copy destination image, the region corresponding to the copy destination image can add the invalid pixel value outside the copy frame in the original copy.
[0059] To solve the above problems, the present application provides a data processing method. When the image data obtained from the original copy contains valid pixel values and invalid pixel values, the valid pixel values are reorganized with the invalid pixel values in the copy destination image, and the reorganized image data is written into the copy destination image. This method can avoid writing the invalid pixel values corresponding to the original copy into the region corresponding to the copy destination image, thereby improving the image data copy quality. The method and device of the present application are based on the same technical concept. Since the principles of the problems solved by the method and device are similar, the embodiments of the device and the method can be mutually referred to, and the repeated parts will not be described again.
[0060] As shown in FIG. 1, a flowchart of a data processing method provided by the present application is shown, which specifically includes the following steps: Figure 1
[0061] S11, obtaining first image data containing N pixel values corresponding to a row of the original copy;
[0062] In the present application, when copying the image data in the original copy, the width value of the copy frame in the original copy is first determined, wherein the width value represents the number of pixel points contained in a row of image data. For example, assuming that the width value of the original copy is Sw, the height value of the original copy is Sh, the top left corner vertex (Sx0, Sy0) of the copy frame in the original copy is taken as the copy starting point, and the bottom right corner vertex (Sx1, Sy1) of the copy frame in the original copy is taken as the copy ending point. Then, the width value SRw of the copy frame in the original copy is (Sx1–Sx0+1), and the height value SRh of the copy frame in the original copy is (Sy1–Sy0+1), wherein the height value represents the number of pixel points contained in a column of image data.
[0063] Similarly, the width value of the destination image is denoted as DW, the height value of the copy destination image is denoted as DH, the top left corner vertex (Dx0, Dy0) of the copy frame in the copy destination image is taken as the copy starting point, and the bottom right corner vertex (Dx1, Dy1) of the copy frame in the copy destination image is taken as the copy ending point. Then, the width value DRw of the copy frame in the copy destination image is (Dx1–Dx0+1), and the height value DRh of the copy frame in the copy destination image is (Dy1–Dy0+1).
[0064] To make the scheme provided by the present application more specific and reasonable, the above parameters can be defined as follows in the embodiments of the present application.
[0065] (1) 0≤Sx0<Sw, 0≤Sy0<Sh, 0≤Sx1<Sw, 0≤Sy1<Sh, 0≤Sx0<Sx1<Sw, 0≤Sy0<Sy1<Sh.
[0066] (2) 0≤Dx0<Dw, 0≤Dy0<Dh, 0≤Dx1<Dw, 0≤Dy1<Dh, 0≤Dx0<Dx1<Dw, 0≤Dy0<Dy1<Dh.
[0067] (3) 0<Rw, 0<Rh.
[0068] As can be seen from the above, in the embodiments of the present application, the start position of pixel reading is limited within the copy frame in the copy original image. In the image data copying process, the width value of the copy frame in the copy destination image is consistent with the width value of the copy frame in the copy original image, and the height value of the copy frame in the copy destination image is consistent with the height value of the copy frame in the copy original image, therefore, SRw and DRw are uniformly represented by Rw, and SRh and DRh are uniformly represented by Rh.
[0069] After the width value of the copy frame in the copy original image is determined, a row of first image data containing N pixel values is obtained in the copy original image. In the embodiments of the present application, the value of N can be 16, which means that 16 pixel points corresponding to pixel values are contained in each row of image data obtained. Of course, according to the specific situation of the copy image, the value of N can also be 8 or 4. When the program is written to assign a value to N, N can be assigned a value of vxc_uchar16, or vxc_uchar4, vxc_uchar8, of course, N can also be assigned a value of other types of data, such as float, double, etc. The data type corresponding to the value of N is not specifically limited here, and the value of N corresponding to various data types can be used in the embodiments of the present application.
[0070] If the first image data is obtained based on OpenCL, a global identification global id(x, y, z) of a work item Work-item of OpenCL needs to be initialized with a starting offset value globalWorkOffset of (0, 0, 0); a dimension workDim of each work item is set to 2, for operating on two-dimensional data; a step globalWorkScale between each work item can also be set to (16, 1, 0), so that one work item reads one row of 16 pixel points corresponding to pixel values at a time; a global work size localWorkSize of the work item in a group is set to 8, that is, a group contains 8 work items, and the number 8 can also be set to other numbers, mainly for performance tuning.
[0071] Based on the above method, the copy frame in the copy original image can be divided into globalWorkSize work items, and each work item is run in parallel during the OpenCL running process, so that the first image data can be obtained through each work item.
[0072] S12, when the first image data contains valid pixel values and first invalid pixel values, determining a second invalid pixel value corresponding to the first invalid pixel value in the copy target image;
[0073] In the embodiment of the present application, after obtaining the first image data, it is first necessary to determine whether the first image data contains the first invalid pixel value, and the specific determination method can be:
[0074] The specific determination method can be realized according to the coordinates corresponding to the end point position, for example:
[0075] Suppose the top-left vertex (Sx0, Sy0) of the copy frame in the copy original image is taken as the copy starting point, and the bottom-right vertex (Sx1, Sy1) of the copy frame in the copy original image is taken as the copy end point, and idx is taken as the starting point coordinate of each work item of OpenCl, then in OpenCL, the pixel reading starting point position Srcpos corresponding to the current work item is idx+(int2)(Sx0, Sy0), and the pixel writing starting point position Dstpos corresponding to the current work item in the copy target image is idx+(int2)(Dx0, Dy0). During the pixel value reading and writing process, the left-to-right direction is taken as the positive direction.
[0076] In the embodiment of the present application, the coordinates of idx can be determined according to the step length between each work item. For example, when the copy start point coordinates are (0, 0), the step length is set to 5, and the copy frame width is 16, the start point coordinates of other work items are (5, 0), (10, 0), and (15, 0) respectively.
[0077] In the above case, when idx.x+Sx0≤Rw+Sx0≤idx.x+Sx0+N, i.e., idx.x≤Rw≤idx.x+N, it indicates that the horizontal coordinate (idx.x+Sx0) corresponding to the pixel reading start point position is within the copy frame in the copy original image, but after reading N pixel values from the pixel reading start point position, the horizontal coordinate (idx.x+Sx0+N) corresponding to the pixel reading end point position is outside the copy frame in the copy original image, i.e., it indicates that the pixel reading end point position is outside the copy frame in the copy original image.
[0078] When idx.x+Sx0+N≤Rw+Sx0, i.e., idx.x+N≤Rw, it indicates that the horizontal coordinate (idx.x+Sx0+N) corresponding to the pixel reading end point position is within the copy frame in the copy original image, i.e., it indicates that the pixel reading end point position is within the copy frame in the copy original image.
[0079] When idx.x+Sx0≥Rw+Sx0, i.e., idx.x≥Rw, it indicates that the pixel reading start point position (idx.x+Sx0) is outside the copy frame in the copy original image, at this time, the pixel reading end point is of course outside the copy frame in the copy original image.
[0080] The position relationship between the pixel reading end point and the copy frame in the copy original image can be determined by the above method, wherein different position relationships correspond to different processing strategies. When it is determined that the pixel reading start point position and the end point position are both within the copy frame in the copy original image, it indicates that the N pixel values read by the current work item are all from the inside of the copy original image, and therefore the N pixel values can be directly written into the copy destination image.
[0081] Although the embodiment of the present application limits the pixel reading start point position to be within the copy frame in the copy original image, in actual application scenarios, the pixel reading start point position can be outside the copy frame. At this time, when it is determined that the pixel reading start point position and the pixel reading end point position are both outside the copy frame in the copy original image, it indicates that the N pixel values read by the current work item are all from the outside of the copy original image, and therefore the N pixel values can be directly revoked.
[0082] When it is determined that the pixel reading start position is in the copy frame in the copy original image, but the pixel reading end position is out of the copy frame in the copy original image, it indicates that the N pixel values read by the current work item have a part of the pixel values originating from the copy frame in the copy original image, and the part of the pixel values is the valid pixel value, and another part of the pixel values originating from the copy frame out of the copy original image, and the part of the pixel values is the first invalid pixel value. The specific method for determining the valid pixel value and the first invalid pixel value in the first image data can be:
[0083] According to the width value corresponding to the copy frame and the N value, the number of valid pixel values in the first image data is calculated, and the specific calculation method is: the remainder obtained by dividing the width value of the copy frame by the N value is taken as the number of valid pixel values.
[0084] Next, the number of valid pixel values in the first image data is extracted according to the preset rule, and the specific method is: first, the N pixel values in the first image data are arranged according to the pixel reading order, and then the number of pixel values arranged in front of the N pixel values are extracted according to the pixel reading order, to obtain the valid pixel value. Further, the data other than the valid pixel value in the first image data is taken as the first invalid pixel value.
[0085] After the valid pixel value and the first invalid pixel value in the first image are determined by the above method, in order to avoid the first invalid pixel value being written into the region corresponding to the copy destination image in the subsequent image copying process, thereby improving the image copying quality, the method adopted by the present application is to replace the first invalid pixel value with the second invalid pixel value corresponding to the copy destination image. Therefore, the second invalid pixel value corresponding to the first invalid pixel value needs to be determined in the copy destination image next, and the specific determination method can be:
[0086] determining the pixel writing start point corresponding to the valid pixel value in the copy destination image;
[0087] According to the pixel writing start point, a row of third image data containing N pixel values is read in the copy destination image;
[0088] According to the number of pixel values corresponding to the first invalid pixel value, the second invalid pixel value with the number of pixel values is extracted from the third image data, wherein the arrangement position of the second invalid pixel value in the third image data is consistent with the arrangement position of the first invalid pixel value in the first image data.
[0089] For example, referring to Figure 2a , in Figure 2aIn the diagram, (x, y) represents a two-dimensional coordinate system. The large rectangle represents the original image to be copied, and the small rectangle represents the copy frame within the original image. The two circles within the small rectangle represent valid pixel values, and the small squares outside the small rectangle and inside the large rectangle represent the first invalid pixel values, where the first invalid pixel value corresponds to a value of 1. To obtain the second invalid pixel value corresponding to the first invalid pixel value in the copied destination image, refer to... Figure 2b ,exist Figure 2b The large rectangle in the image represents the destination image to be copied, and the small rectangle represents the copy box within the destination image. Then confirm. Figure 2a The coordinates corresponding to the starting position of the pixel are read and then... Figure 2b Using the position corresponding to the same coordinate in the coordinate system as the starting point, the pixel values in the target image are read and copied. The obtained pixel values are as follows: Figure 2b As shown in the diagram of the three triangles, the last triangle among the three is taken as the second invalid pixel value.
[0090] The above method can be used to obtain the valid pixel values in the first image data and the second invalid pixel values in the copied destination image.
[0091] S13, the valid pixel values and the second invalid pixel values are recombined to obtain the second image data, and the second image data is written to the copy destination image.
[0092] After obtaining the valid pixel values from the first image data and the second invalid pixel values from the target image, the valid and invalid pixel values are recombined to obtain the second image data, where the number of pixels in the second image data is the same as the number of pixels in the first image data. Then, the second image data is written into the target image. This method avoids writing the first invalid pixel values into the target image, thereby improving image copying quality. For example, refer to... Figure 2c ,exist Figure 2c In the middle, the two small circles are Figure 2a The effective pixel values shown in the diagram, with one small triangle representing... Figure 2b The second invalid pixel value in the image is combined with the valid pixel value and the second invalid pixel value, and then written into the copy destination image to obtain the result as shown below. Figure 2c The image shown is of the target copy. Figure 2c Not included Figure 2a Invalid pixel values in the data.
[0093] To more clearly and in detail illustrate the scheme provided in this application for repeating the valid pixel values in the first image data and the second invalid pixel values in the copied destination image, an example based on OpenCL is given below:
[0094] First, define an array variable tmpA of type vxc_uchar16 and initialize it as {0, 1,..., 15}, so that the 16 numbers saved in tmpA are {0, 1,..., 15}.
[0095] Then, define an array variable dst_data of type vxc_uchar16, which is used to save 16 pixel values read from the start position Dstpos of the pixel read in the destination image.
[0096] Next, when copying the data in the boundary region of the source image, the remainder of Rw%16 is calculated, and the remainder is used as the number of valid pixel values in the current work item. If the width value of the copy frame in the source image is 327 pixel points, 16 pixel values are read each time, the first 20 times read the first 320 pixel values in the copy frame of the source image, the 21st time reads the last 7 pixel values in the copy frame of the source image and 9 pixel values outside the copy frame of the source image, and the remainder of 327 divided by 16 is exactly 7. In this way, it can be determined that the first 7 pixel values in the current work item are valid, and the last 9 pixel values are invalid.
[0097] Further, define a variable tmpB of type vxc_uchar16, and assign the remainder n of Rw%16 to tmpB, so that the 16 data in tmpB are {n, n,..., n}. When n is 7, the 16 data in tmpB are all {7, 7,..., 7}.
[0098] Further, define a variable tmpdst_data of type vxc_uchar16, wherein tmpdst_data can be assigned by the formula tmpdst_data = tmpA < tmpB? src_data: dst_data, and then the valid pixel values in the first image data src_data corresponding to the current work item of the source image and the second invalid pixel values in the N pixel value data dst_data obtained from the destination image are saved.
[0099] In the tmpA<tmpB comparison process, the first n data in tmpA stores {0, 1, …, n-1}, and tmpB stores all numbers n, therefore, the first n data satisfy tmpA<tmpB, and the first n data of src_data are assigned to tmpdst_data; the last 16-n data in tmpA stores {n, …, 15}, and tmpB stores all numbers n, therefore, the last 16-n data do not satisfy tmpA<tmpB, and the last 16-n data of dst_data are assigned to tmpdst_data. Through this method, the first n data in the 16 data stored in tmpdst_data are the first n valid pixel values in src_data, and the last 16-n data are the last 16-n data in dst_data.
[0100] Finally, the 16 pixels of the obtained tmpdst_data are all written into the copy destination image, and the copy task corresponding to the current work item is completed.
[0101] Based on the above data processing method, when the image data obtained from the copy original image contains valid pixel values and invalid pixel values, the valid pixel values are recombined with the invalid pixel values in the copy destination image, and the recombined image data is written into the copy destination image, which can avoid writing the invalid pixel values corresponding to the copy original image into the region corresponding to the copy destination image, thereby improving the image data copy quality.
[0102] In addition, by judging whether the pixel reading end position is outside the copy frame in the copy original image, it is further judged whether the current work item contains invalid pixel values, which is simple in logic and convenient to operate. Moreover, the OpenCL self-programming form can be used to implement, the code logic is simple, the universality is strong, and the number of pixels and the number of rows read by the work item each time can be modified by modifying the corresponding code according to actual application requirements.
[0103] Based on the same inventive concept, the embodiment of the present application also provides a data processing device, as shown in Figure 3 The device includes:
[0104] The acquisition module 31 is configured to acquire a first image data corresponding to a row of the copy original image and containing N pixel values, wherein the value of N is determined according to the pixel reading performance and the number of pixel points of the copy original image.
[0105] The extraction module 32 is configured to, when it is determined that the first image data contains valid pixel values and first invalid pixel values, extract a second invalid pixel value corresponding to the first invalid pixel value in the copy destination image.
[0106] The writing module 33 is configured to recombine the valid pixel value and the second invalid pixel value to obtain second image data, and write the second image data into the copy destination image.
[0107] In a possible design, the apparatus further includes:
[0108] The determining module is configured to determine whether the pixel reading end position is outside the copy frame in the copy original image.
[0109] The determining module is configured to determine that the valid pixel value and the first invalid pixel value are included in the first image data if the pixel reading end position is outside the copy frame, and determine that only the valid pixel value is included in the first image data if the pixel reading end position is inside the copy frame.
[0110] In a possible design, the extracting module 32 is further configured to:
[0111] The number of valid pixel values in the first image data is calculated according to the width value corresponding to the copy frame and the N value, where the width value represents the number of pixel points included in one row of image data.
[0112] The number of valid pixel values is extracted from the first image data according to a preset rule.
[0113] Data other than the valid pixel value in the first image data is taken as the first invalid pixel value.
[0114] In a possible design, the extracting module 32 is further configured to:
[0115] The pixel writing start point corresponding to the valid pixel value in the copy destination image is determined.
[0116] Third image data including N pixel values in one row is read from the copy destination image according to the pixel writing start point.
[0117] The second invalid pixel value is extracted from the third image data according to the number of pixel values corresponding to the first invalid pixel value, where the arrangement position of the second invalid pixel value in the third image data is consistent with the arrangement position of the first invalid pixel value in the first image data.
[0118] In a possible design, the apparatus further includes:
[0119] The processing module is configured to write the first image data into the copy destination image when it is determined that only the valid pixel value is included in the first image data, and cancel the first image data when it is determined that only the invalid pixel value is included in the first image data.
[0120] Based on the above data processing device, when the image data obtained in the copy original image contains valid pixel values and invalid pixel values, the valid pixel values are recombined with the invalid pixel values in the copy target image, and the recombined image data is written into the copy target image. This method can avoid writing the invalid pixel values corresponding to the copy original image into the area corresponding to the copy target image, thereby improving the image data copy quality.
[0121] Based on the same inventive concept, the embodiments of the present application also provide an electronic device, which can realize the functions of the foregoing data processing device, and the functions of the foregoing data processing device are described in the foregoing method embodiments, and details are not described herein. Figure 4 The electronic device includes:
[0122] at least one processor 41 and a memory 42 connected with the at least one processor 41, and the specific connection medium between the processor 41 and the memory 42 is not limited in the embodiments of the present application, Figure 4 In the foregoing embodiments, the connection between the processor 41 and the memory 42 is taken by way of example through a bus 40. The bus 40 is represented by a thick line in Figure 4 the foregoing embodiments, and the connection modes between other components are only schematically illustrated and are not limited. The bus 40 can be divided into an address bus, a data bus, a control bus and the like, and for the convenience of representation, Figure 4 in the foregoing embodiments, only one thick line is used, but it does not mean that there is only one bus or only one type of bus. Alternatively, the processor 41 can also be referred to as a controller, and the name is not limited.
[0123] In the embodiments of the present application, the memory 42 stores instructions executable by the at least one processor 41, and the at least one processor 41 can execute the foregoing data processing method by executing the instructions stored in the memory 42. The processor 41 can realize the functions of various modules in the device shown in Figure 3 .
[0124] The processor 41 is the control center of the device, and can connect all parts of the entire control device through various interfaces and lines, and through running or executing the instructions stored in the memory 42 and calling the data stored in the memory 42, the device processes various functions and data, thereby monitoring the entire device.
[0125] In a possible design, the processor 41 can include one or more processing units, and the processor 41 can integrate an application processor and a modem processor, wherein the application processor mainly processes operating systems, user interfaces and application programs, and the modem processor mainly processes wireless communication. It can be understood that the foregoing modem processor can also not be integrated into the processor 41. In some embodiments, the processor 41 and the memory 42 can be implemented on the same chip, and in some embodiments, they can also be implemented on independent chips respectively.
[0126] The processor 41 can be a general processor, such as a central processing unit (CPU), a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic component, a discrete hardware component, and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or any conventional processor. The steps of the data processing method disclosed in the embodiments of the present application can be directly embodied as hardware processor execution or executed by a combination of hardware and software modules in the processor.
[0127] The memory 42 is a non-volatile computer readable storage medium, which can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 42 can include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card type memory, random access memory (RAM), static random access memory (SRAM), programmable read only memory (PROM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. The memory 42 is any other medium capable of carrying or storing desired program code in the form of instructions or data structures and capable of being accessed by a computer, but is not limited to this. The memory 42 in the embodiments of the present application can also be a circuit or any other device capable of realizing the storage function, used for storing program instructions and / or data.
[0128] By designing and programming the processor 41, the code corresponding to the data processing method introduced in the foregoing embodiments can be fixed in the chip, so that the chip can execute the steps of the data processing method of the embodiments shown in the running time. Figure 1 How to design and program the processor 41 is a technology known to those skilled in the art, which will not be described here.
[0129] Based on the same inventive concept, the embodiments of the present application also provide a storage medium storing computer instructions, which, when running on a computer, enable the computer to execute the data processing method discussed above.
[0130] In some possible implementation, each of the aspects of the data processing method provided by the present application can also be implemented in the form of a program product, which includes program codes for causing the control device to perform the steps of the data processing method according to various exemplary embodiments of the present application described above in the specification when the program product is run on the device.
[0131] Those skilled in the art should understand that embodiments of the present application can be provided in the form of a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) containing computer-usable program codes.
[0132] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as a combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus generate a means for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 an apparatus for implementing functions specified in one or more flows and / or blocks.
[0133] These computer program instructions can also be stored in a computer-readable memory that can direct the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including instruction apparatus, which implements the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 one or more flows and / or blocks.
[0134] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable data processing apparatus to produce a computer-implemented process, so that the instructions executed on the computer or other programmable data processing apparatus provide a process for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 one or more flows and / or blocks.
[0135] Obviously, many modifications and variations of the present application are possible in light of the above teachings. It is, therefore, to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.
Claims
1. A data processing method, characterized by, The method comprises: acquiring first image data corresponding to a row of the copy original image containing N pixel values, wherein the value of N is determined according to the pixel reading performance and the number of pixel points of the copy original image; when it is determined that the first image data contains valid pixel values and first invalid pixel values, extracting second invalid pixel values corresponding to the first invalid pixel values in the copy target image, wherein the pixel values outside the copy frame in the copy original image are the first invalid pixel values, and the pixel values outside the copy frame in the copy target image are the second invalid pixel values; recombining the valid pixel values and the second invalid pixel values to obtain second image data, and writing the second image data into the copy target image; the extracting of the second invalid pixel values corresponding to the first invalid pixel values in the copy target image comprises: determining a pixel writing starting point corresponding to the valid pixel values in the copy target image; reading third image data containing N pixel values in a row in the copy target image according to the pixel writing starting point; extracting second invalid pixel values of the pixel value number in the third image data according to the pixel value number corresponding to the first invalid pixel values, wherein the arrangement position of the second invalid pixel values in the third image data is consistent with the arrangement position of the first invalid pixel values in the first image data.
2. The method of claim 1, wherein, before it is determined that the first image data contains valid pixel values and first invalid pixel values, comprising: judging whether the pixel reading endpoint position is outside the copy frame in the copy original image; if yes, determining that the first image data contains the valid pixel values and the first invalid pixel values; if no, determining that the first image data only contains the valid pixel values.
3. The method of claim 2, wherein, the determination of the valid pixel values and the first invalid pixel values contained in the first image data comprises: calculating the number of valid pixel values in the first image data according to the width value corresponding to the copy frame and the value of N, wherein the width value represents the number of pixel points contained in a row of image data; extracting the number of valid pixel values in the first image data according to a preset rule; regarding the data other than the valid pixel values in the first image data as the first invalid pixel values.
4. The method of claim 2, wherein, after the second image data is written into the copy target image, further comprising: when it is determined that the first image data only contains valid pixel values, writing the first image data into the copy target image; when it is determined that the first image data only contains invalid pixel values, canceling the first image data.
5. A data processing apparatus, characterized by, The device comprises: an acquisition module configured to acquire first image data corresponding to a row of the copy original image containing N pixel values, wherein the value of N is determined according to the pixel reading performance and the number of pixel points of the copy original image; extracting a second invalid pixel value corresponding to the first invalid pixel value in a copy destination image when it is determined that the first image data contains valid pixel values and the first invalid pixel values, wherein the first invalid pixel values are pixel values located outside a copy frame in a copy original image, and the second invalid pixel values are pixel values located outside a copy frame in the copy destination image; a writing module, configured to recombine the valid pixel values and the second invalid pixel values to obtain second image data, and write the second image data into the copy destination image; the extraction module is further configured to: determine a pixel writing start point corresponding to the valid pixel values in the copy destination image; read third image data containing N pixel values in a row in the copy destination image according to the pixel writing start point; extract second invalid pixel values in the third image data according to a number of pixel values corresponding to the first invalid pixel values, wherein the arrangement positions of the second invalid pixel values in the third image data are consistent with the arrangement positions of the first invalid pixel values in the first image data.
6. The apparatus of claim 5, wherein, The device further comprises: a determination module, configured to determine that the first image data contains the valid pixel values and the first invalid pixel values if the pixel reading end position is outside the copy frame in the copy original image, and determine that the first image data contains only the valid pixel values if the pixel reading end position is inside the copy frame. the extraction module is further configured to:
7. The apparatus of claim 6, wherein, calculate a number of valid pixel values in the first image data according to a width value corresponding to the copy frame and the N value, wherein the width value represents a number of pixel points contained in a row of image data; extract the number of valid pixel values in the first image data according to a preset rule; treat data other than the valid pixel values in the first image data as the first invalid pixel values. The device further comprises:
8. The apparatus of claim 6, wherein, a processing module, configured to write the first image data into the copy destination image when it is determined that the first image data contains only valid pixel values, and cancel the first image data when it is determined that the first image data contains only invalid pixel values. comprises:
9. An electronic device, comprising: a memory, configured to store a computer program; a processor, configured to execute the computer program stored in the memory to implement the method steps in any one of claims 1-4. The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the method steps in any one of claims 1-4.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the method steps in any one of claims 1-4.
Citation Information
Patent Citations
Method and device for character superimposition of video image
CN105450942A
Implementation method of GPU copy buffer area based on OpenGL copy command
CN111047501A