CN111553847B - Image processing method and device - Google Patents

Image processing method and device Download PDF

Info

Publication number
CN111553847B
CN111553847B CN202010411870.3A CN202010411870A CN111553847B CN 111553847 B CN111553847 B CN 111553847B CN 202010411870 A CN202010411870 A CN 202010411870A CN 111553847 B CN111553847 B CN 111553847B
Authority
CN
China
Prior art keywords
picture
bit array
packaged
pixel
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010411870.3A
Other languages
Chinese (zh)
Other versions
CN111553847A (en
Inventor
温俊城
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202010411870.3A priority Critical patent/CN111553847B/en
Publication of CN111553847A publication Critical patent/CN111553847A/en
Application granted granted Critical
Publication of CN111553847B publication Critical patent/CN111553847B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4038Image mosaicing, e.g. composing plane images from plane sub-images
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2200/00Indexing scheme for image data processing or generation, in general
    • G06T2200/32Indexing scheme for image data processing or generation, in general involving image mosaicing

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)

Abstract

The application provides an image processing method and device, wherein the method comprises the following steps: acquiring a target picture and at least one picture to be packaged; creating a first bit array for representing whether a pixel is occupied based on a target picture; creating a second bit array for representing whether the pixel is a valid pixel based on the picture to be packed; comparing the second bit array with the first bit array to determine whether the picture to be packaged can be inserted into the target picture; if the picture to be packaged can be inserted into the target picture, writing the pixels of the picture to be packaged into the corresponding positions of the target picture. The packing utilization rate for improving the target image is low.

Description

