CN111553847A - Image processing method and device - Google Patents

Image processing method and device Download PDF

Info

Publication number
CN111553847A
CN111553847A CN202010411870.3A CN202010411870A CN111553847A CN 111553847 A CN111553847 A CN 111553847A CN 202010411870 A CN202010411870 A CN 202010411870A CN 111553847 A CN111553847 A CN 111553847A
Authority
CN
China
Prior art keywords
picture
packaged
bit array
pixel
packed
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.)
Granted
Application number
CN202010411870.3A
Other languages
Chinese (zh)
Other versions
CN111553847B (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

Images

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, and 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 used for representing whether the pixel is an effective pixel or not based on the picture to be packed; comparing the second digit group with the first digit group to determine whether the picture to be packaged can be inserted into the target picture; and 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 application relates to the field of computer image processing, and in particular, to an image processing method and apparatus.
Background
At present, in order to facilitate the transmission of a plurality of images to be packaged, a 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 performing 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 packed is inserted into the corresponding rectangular writing area, resulting in a low packing utilization rate of the target image.
Disclosure of Invention
The application provides an image processing method and device, which are used for improving the 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 used for representing whether the pixel is an effective pixel or not based on the picture to be packed;
comparing the second digit group with the first digit group to determine whether the picture to be packaged can be inserted into the target picture;
and 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 a possible implementation manner, 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 digit array;
and comparing each row of the second bit array and the first bit array based on the row processing thread, and determining whether the picture to be packaged can be inserted into the target picture.
In one possible implementation, the determining whether the picture to be packed can be inserted into the target picture based on the line processing thread performing the comparison of the second bit array with each line of the first bit array includes:
and executing at least one second numerical value in the second bit array and at least one first numerical value in the first bit array based on the line processing thread to compare, and if the comparison is successful, determining that the picture to be packed can be inserted into the target picture.
In one possible embodiment, the corresponding value occupied by a pixel in the first bit array is 1, and the corresponding value unoccupied by a pixel is 0.
In one possible embodiment, 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 a possible implementation, writing the pixels of the picture to be packed into the corresponding positions of the target picture includes:
and if the OR operation result 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, updating the first value to be 1.
In a possible embodiment, the obtaining at least a picture to be packed includes:
acquiring the picture size of at least one packed picture;
according to the picture size of each packaged picture, performing size sorting processing on at least one packaged picture to obtain a picture set, wherein the picture set comprises at least one picture to be packaged, and the at least one picture to be packaged is sequentially arranged from small to large according to the size or from large to small according to the size.
In a second aspect, the present application provides an image processing apparatus comprising: 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 the pixel is 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 an effective pixel or not based on the picture to be packaged;
the determining module is used for comparing the second digit group with the first digit group and determining whether the picture to be packaged can be inserted into the target picture;
and the writing module is used for writing the pixels of the picture to be packaged into the corresponding position of the target picture if the picture to be packaged can be inserted into the target picture.
In a possible implementation, the determining module is specifically configured to:
creating a line processing thread according to each line of the first digit array;
and comparing each row of the second bit array and the first bit array based on the row processing thread, and determining whether the picture to be packaged can be inserted into the target picture.
In a possible implementation, the determining module is specifically configured to:
and executing at least one second numerical value in the second bit array and at least one first numerical value in the first bit array based on the line processing thread to compare, and if the comparison is successful, determining that the picture to be packed can be inserted into the target picture.
In one possible embodiment, the corresponding value occupied by a pixel in the first bit array is 1, and the corresponding value unoccupied by a pixel is 0.
In one possible embodiment, 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 a possible implementation, the writing module is specifically configured to:
and if the OR operation result 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, updating the first value to be 1.
In a possible implementation manner, the obtaining module is specifically configured to:
acquiring the picture size of at least one packed picture;
according to the picture size of each packaged picture, performing size sorting processing on at least one packaged picture to obtain a picture set, wherein the picture set comprises at least one picture to be packaged, and the at least one picture to be packaged is sequentially arranged from small to large according to the size 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 the computer-executable instructions stored by the memory, causing the processor to perform the image processing method of any of the first aspects.
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 of any one of the above first aspects.
The application provides an image processing method and device, and 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 used for representing whether the pixel is an effective pixel or not based on the picture to be packed; comparing the second digit group with the first digit group to determine whether the picture to be packaged can be inserted into the target picture; and 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, and 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, so that the positions of the pixels which can be written into the target picture but are not written into the target picture can be avoided, and the low packaging utilization rate of the target picture is improved.
Drawings
In order to more clearly illustrate the technical solutions in the present application or the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.
FIG. 1 is a schematic diagram of image processing by a rectangular-based binary tree segmentation method in the prior art;
FIG. 2 is a diagram illustrating image processing in the prior art;
fig. 3 is a first schematic flowchart of an image processing method provided in the present application;
FIG. 4 is a diagram of a target picture and a first bit array according to the present invention;
FIG. 5 is a diagram illustrating a picture to be packed and a second bit array according to the present invention;
FIG. 6 is a schematic diagram illustrating a comparison between a second bit array and a first bit array provided herein;
FIG. 7 is a schematic diagram of the OR operation result obtained by the present application;
fig. 8 is a second flowchart illustrating an image processing method according to the present application;
FIG. 9 is a schematic diagram of image processing according to the image processing method provided in the present application;
fig. 10 is a schematic structural diagram of an image processing apparatus provided in the present application;
fig. 11 is a schematic diagram of a hardware structure of an image processing apparatus according to the present application.
Detailed Description
To make the purpose, technical solutions and advantages of the present application clearer, 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 obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements 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 by a rectangular-based binary tree segmentation method in the prior art. First, a large blank picture (which may be called a target picture) is set. Since the target picture is considered to be maximally utilized, all the pictures to be packed may be sorted in size in advance. The largest picture is placed in the upper left corner and the next largest picture is unfolded right one time. As shown in fig. 1, by placing the largest picture 11 in the upper left corner of the blank picture, the remaining area can be divided into two parts: 12 and 13, for placing other pictures to be packed subsequently. This logic is repeated, then all pictures can be packed and written into the target picture.
In the prior art shown in fig. 1, when a picture to be packed is a rectangular picture, image processing can be performed by a binary tree segmentation method based on a rectangle. If the picture to be packed is not a rectangular picture, the image processing cannot be performed by the binary tree segmentation method based on the rectangle, so that the application range of the binary tree segmentation method based on the rectangle to perform the image processing is small. Fig. 2 is a schematic diagram of image processing in the prior art. As shown in fig. 2, if the picture to be packed is irregular or contains a hollow, the picture to be packed can only be regarded as a rectangle during packing, and a large blank gap exists in an area of the target picture occupied by the rectangle, thereby resulting in a low packing utilization rate of the target image.
In the present application, an image processing method is provided, where when there is an area in which pixels can be written in some rectangular writing areas, pixels of a packed picture can be written in the area in which pixels can be written in the rectangular writing areas, so that a low packing utilization rate of a target image is improved.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 3 is a first flowchart of an image processing method provided in the present application. As shown in fig. 3, the image processing method provided by the present embodiment includes:
s201: and acquiring a target picture and at least one picture to be packaged.
Alternatively, the execution subject 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.
Optionally, the target picture and the picture to be packaged may be pictures in any shapes, for example: the arbitrary shape may be a rectangle, a circle, a triangle, a parallelogram, wherein the arbitrary shape may have an arbitrary size.
Alternatively, the target picture may be determined according to size information set by a 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 created from 2048 × 2048.
Specifically, at least one preset and stored picture to be packaged may be acquired 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, and the maximum rectangular picture is a maximum circumscribed rectangle of the target picture.
Specifically, the number of the pixel bits included in the first bit array is equal to the product of the number of the pixels on the long side of the picture and the number of the pixels on the short side of the picture, 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 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 is the maximum circumscribed rectangular picture of the target picture 31 and is a picture including an integer number of pixels, the first bit array 33 is a pixel bit array determined according to the maximum rectangular picture 32, for example: the first bit array 33 determined from the largest rectangular picture 32 is a bit array comprising 40 pixel bits. The 40 pixel bits (the first values are all 0) are equal to the product of 8 pixels on the long side of the picture and 5 pixels on the short side of the picture of the maximum rectangular picture 32. In practice, the maximum rectangular picture 32 may be determined according to the target picture 31, and then the first bit array 33 may be obtained according to the maximum 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 the first value of the pixel bit is 0, indicating that the pixel bit can be written into the pixel.
S203: and creating a second bit array used for representing whether the pixel is an effective pixel or not based on the picture to be packed.
The effective pixels are pixels whose transparency is not 0, and the ineffective pixels are pixels whose transparency is 0.
Specifically, a second bit array corresponding to each picture to be packaged is created. Further, with reference to fig. 5, taking an image to be packaged and a second bit array corresponding to the image to be packaged as an example, the creation of the second bit array is described. Fig. 5 is a schematic diagram of a picture to be packed and a second bit array according to the present invention. As shown in fig. 5, includes: a picture 41 to be packed, a maximum picture 42 to be packed, and a second bit array 43, where the maximum picture 42 to be packed is a maximum circumscribed rectangular picture of the picture 41 to be packed and is a picture including integer pixels, and the second bit array 43 obtains an integer bit array according to the maximum picture 42 to be packed, 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 4 of pixels on the long side of the picture and the number 4 of pixels on the short side of the picture of the maximum picture to be packed 42. In fig. 5, a second value of "1" of a pixel bit in the second bit array 43 indicates that the pixel corresponding to the pixel bit is an active pixel, and a second value of "0" indicates that the pixel corresponding to the pixel bit is an inactive pixel.
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 numerical value included in the second bit array is anded with each first numerical value included in a corresponding position of the first bit array, so that the second bit array is compared with the first bit array. If the and operation result is 1, determining that the picture to be packaged can be inserted into the target picture. The corresponding position is the same size of the first bit array as the second bit array, specifically, see fig. 6. Fig. 6 is a schematic diagram illustrating a comparison between a second bit array and a first bit array provided in the present application. As shown in fig. 6, includes: a second bit array 51, a first bit array 52 and an 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 corresponding location may be any one of the corresponding locations 54, 55, 56, or 57. And when the corresponding position is the corresponding position 54, performing and operation on the second numerical value of each pixel bit in the second bit array 51 and the first numerical value of each pixel bit in the corresponding position 54, and if the and operation result is 0, determining that the picture to be packed 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 and-operated, the obtained value of each pixel bit in the and-operation result bit array 53 is 0, and it can be determined that the picture to be packed can be inserted into the target picture.
S205: and 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 a possible implementation, writing the pixels of the picture to be packed into the corresponding positions of the target picture includes: and if the OR operation result 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, updating the first value to be 1.
Specifically, the second numerical value of each pixel bit in the second bit array is or-operated with the first numerical value of each pixel bit in the corresponding position to obtain an or-operation result corresponding to each pixel bit, and the first numerical 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 pixels of the picture to be packed are written into the corresponding positions of the target picture. Specifically, please refer to fig. 7. Fig. 7 is a schematic diagram of obtaining an or operation result corresponding to a pixel bit 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 an or-operation result (corresponding position 65) corresponding to each pixel bit, and the first value of each pixel bit in the corresponding position 64 is updated to the or-operation result corresponding to the pixel bit, so as to obtain the 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 unoccupied by a pixel is 0.
It should be noted that, for the second bit array corresponding to each picture to be packed, S204 to S205 are sequentially executed until all pixels of the picture to be packed are written into corresponding positions (positions corresponding to the picture to be packed) in the target picture.
Unlike the prior art, in the method for processing an image based on the rectangular binary tree segmentation method in the prior art, the target picture needs to be a rectangular picture, so that the application range of the method for processing an image based on the rectangular binary tree segmentation method is small. In the present application, the target picture in the image processing method provided by the present application may be a picture with any shape, so that the image processing method shown in the present application may have a wide application range.
The image processing method provided by the embodiment 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 used for representing whether the pixel is an effective pixel or not based on the picture to be packed; comparing the second digit group with the first digit group to determine whether the picture to be packaged can be inserted into the target picture; and 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, and 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, so that the positions of the pixels which can be written into the target picture but are not written into the target picture can be avoided, and the low packaging utilization rate of the target picture is improved.
The image processing method provided by the present application is further described in detail with reference to fig. 8, and specifically, refer to the embodiment of fig. 8.
Fig. 8 is a flowchart illustrating a second image processing method according to the present application. As shown in fig. 8, the image processing method provided by the present embodiment includes:
s701: and acquiring a target picture.
Specifically, the execution method of S701 is the same as the execution method of S201, and the execution process of S701 is not described herein again.
S702: a picture size of at least one packed picture is obtained.
Specifically, each packed picture is measured to obtain the picture size of each packed picture.
S703: according to the picture size of each packaged picture, performing size sorting processing on at least one packaged picture to obtain a picture set, wherein the picture set comprises at least one picture to be packaged, and the at least one picture to be packaged is sequentially arranged from small to large according to the size or from large to small according to the size.
It should be noted that, one packed picture corresponding to one picture to be packed is the same as the picture to be packed.
S704: and distributing a sequence number for 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 in size or from large to small in size.
For example, when at least one picture to be packed is arranged from small to large according to the size, the respective sequence numbers of the at least one picture to be packed are also arranged from small to large. For example, when at least one picture to be packed is arranged from large to small according to the size, the sequence numbers allocated to the at least one picture to be packed are also arranged from large to small.
Alternatively, the serial 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, where a sequence number of the first picture to be packaged is 1, a sequence number of the second picture to be packaged is 2, and a sequence number of the third picture to be packaged is 3, and the obtained picture to be packaged is the third picture to be packaged.
S706: and judging whether N is 0 or not.
If so, S713 is performed.
If not, S707 to S712 are executed.
S707: and creating a second bit array used for representing whether the pixel is an effective pixel or not based on the picture to be packed.
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 again.
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 the execution method of S202, and the execution process of S708 is not described herein again.
S709: a row processing thread is created for each row of the first bit array.
Specifically, the number of the line processing threads is the same as the number of the lines of the first bit array.
For example, if the number of rows in the first bit array is 5, the number of 5-row processing threads is also 5.
S710: and comparing each row of the second bit array and the first bit array based on the row processing thread, and determining whether the picture to be packaged can be inserted into the target picture.
In one possible implementation, the determining whether the picture to be packed can be inserted into the target picture based on the line processing thread performing the comparison of the second bit array with each line of the first bit array includes: and executing at least one second numerical value in the second bit array and at least one first numerical value in the first bit array based on the line processing thread to compare, and if the comparison is successful, determining that the picture to be packed 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, fig. 6 shows the result of the and operation of 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.
S711: and 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 the execution method of S205, and the execution process of S711 is not described herein again.
S712: and updating N to be N-1, updating the picture set, and deleting the pictures to be packaged with the sequence number N in the picture set.
S713: and (6) ending.
The image processing method provided by the embodiment comprises the following steps: acquiring a target picture; acquiring the picture size of at least one packed picture; according to the picture size of each packaged picture, performing size sorting processing on at least one packaged picture to obtain a picture set, wherein the picture set comprises at least one picture to be packaged, and the at least one picture to be packaged is sequentially arranged from small to large according to the size or from large to small according to the size; according to the arrangement sequence of the at least one picture to be packaged from small to large in size or from large to small in size, allocating a sequence number to the at least one picture to be packaged; 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 serial number in the serial numbers; judging whether N is 0; if yes, ending; if not, creating a second bit array used for representing whether the pixel is an effective pixel or not 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 digit array; comparing each row of the second digit array and the first digit array based on the row processing thread, and determining 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 pixels of the picture to be packaged into the corresponding position of the target picture; and updating N to be N-1, updating the picture set, and deleting the pictures to be packaged with the sequence number N in the picture set. In the method, the comparison between the second bit array and each row of the first bit array is executed based on the row processing thread, whether the picture to be packaged can be inserted into the target picture or not is determined, the image processing efficiency can be improved, and the speed of packaging the picture to be packaged into the target picture is further improved.
Further, in the application, N is updated to be N-1, the picture set is updated, and the pictures to be packaged with the sequence number of N in the picture set are deleted, so that at least one picture to be packaged can be completely packaged to the target picture, and the pictures to be packaged are prevented from being missed.
Fig. 9 is a schematic diagram of image processing obtained by the image processing method provided in the present application. As shown in fig. 9, the target picture 80 is written with a plurality of pixels of packed pictures, for example: pixels of packed picture 81 and pixels of packed picture 83. In the target picture 80, the pixels of each packed picture have respective corresponding writing areas, and the writing areas corresponding to the respective packed pictures can be overlapped with each other, so that the packing utilization rate of the target image 80 is improved, and is low. 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 according to 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 used for creating a first bit array used for representing whether a pixel is occupied or not based on a target picture;
the second creating module 103 is configured to create a second bit array used for indicating whether a pixel is an effective pixel based on the picture to be packed;
the determining module 104 is configured to compare the second bit array with the first bit array, and determine whether the picture to be packed can be inserted into the target picture;
the writing module 105 is configured to write the pixels of the picture to be packaged into the corresponding positions of the target picture if it is determined that the picture to be packaged can be inserted into the target picture.
The image processing apparatus 10 provided in the present application can execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects thereof are similar, and are not described herein again.
In a possible implementation, the determining module 104 is specifically configured to:
creating a line processing thread according to each line of the first digit array;
and comparing each row of the second bit array and the first bit array based on the row processing thread, and determining whether the picture to be packaged can be inserted into the target picture.
In a possible implementation, the determining module 104 is specifically configured to:
and executing at least one second numerical value in the second bit array and at least one first numerical value in the first bit array based on the line processing thread to compare, and if the comparison is successful, determining that the picture to be packed can be inserted into the target picture.
In one possible embodiment, the corresponding value occupied by a pixel in the first bit array is 1, and the corresponding value unoccupied by a pixel is 0.
In one possible embodiment, 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 if the OR operation result 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, updating the first value to be 1.
In a possible implementation, the obtaining module 101 is specifically configured to:
acquiring the picture size of at least one packed picture;
according to the picture size of each packaged picture, performing size sorting processing on at least one packaged picture to obtain a picture set, wherein the picture set comprises at least one picture to be packaged, and the at least one picture to be packaged is sequentially arranged from small to large according to the size or from large to small according to the size.
Fig. 11 is a schematic diagram of a hardware structure of an image processing apparatus according to the present application. As shown in fig. 11, the image processing apparatus 20 includes: a processor 201, a memory 202,
the processor 201 and the memory 202 are connected by a bus 203.
In a particular implementation, the processor 201 executes computer-executable instructions stored by the memory 202, causing the processor 201 to perform the image processing method as described above.
For a specific implementation process of the processor 201, reference may be made to the above method embodiments, which have similar implementation principles and technical effects, and details of this embodiment are not described herein again.
In the embodiment shown in fig. 11, it should be understood that the Processor may be a Central Processing Unit (CPU), other general purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. 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, or in a combination of the hardware and software modules within the processor.
The memory may comprise high speed RAM memory and may also include non-volatile storage NVM, such as disk storage.
The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the buses in the figures of the present application are not limited to only one bus or one type of bus.
The application also provides a computer readable storage medium, in which computer executable instructions are stored, and when the processor executes the computer executable instructions, the image processing method is realized.
The computer-readable storage medium 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 or optical disk. Readable storage media can be any available media 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. Of course, the readable storage medium may also be an integral part of the processor. The processor and the readable storage medium may reside in an Application Specific Integrated Circuits (ASIC). Of course, the processor and the readable storage medium may also reside as discrete components in the apparatus.
The division of the unit is only a logical division, and other division ways are possible in actual implementation, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into 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 such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to 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), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

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 a pixel is occupied based on the target picture;
creating a second bit array used for representing whether the pixel is an effective pixel or not 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;
and 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 position of the target picture.
2. The method of claim 1, wherein the 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 comprises:
creating a row processing thread according to each row of the first digit array;
and comparing each row of the second bit array and the first bit array based on the row processing thread, and determining whether the picture to be packed can be inserted into the target picture.
3. The method of claim 2, wherein the determining whether the picture to be packed can be inserted into the target picture based on the line processing thread performing the comparison of the second bit array with each line of the first bit array comprises:
and executing at least one second numerical value in the second bit array and at least one first numerical value in the first bit array based on the line processing thread to compare, and if the comparison is successful, determining that the picture to be packaged can be inserted into the target picture.
4. A method according to any one of claims 1 to 3, wherein the respective value occupied by the pixel in the first bit array is 1 and the respective value unoccupied by the pixel is 0.
5. The method of any of claims 1 to 4, wherein the corresponding value of the valid pixel in the second bit array is 1 and the corresponding value of the invalid pixel is 0.
6. The method according to any one of claims 1 to 5, wherein the writing of the pixels of the picture to be packed into the corresponding positions of the target picture comprises:
and updating the first numerical value to be 1 if the OR operation result of the second numerical value of the pixel bit corresponding to the pixel and the first numerical value of the pixel bit in the corresponding position is 1.
7. The method according to any one of claims 1 to 6, wherein the obtaining at least a picture to be packed comprises:
acquiring the picture size of at least one packed picture;
and according to the picture size of each packaged picture, performing size sequencing processing on the at least one packaged picture to obtain a picture set, wherein the picture set comprises the at least one picture to be packaged, and the at least one picture to be packaged is sequentially arranged from small to large according to the size or from large to small according to the size.
8. An image processing apparatus characterized by comprising: 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 the pixel is 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 an effective pixel or not based on the picture to be packaged;
the determining module is configured to compare the second bit array with the first bit array, and determine whether the picture to be packed can be inserted into the target picture;
the writing module is configured to, if it is determined that the picture to be packaged can be inserted into the target picture, write pixels of the picture to be packaged into corresponding positions of the target picture.
9. An image processing apparatus characterized by comprising: a processor and a memory;
the memory stores computer-executable instructions;
the processor executing the computer-executable instructions stored by the memory causes the processor to perform the image processing method of any of claims 1 to 7.
10. A computer-readable storage medium having stored thereon computer-executable instructions which, when executed by a processor, implement the image processing method of any one of claims 1 to 7.
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 true CN111553847A (en) 2020-08-18
CN111553847B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112073730A (en) * 2020-09-03 2020-12-11 北京字节跳动网络技术有限公司 Method, device and equipment for packing atlas and storage medium
CN113014990A (en) * 2021-03-02 2021-06-22 卡莱特云科技股份有限公司 Program picture fast playing method, playing box and playing system

Citations (2)

* 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
US20200073536A1 (en) * 2018-08-28 2020-03-05 Lucasfilm Entertainment Company Ltd. LLC Systems and methods for uv packing

Patent Citations (2)

* 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
US20200073536A1 (en) * 2018-08-28 2020-03-05 Lucasfilm Entertainment Company Ltd. LLC Systems and methods for uv packing

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" *
周慧娟: "二维不规则装箱在快速原型设计中的应用" *

Cited By (4)

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

Also Published As

Publication number Publication date
CN111553847B (en) 2024-02-13

Similar Documents

Publication Publication Date Title
CN111880736B (en) Solid state disk access method, device, equipment and medium
CN111553847B (en) Image processing method and device
US11995890B2 (en) Method and apparatus for tensor processing
CN113704140A (en) Solid state disk address mapping method and device
CN116400852A (en) Method and device for optimizing writing performance of solid state disk, computer equipment and storage medium
CN112000591B (en) SSD scanning method capable of designating logical block address, SSD scanning device, SSD scanning computer equipment and storage medium
CN111061429B (en) Data access method, device, equipment and medium
CN112035656A (en) Method, device, computer equipment and medium for quickly previewing document
CN111862343A (en) Three-dimensional reconstruction method, device and equipment and computer readable storage medium
CN113867862B (en) List page layout method and computing device
CN112216333B (en) Chip testing method and device
CN113253939B (en) Data processing method, device, electronic equipment and storage medium
CN109271538A (en) A kind of picture storage method and relevant device
CN113988007A (en) Text display method and device, electronic equipment and storage medium
CN111562983B (en) Memory optimization method and device, electronic equipment and storage medium
CN111739084B (en) Picture processing method, atlas processing method, computer device, and storage medium
CN113743056A (en) Document conversion method based on paragraph shrinkage amount, computing device and storage medium
CN112817526A (en) Data storage method, device and medium
CN113568578B (en) Picture processing method and device, electronic equipment and readable storage medium
CN111158733A (en) BMC upgrading method, device, equipment and computer readable storage medium
CN116541334B (en) PCIE equipment operation time file processing method, device and equipment
US20230076550A1 (en) Method and apparatus for sorting data, storage apparatus
CN109885491B (en) Method for detecting existence of data overflow expression and terminal equipment
CN114637626B (en) Method, device and equipment for reducing read-write errors of EEPROM (electrically erasable programmable read-only memory) data and readable storage medium
CN111625192B (en) Metadata object access method, device, equipment and medium

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