Image processing method and device
Technical Field
The present disclosure relates to the field of computer image processing, and in particular, to an image processing method and apparatus.
Background
Currently, in order to facilitate transmission of a plurality of images to be packaged, the plurality of images to be packaged are generally packaged into a target picture.
In the related art, a method of packing a plurality of images to be packed into a target image generally includes: and carrying out rectangular segmentation on the target image with the rectangular shape according to the size of each image to be packaged to obtain a rectangular writing area of each image to be packaged in the target image, and then inserting the image to be packaged into the corresponding rectangular writing area. In the above process, the image to be packaged is inserted into the corresponding rectangular writing area, resulting in low packaging utilization rate of the target image.
Disclosure of Invention
The application provides an image processing method and device, which are used for improving low packaging utilization rate of a target image.
In a first aspect, the present application provides an image processing method, including:
acquiring a target picture and at least one picture to be packaged;
creating a first bit array for representing whether a pixel is occupied based on a target picture;
creating a second bit array for representing whether the pixel is a valid pixel based on the picture to be packed;
comparing the second bit array with the first bit array to determine whether the picture to be packaged can be inserted into the target picture;
if the picture to be packaged can be inserted into the target picture, writing the pixels of the picture to be packaged into the corresponding positions of the target picture.
In one possible implementation, comparing the second bit array with the first bit array to determine whether the picture to be packed can be inserted into the target picture includes:
creating a line processing thread according to each line of the first bit array;
and based on the line processing thread, executing the comparison between the second bit array and each line of the first bit array, and determining whether the picture to be packaged can be inserted into the target picture.
In one possible implementation, determining whether the picture to be packed can be inserted into the target picture based on the line processing thread executing the comparison of the second bit array and each line of the first bit array includes:
and executing at least one second numerical value in the second numerical array and at least one first numerical value in the first numerical array based on the line processing thread to compare, and if the comparison operation is successful, determining that the picture to be packaged can be inserted into the target picture.
In one possible implementation, the corresponding value occupied by a pixel in the first bit array is 1 and the corresponding value not occupied by a pixel is 0.
In one possible implementation, the corresponding value of the valid pixel in the second bit array is 1, and the corresponding value of the invalid pixel is 0.
In one possible implementation, writing pixels of a picture to be packed into corresponding positions of a target picture includes:
and updating the first value to 1 if the result of the operation of the second value of the pixel bit corresponding to the pixel and the first value of the pixel bit in the corresponding position is 1.
In one possible implementation, obtaining at least a picture to be packaged includes:
acquiring the picture size of at least one packed picture;
and carrying out size sorting treatment on at least one packed picture according to the picture size of each packed picture to obtain a picture set, wherein the picture set comprises at least one picture to be packed, and the at least one picture to be packed is orderly arranged from small to large or from large to small according to the size.
In a second aspect, the present application provides an image processing apparatus comprising: the system comprises an acquisition module, a first creation module, a second creation module, a determination module and a writing module, wherein,
the acquisition module is used for acquiring a target picture and at least one picture to be packaged;
the first creation module is used for creating a first bit array used for representing whether pixels are occupied or not based on the target picture;
the second creating module is used for creating a second bit array used for representing whether the pixel is a valid pixel or not based on the picture to be packaged;
the determining module is used for comparing the second bit array with the first bit array to determine whether the picture to be packaged can be inserted into the target picture or not;
the writing module is used for writing pixels of the picture to be packaged into corresponding positions of the target picture if the picture to be packaged is determined to be capable of being inserted into the target picture.
In one possible implementation, the determining module is specifically configured to:
creating a line processing thread according to each line of the first bit array;
and based on the line processing thread, executing the comparison between the second bit array and each line of the first bit array, and determining whether the picture to be packaged can be inserted into the target picture.
In one possible implementation, the determining module is specifically configured to:
and executing at least one second numerical value in the second numerical array and at least one first numerical value in the first numerical array based on the line processing thread to compare, and if the comparison operation is successful, determining that the picture to be packaged can be inserted into the target picture.
In one possible implementation, the corresponding value occupied by a pixel in the first bit array is 1 and the corresponding value not occupied by a pixel is 0.
In one possible implementation, the corresponding value of the valid pixel in the second bit array is 1, and the corresponding value of the invalid pixel is 0.
In one possible implementation, the writing module is specifically configured to:
and updating the first value to 1 if the result of the operation of the second value of the pixel bit corresponding to the pixel and the first value of the pixel bit in the corresponding position is 1.
In one possible implementation, the obtaining module is specifically configured to:
acquiring the picture size of at least one packed picture;
and carrying out size sorting treatment on at least one packed picture according to the picture size of each packed picture to obtain a picture set, wherein the picture set comprises at least one picture to be packed, and the at least one picture to be packed is orderly arranged from small to large or from large to small according to the size.
In a third aspect, the present application provides an image processing apparatus comprising: a processor and a memory;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored in the memory, causing the processor to perform the image processing method according to any one of the first aspect.
In a fourth aspect, the present application provides a readable storage medium comprising a program or instructions which, when run on a computer, performs the image processing method according to any one of the first aspects described above.
The application provides an image processing method and device, wherein the method comprises the following steps: acquiring a target picture and at least one picture to be packaged; creating a first bit array for representing whether a pixel is occupied based on a target picture; creating a second bit array for representing whether the pixel is a valid pixel based on the picture to be packed; comparing the second bit array with the first bit array to determine whether the picture to be packaged can be inserted into the target picture; if the picture to be packaged can be inserted into the target picture, writing the pixels of the picture to be packaged into the corresponding positions of the target picture. In the method, the second bit array is compared with the first bit array, if the picture to be packaged can be inserted into the target picture, the pixels of the picture to be packaged are written into the corresponding positions of the target picture, the positions which can be written into the pixels but not written into the pixels in the target picture can be avoided, and the packaging utilization rate of the target image is improved.
Drawings
For a clearer description of the technical solutions of the present application or of the prior art, the drawings that are used in the description of the embodiments or of the prior art will be briefly described, it being obvious that the drawings in the description below are some embodiments of the invention, and that other drawings can be obtained from them without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of image processing by a binary tree segmentation method based on a rectangle in the prior art;
FIG. 2 is a schematic diagram of image processing in the prior art;
FIG. 3 is a flowchart illustrating a first embodiment of an image processing method provided in the present application;
FIG. 4 is a schematic diagram of a target picture and a first bit array according to the present invention;
FIG. 5 is a schematic diagram of a picture to be packaged and a second bit array according to the present invention;
FIG. 6 is a schematic diagram of a comparison of a second bit array with a first bit array provided in the present application;
FIG. 7 is a schematic diagram of obtaining a pixel bit corresponding or operation result provided in the present application;
FIG. 8 is a second flow chart of the image processing method provided in the present application;
FIG. 9 is a schematic image processing diagram obtained according to the image processing method provided in the present application;
fig. 10 is a schematic structural view of an image processing apparatus provided in the present application;
fig. 11 is a schematic hardware structure of the image processing apparatus provided in the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the present application more apparent, the technical solutions in the present application will be clearly and completely described below with reference to the drawings in the present application, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The terms "first," "second," "third," "fourth" and the like in the description and in the claims and in the above drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Fig. 1 is a schematic diagram of image processing performed by a binary tree segmentation method based on a rectangle in the prior art. A very large blank picture (which may be referred to as a target picture) is first set. Since the maximum utilization of the target pictures is considered, all the pictures to be packaged can be subjected to size sorting in advance. The largest picture is placed in the upper left corner and the next largest picture is spread out once to the right. As shown in fig. 1, the largest picture 11 is placed in the upper left corner of the blank picture, and then the remaining area can be divided into two parts: 12 and 13 for placing further pictures to be packed later. Repeating this logic, then all pictures can be packed into the target picture.
In the prior art shown in fig. 1, when the picture to be packaged is a rectangular picture, image processing may be performed by a binary tree segmentation method based on a rectangle. If the picture to be packaged is not a rectangular picture, image processing cannot be performed through a binary tree segmentation method based on the rectangle, so that the application range of performing image processing through the binary tree segmentation method based on the rectangle is smaller. Fig. 2 is a schematic diagram of image processing in the prior art. As shown in fig. 2, if the picture to be packaged is irregularly shaped or includes hollowed-out parts, the picture to be packaged can only be used as a rectangle when the packaging process is performed, and a large blank gap exists in the area of the target picture occupied by the rectangle, so that the packaging utilization rate of the target image is low.
In the application, the application provides an image processing method, when a region capable of being written with pixels exists in some rectangular writing regions, pixels of a packaged picture can be written into the region capable of being written with pixels in the rectangular writing regions, so that the packaging utilization rate of a target image is improved.
The technical scheme of the invention is described in detail below by specific examples. The following embodiments may be combined with each other, and some embodiments may not be repeated for the same or similar concepts or processes.
Fig. 3 is a schematic flow chart of an image processing method provided in the present application. As shown in fig. 3, the image processing method provided in this embodiment includes:
s201: and obtaining the target picture and at least one picture to be packaged.
Alternatively, the execution body of the embodiment of the present application may be an electronic device, and may be an image processing apparatus provided in the electronic device, where the image processing apparatus may be implemented by a combination of software and/or hardware.
Alternatively, the electronic device may be a computer processing device such as a desktop computer, a notebook computer, or the like.
Alternatively, the target picture and the picture to be packaged may be arbitrarily shaped pictures, for example: any shape may be rectangular, circular, triangular, parallelogram, wherein any shape may have any size.
Alternatively, the target picture may be determined according to size information set by the developer. For example: when the size information set by the developer is 2048×2048, a target picture with a size of 2048×2048 can be established according to 2048×2048.
Specifically, at least one picture to be packaged, which is stored in a preset manner, can be obtained from a preset memory.
S202: a first bit array is created based on the target picture to indicate whether the pixel is occupied.
The first bit array is a pixel bit array determined according to a maximum rectangular picture corresponding to the target picture, wherein the maximum rectangular picture is a maximum circumscribed rectangle of the target picture.
Specifically, the first bit number group includes the number of pixel bits equal to the product of the number of pixels on the long side of the picture and the number of pixels on the short side of the picture, where the long side of the picture is the long side of the maximum rectangular picture, and the short side of the picture is the short side of the maximum rectangular picture.
Further, please refer to the target picture and the first bit array shown in fig. 4. Fig. 4 is a schematic diagram of a target picture and a first bit array according to the present invention. As shown in fig. 4, includes: a target picture 31, a maximum rectangular picture 32, and a first bit array 33, the maximum rectangular picture 32 being a maximum circumscribed rectangular picture of the target picture 31 and being a picture including an integer number of pixels, the first bit array 33 being a pixel bit array determined from the maximum rectangular picture 32, for example: the first bit array 33 determined from the maximum rectangular picture 32 is a bit array including 40 pixel bits. Wherein 40 pixel bits (the first values are all 0) are equal to the product of the number of pixels 8 on the long side of the picture and the number of pixels 5 on the short side of the picture of the maximum rectangular picture 32. In practice, the largest rectangular picture 32 may be determined from the target picture 31, and then the first bit array 33 may be obtained from the largest rectangular picture 32. In fig. 4, when a pixel of any picture to be packed is not written into the target picture 31, the first value of each pixel bit in the first bit array 33 is 0, and when the first value of the pixel bit is 0, it indicates that the pixel bit can be written into the pixel.
S203: a second bit array is created based on the picture to be packed to indicate whether the pixel is a valid pixel.
The effective pixel is a pixel having a transparency of not 0, and the ineffective pixel is a pixel having a transparency of 0.
Specifically, a second bit array corresponding to each picture to be packaged is created. Further, taking a picture to be packaged and a second bit array corresponding to the picture to be packaged as an example, with reference to fig. 5, the creation of the second bit array will be described. Fig. 5 is a schematic diagram of a picture to be packaged and a second bit array according to the present invention. As shown in fig. 5, includes: the to-be-packed picture 41, a maximum to-be-packed picture 42, and a second bit array 43, where the maximum to-be-packed picture 42 is a maximum circumscribed rectangular picture of the to-be-packed picture 41 and is a picture including an integer number of pixels, and the second bit array 43 is an integer bit array obtained according to the maximum to-be-packed picture 42, for example: the second bit array 43 obtained from the largest picture to be packed 42 is a bit array comprising 16 pixel bits. Wherein the 16 pixel bits are equal to the product of the number of pixels 4 on the long side of the picture and the number of pixels 4 on the short side of the picture of the maximum picture 42 to be packed. In fig. 5, the second value of the pixel bit in the second bit array 43 indicates that the pixel corresponding to the pixel bit is an effective pixel when the second value is "1", and indicates that the pixel corresponding to the pixel bit is an ineffective pixel when the second value is "0".
S204: and comparing the second bit array with the first bit array to determine whether the picture to be packaged can be inserted into the target picture.
Specifically, each second value included in the second bit array is and-operated with each first value included in the corresponding position of the first bit array, thereby realizing the comparison of the second bit array with the first bit array. If the sum operation result is 1, it is determined that the picture to be packaged can be inserted into the target picture. The corresponding position is the same as the second bit array in size in the first bit array, and in particular, please refer to fig. 6. FIG. 6 is a schematic diagram of comparing a second bit array with a first bit array according to the present application. As shown in fig. 6, includes: second bit array 51, first bit array 52, and operation result bit array 53, and corresponding locations 54, 55, 56, and 57. Alternatively, the corresponding position may be determined in the first bit array 52 from the second bit array 51, for example: the respective location may be any of the respective locations 54, 55, 56, or 57. When the corresponding position is the corresponding position 54, performing an and operation on the second value of each pixel bit in the second bit array 51 and the first value of each pixel bit in the corresponding position 54, and if the and operation results are both 0, determining that the picture to be packaged can be inserted into the target picture. In fig. 6, the second value of each pixel bit in the second bit array 51 and the first value of each pixel bit in the corresponding position 54 are anded, and the value of each pixel bit in the and operation result bit array 53 is 0, so that it can be determined that the picture to be packed can be inserted into the target picture.
S205: if the picture to be packaged can be inserted into the target picture, writing the pixels of the picture to be packaged into the corresponding positions of the target picture.
In one possible implementation, writing pixels of a picture to be packed into corresponding positions of a target picture includes: and updating the first value to 1 if the result of the operation of the second value of the pixel bit corresponding to the pixel and the first value of the pixel bit in the corresponding position is 1.
Specifically, the second value of each pixel bit in the second bit array and the first value of each pixel bit in the corresponding position are subjected to OR operation to obtain an OR operation result corresponding to each pixel bit, and the first value of each pixel bit in the corresponding position is updated to be the OR operation result 1 corresponding to the pixel bit, so that the pixel of the picture to be packaged is written into the corresponding position of the target picture. Specifically, please refer to fig. 7. Fig. 7 is a schematic diagram of obtaining a pixel bit corresponding or operation result provided in the present application. As shown in fig. 7, includes: a second bit array 61, a first bit array 62, an updated first bit array 63, a corresponding location 64 and a corresponding location 65. Specifically, the second value of each pixel bit in the second bit array 61 is or-operated with the first value of each pixel bit in the corresponding position 64 to obtain a corresponding or-operated result (corresponding position 65) of each pixel bit, and the first value of each pixel bit in the corresponding position 64 is updated to the corresponding or-operated result of the pixel bit, thereby obtaining an updated first bit array 63. In the updated first bit array 63, the corresponding value occupied by a pixel is 1 and the corresponding value not occupied by a pixel is 0.
It should be noted that, for the second bit array corresponding to each picture to be packaged, S204 to S205 are sequentially executed until all pixels of the picture to be packaged are written into the corresponding positions (positions corresponding to the picture to be packaged) in the target picture.
Unlike the prior art, in the method for performing image processing based on the rectangular binary tree segmentation method, the target picture needs to be a rectangular picture, so that the application range of the method for performing image processing based on the rectangular binary tree segmentation method is smaller. In the application, the target picture in the image processing method provided by the application can be a picture with any shape, so that the image processing method shown by the application can be applied in a wider range.
The image processing method provided in the embodiment includes: acquiring a target picture and at least one picture to be packaged; creating a first bit array for representing whether a pixel is occupied based on a target picture; creating a second bit array for representing whether the pixel is a valid pixel based on the picture to be packed; comparing the second bit array with the first bit array to determine whether the picture to be packaged can be inserted into the target picture; if the picture to be packaged can be inserted into the target picture, writing the pixels of the picture to be packaged into the corresponding positions of the target picture. In the method, the second bit array is compared with the first bit array, if the picture to be packaged can be inserted into the target picture, the pixels of the picture to be packaged are written into the corresponding positions of the target picture, the positions which can be written into the pixels but not written into the pixels in the target picture can be avoided, and the packaging utilization rate of the target image is improved.
The image processing method provided in the present application is described in further detail below with reference to fig. 8, and in particular, please refer to the embodiment of fig. 8.
Fig. 8 is a second flowchart of an image processing method provided in the present application. As shown in fig. 8, the image processing method provided in this embodiment includes:
s701: and obtaining a target picture.
Specifically, the execution method of S701 is the same as that of S201, and the execution process of S701 is not described here again.
S702: a picture size of at least one packed picture is obtained.
Specifically, measurement processing is performed on each packaged picture, and the picture size of each packaged picture is obtained.
S703: and carrying out size sorting treatment on at least one packed picture according to the picture size of each packed picture to obtain a picture set, wherein the picture set comprises at least one picture to be packed, and the at least one picture to be packed is orderly arranged from small to large or from large to small according to the size.
It should be noted that, a packed picture corresponding to a picture to be packed is the same as the packed picture corresponding to the picture to be packed.
S704: and distributing the sequence numbers to the at least one picture to be packaged according to the arrangement sequence of the at least one picture to be packaged from small to large or from large to small.
For example, when at least one picture to be packaged is arranged from small to large according to the size, the respective sequence numbers of the at least one picture to be packaged are also arranged from small to large. For example, when at least one picture to be packaged is arranged according to the size from large to small, the sequence numbers allocated to the at least one picture to be packaged are also arranged according to the size from large to small.
Alternatively, the sequence number may be 1, 2, 3, etc.
S705: and acquiring a picture to be packaged from the picture set, wherein the serial number of the picture to be packaged is N, and N is the maximum serial number in the serial numbers.
For example, the at least one picture to be packaged includes a first picture to be packaged, a second picture to be packaged, and a third picture to be packaged, wherein the first picture to be packaged has a sequence number of 1, the second picture to be packaged has a sequence number of 2, and the third picture to be packaged has a sequence number of 3, and the obtained one picture to be packaged is the third picture to be packaged.
S706: and judging whether N is 0.
If yes, S713 is performed.
If not, then S707 through S712 are performed.
S707: a second bit array is created based on the picture to be packed to indicate whether the pixel is a valid pixel.
Specifically, the execution method of S707 is the same as the execution method of S203, and here, the execution process of S707 is not described in detail.
S708: a first bit array is created based on the target picture to indicate whether the pixel is occupied.
Specifically, the execution method of S708 is the same as that of S202, and here, the execution process of S708 is not repeated.
S709: a line processing thread is created for each line of the first bit array.
Specifically, the number of line processing threads is the same as the number of lines of the first bit array.
For example, if the number of lines of the first bit array is 5, the number of 5 lines of processing threads is also 5.
S710: and based on the line processing thread, executing the comparison between the second bit array and each line of the first bit array, and determining whether the picture to be packaged can be inserted into the target picture.
In one possible implementation, determining whether the picture to be packed can be inserted into the target picture based on the line processing thread executing the comparison of the second bit array and each line of the first bit array includes: and executing at least one second numerical value in the second numerical array and at least one first numerical value in the first numerical array based on the line processing thread to compare, and if the comparison operation is successful, determining that the picture to be packaged can be inserted into the target picture.
Wherein, the AND operation success means that the AND operation result of the at least one second numerical value and the at least one first numerical value is 0. Specifically, the second value of each pixel bit in the second bit array 51 and the first value of each pixel bit in the corresponding location 54 are summed as shown in fig. 6.
S711: if the picture to be packaged can be inserted into the target picture, writing the pixels of the picture to be packaged into the corresponding positions of the target picture.
Specifically, the execution method of S711 is the same as that of S205, and here, the execution process of S711 is not described again.
S712: updating N to N-1, updating the picture set, and deleting the picture to be packaged with the sequence number N in the picture set.
S713: and (5) ending.
The image processing method provided in the embodiment includes: obtaining a target picture; acquiring the picture size of at least one packed picture; performing size sorting treatment on at least one packed picture according to the picture size of each packed picture to obtain a picture set, wherein the picture set comprises at least one picture to be packed, and the at least one picture to be packed is sequentially arranged from small to large or from large to small according to the size; according to at least one picture to be packaged, distributing a sequence number to at least one picture to be packaged according to the arrangement sequence from small to large or from large to small; acquiring a picture to be packaged from a picture set, wherein the serial number of the picture to be packaged is N, and N is the maximum value serial number in the serial numbers; judging whether N is 0; if yes, ending; if not, creating a second bit array for representing whether the pixel is a valid pixel based on the picture to be packaged; creating a first bit array for representing whether a pixel is occupied based on a target picture; creating a line processing thread according to each line of the first bit array; based on the line processing thread, executing the comparison between the second bit array and each line of the first bit array, and determining whether the picture to be packaged can be inserted into the target picture; if the fact that the picture to be packaged can be inserted into the target picture is determined, writing pixels of the picture to be packaged into corresponding positions of the target picture; updating N to N-1, updating the picture set, and deleting the picture to be packaged with the sequence number N in the picture set. In the method, based on the comparison between each row of the second bit array and each row of the first bit array executed by the row processing thread, whether the picture to be packed can be inserted into the target picture or not is determined, so that the image processing efficiency can be improved, and the speed of packing the picture to be packed into the target picture is further improved.
Further, in the application, updating N to N-1, updating the picture set, deleting the picture to be packaged with the sequence number N in the picture set, and can realize that at least one picture to be packaged is completely packaged to the target picture, so that the picture to be packaged is prevented from being missed.
Fig. 9 is a schematic image processing diagram obtained according to the image processing method provided in the present application. As shown in fig. 9, pixels of a plurality of packed pictures are written in the target picture 80, for example: pixels of packed picture 81 and pixels of packed picture 83. In the target image 80, the pixels of each packed image have respective corresponding writing areas, and the writing areas corresponding to the packed images can overlap each other, so that the packing utilization rate of the target image 80 is improved. For example: a writing area 82 corresponding to a pixel of the packed picture 81 and a writing area 84 corresponding to a pixel of the packed picture 83.
Fig. 10 is a schematic structural diagram of an image processing apparatus provided in the present application. As shown in fig. 10, the image processing apparatus 10 includes: an acquisition module 101, a first creation module 102, a second creation module 103, a determination module 104, and a writing module 105, wherein,
the obtaining module 101 is configured to obtain a target picture and at least one picture to be packaged;
the first creation module 102 is configured to create, based on the target picture, a first bit array for indicating whether the pixel is occupied;
the second creating module 103 is configured to create, based on the picture to be packaged, a second bit array for indicating whether the pixel is a valid pixel;
the determining module 104 is configured to compare the second bit array with the first bit array, and determine whether the picture to be packaged can be inserted into the target picture;
the writing module 105 is configured to, if it is determined that the picture to be packaged can be inserted into the target picture, write the pixel of the picture to be packaged into the corresponding position of the target picture.
The image processing apparatus 10 provided in the present application may execute the technical solution shown in the foregoing method embodiment, and its implementation principle and beneficial effects are similar, and will not be described herein again.
In one possible implementation, the determining module 104 is specifically configured to:
creating a line processing thread according to each line of the first bit array;
and based on the line processing thread, executing the comparison between the second bit array and each line of the first bit array, and determining whether the picture to be packaged can be inserted into the target picture.
In one possible implementation, the determining module 104 is specifically configured to:
and executing at least one second numerical value in the second numerical array and at least one first numerical value in the first numerical array based on the line processing thread to compare, and if the comparison operation is successful, determining that the picture to be packaged can be inserted into the target picture.
In one possible implementation, the corresponding value occupied by a pixel in the first bit array is 1 and the corresponding value not occupied by a pixel is 0.
In one possible implementation, the corresponding value of the valid pixel in the second bit array is 1, and the corresponding value of the invalid pixel is 0.
In one possible implementation, the writing module 105 is specifically configured to:
and updating the first value to 1 if the result of the operation of the second value of the pixel bit corresponding to the pixel and the first value of the pixel bit in the corresponding position is 1.
In one possible implementation, the obtaining module 101 is specifically configured to:
acquiring the picture size of at least one packed picture;
and carrying out size sorting treatment on at least one packed picture according to the picture size of each packed picture to obtain a picture set, wherein the picture set comprises at least one picture to be packed, and the at least one picture to be packed is orderly arranged from small to large or from large to small according to the size.
Fig. 11 is a schematic hardware structure of the image processing apparatus provided in the present application. As shown in fig. 11, the image processing apparatus 20 includes: a processor 201 and a memory 202 are provided,
the processor 201 and the memory 202 are connected via a bus 203.
In a specific implementation, the processor 201 executes computer-executable instructions stored in the memory 202, so that the processor 201 executes the image processing method as described above.
The specific implementation process of the processor 201 may refer to the above-mentioned method embodiment, and its implementation principle and technical effects are similar, and this embodiment will not be described herein again.
In the embodiment shown in fig. 11, it should be understood that the processor may be a central processing unit (english: central Processing Unit, abbreviated as CPU), or may be other general purpose processors, digital signal processors (english: digital Signal Processor, abbreviated as DSP), application specific integrated circuits (english: application Specific Integrated Circuit, abbreviated as ASIC), or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in a processor for execution.
The memory may comprise high speed RAM memory or may also comprise non-volatile storage NVM, such as disk memory.
The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (Peripheral Component, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, the buses in the drawings of the present application are not limited to only one bus or one type of bus.
The present application also provides a computer-readable storage medium in which computer-executable instructions are stored, which when executed by a processor, implement the image processing method as above.
The computer readable storage medium described above may be implemented by any type of volatile or non-volatile memory device or combination thereof, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk. A readable storage medium can be any available medium that can be accessed by a general purpose or special purpose computer.
An exemplary readable storage medium is coupled to the processor such the processor can read information from, and write information to, the readable storage medium. In the alternative, the readable storage medium may be integral to the processor. The processor and the readable storage medium may reside in an application specific integrated circuit (Application Specific Integrated Circuits, ASIC for short). The processor and the readable storage medium may reside as discrete components in a device.
The division of units is merely a logical function division, and there may be another division manner in actual implementation, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method of the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The foregoing program may be stored in a computer readable storage medium. The program, when executed, performs steps including the method embodiments described above; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.

Claims (8)

1. An image processing method, comprising:
acquiring a target picture and at least one picture to be packaged;
creating a first bit array for representing whether pixels are occupied or not based on the target picture, wherein the first bit array is a pixel bit array determined according to a maximum rectangular picture corresponding to the target picture, and the maximum rectangular picture is a maximum circumscribed rectangle of the target picture;
creating a second bit array for representing whether the pixel is a valid pixel based on the picture to be packaged;
comparing the second bit array with the first bit array to determine whether the picture to be packaged can be inserted into the target picture;
if the fact that the picture to be packaged can be inserted into the target picture is determined, writing pixels of the picture to be packaged into corresponding positions of the target picture;
the comparing the second bit array with the first bit array to determine whether the picture to be packaged can be inserted into the target picture, including:
creating a line processing thread according to each line of the first bit array;
and comparing at least one second numerical value in the second bit array with at least one first numerical value in the first bit array based on the line processing thread, and if the line processing thread is successful in operation, determining that the picture to be packaged can be inserted into the target picture.
2. The method of claim 1, wherein the corresponding value in the first bit array occupied by the pixel is 1 and the corresponding value not occupied by the pixel is 0.
3. The method of claim 1, wherein the second bit array has a corresponding value of 1 for the active pixels and a corresponding value of 0 for the inactive pixels.
4. A method according to any one of claims 1 to 3, wherein said writing pixels of the picture to be packed into corresponding positions of the target picture comprises:
and updating the first value to 1 if the result of the operation of the second value of the pixel bit corresponding to the pixel and the first value of the pixel bit in the corresponding position is 1.
5. A method according to any one of claims 1 to 3, wherein said obtaining at least a picture to be packaged comprises:
acquiring the picture size of at least one packed picture;
and carrying out size sorting treatment on at least one packed picture according to the picture size of each packed picture to obtain a picture set, wherein the picture set comprises at least one picture to be packed, and the at least one picture to be packed is orderly arranged from small to large or from large to small according to the size.
6. An image processing apparatus, comprising: the system comprises an acquisition module, a first creation module, a second creation module, a determination module and a writing module, wherein,
the acquisition module is used for acquiring a target picture and at least one picture to be packaged;
the first creating module is used for creating a first bit array used for representing whether pixels are occupied or not based on the target picture, wherein the first bit array is a pixel bit array determined according to a maximum rectangular picture corresponding to the target picture, and the maximum rectangular picture is a maximum circumscribed rectangle of the target picture;
the second creating module is used for creating a second bit array used for representing whether the pixel is a valid pixel or not based on the picture to be packaged;
the determining module is used for comparing the second bit array with the first bit array to determine whether the picture to be packaged can be inserted into the target picture;
the writing module is used for writing pixels of the picture to be packaged into corresponding positions of the target picture if the picture to be packaged is determined to be capable of being inserted into the target picture;
the determining module is specifically configured to create a line processing thread according to each line of the first bit array;
and comparing at least one second numerical value in the second bit array with at least one first numerical value in the first bit array based on the line processing thread, and if the line processing thread is successful in operation, determining that the picture to be packaged can be inserted into the target picture.
7. An image processing apparatus, comprising: a processor and a memory;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored in the memory, causing the processor to perform the image processing method according to any one of claims 1 to 5.
8. A computer-readable storage medium, in which computer-executable instructions are stored, which, when executed by a processor, implement the image processing method according to any one of claims 1 to 5.
CN202010411870.3A 2020-05-15 2020-05-15 Image processing method and device Active CN111553847B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010411870.3A CN111553847B (en) 2020-05-15 2020-05-15 Image processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010411870.3A CN111553847B (en) 2020-05-15 2020-05-15 Image processing method and device

Publications (2)

Publication Number Publication Date
CN111553847A CN111553847A (en) 2020-08-18
CN111553847B true CN111553847B (en) 2024-02-13

Family

ID=72004765

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010411870.3A Active CN111553847B (en) 2020-05-15 2020-05-15 Image processing method and device

Country Status (1)

Country Link
CN (1) CN111553847B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112073730B (en) * 2020-09-03 2022-06-24 北京字节跳动网络技术有限公司 Method, device and equipment for packing atlas and storage medium
CN113014990B (en) * 2021-03-02 2024-04-12 卡莱特云科技股份有限公司 Quick playing method, playing box and playing system for program pictures

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107330214A (en) * 2017-07-11 2017-11-07 哈尔滨工业大学(威海) Spatial configuration optimal method based on discretization Yu heuristic evolution algorithm

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10928995B2 (en) * 2018-08-28 2021-02-23 Lucasfilm Entertainment Company Ltd. LLC Systems and methods for UV packing

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107330214A (en) * 2017-07-11 2017-11-07 哈尔滨工业大学(威海) Spatial configuration optimal method based on discretization Yu heuristic evolution algorithm

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Andre Kubagawa Sato等.Study of the grid size impact on a raster based strip packing problem solution.《IFAC-PapersOnLine》.2016,第143–148页. *
周慧娟.二维不规则装箱在快速原型设计中的应用.《中国优秀硕士学位论文全文数据库 信息科技辑》.2016,第15-19页. *

Also Published As

Publication number Publication date
CN111553847A (en) 2020-08-18

Similar Documents

Publication Publication Date Title
US7669033B2 (en) Pretranslating input/output buffers in environments with multiple page sizes
US20120005451A1 (en) Data storage device and bad block managing method thereof
US6529201B1 (en) Method and apparatus for storing and accessing texture maps
CN111553847B (en) Image processing method and device
US9069477B1 (en) Reuse of dynamically allocated memory
EP3657337A1 (en) Method, apparatus, device and storage medium for accessing static random access memory
CN110968529A (en) Method and device for realizing non-cache solid state disk, computer equipment and storage medium
EP3816867A1 (en) Data reading/writing method and system in 3d image processing, storage medium, and terminal
CN111210004B (en) Convolution calculation method, convolution calculation device and terminal equipment
CN114880289A (en) File grouping display method and computing device
US20200327638A1 (en) Connected component detection method, circuit, device and computer-readable storage medium
CN111382831B (en) Accelerating convolutional nerves network model Forward reasoning method and device
CN116185545A (en) Page rendering method and device
CN116400852A (en) Method and device for optimizing writing performance of solid state disk, computer equipment and storage medium
CN113253939B (en) Data processing method, device, electronic equipment and storage medium
CN111258733B (en) Embedded OS task scheduling method and device, terminal equipment and storage medium
US20210357317A1 (en) Memory device and operation method
CN110087088B (en) Data storage method based on motion estimation, terminal equipment and storage medium
EP0532690A1 (en) Method and apparatus for managing page zero memory accesses in a multi-processor system
CN111739084B (en) Picture processing method, atlas processing method, computer device, and storage medium
CN113190472B (en) Method and device for quickly reconstructing NOMAP information of solid-state storage equipment, computer equipment and storage medium
CN113568578B (en) Picture processing method and device, electronic equipment and readable storage medium
US20090073179A1 (en) Addressing on chip memory for block operations
CN109885491B (en) Method for detecting existence of data overflow expression and terminal equipment
US11733893B2 (en) Management of flash storage media

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant