CN113033394A - Image signature generation method and device, electronic equipment and storage medium - Google Patents

Image signature generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113033394A
CN113033394A CN202110315365.3A CN202110315365A CN113033394A CN 113033394 A CN113033394 A CN 113033394A CN 202110315365 A CN202110315365 A CN 202110315365A CN 113033394 A CN113033394 A CN 113033394A
Authority
CN
China
Prior art keywords
image
pixel
pixel array
preset
value
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
CN202110315365.3A
Other languages
Chinese (zh)
Other versions
CN113033394B (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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202110315365.3A priority Critical patent/CN113033394B/en
Publication of CN113033394A publication Critical patent/CN113033394A/en
Application granted granted Critical
Publication of CN113033394B publication Critical patent/CN113033394B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/30Writer recognition; Reading and verifying signatures
    • G06V40/33Writer recognition; Reading and verifying signatures based only on signature image, e.g. static signature recognition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/56Extraction of image or video features relating to colour

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Editing Of Facsimile Originals (AREA)
  • Image Processing (AREA)

Abstract

The present disclosure relates to a method, an apparatus, an electronic device, and a storage medium for generating a signature of an image, the method including: acquiring a first pixel array of a target image, wherein the first pixel array comprises pixel information of each pixel point, and the pixel information comprises a color value and transparency; determining a preset area of a preset area by taking each pixel point as a center; calculating a target color value of a central pixel point according to pixel information of each pixel point in a preset area, wherein the central pixel point is the pixel point positioned in the center of the preset area; determining an image to be converted at least according to all the target color values; and converting the image to be converted into a character string to generate a signature of the target image. The method ensures the flexible adjustment of the speed of acquiring the signature of the target image and the accuracy of the acquired signature of the target image, and solves the problems that the time required for acquiring the image signature and the accuracy of the image signature cannot be flexibly adjusted for the same image in the prior art.

Description

Image signature generation method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of image comparison, and in particular, to a method and an apparatus for generating an image signature, an electronic device, and a storage medium.
Background
In the related art, the process of obtaining the picture signature generally includes: dividing the picture into a set number of grid blocks with the same size; calculating the gray average value of each grid block according to a preset algorithm; determining the brightness and dark contrast between each grid block and the grid block adjacent to the grid block based on the gray average value; the light-dark contrast between each grid block and its neighboring grid block is determined as the signature of the picture.
The method cannot flexibly adjust the time required for obtaining the picture signature and the accuracy of the picture signature aiming at the same picture.
Disclosure of Invention
The present disclosure provides a method and an apparatus for generating an image signature, an electronic device, and a storage medium, so as to at least solve the problem that the time required for obtaining an image signature and the accuracy of the image signature cannot be flexibly adjusted for the same image in the related art.
The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a method for generating an image signature, including: acquiring a first pixel array of a target image, wherein the first pixel array comprises pixel information of each pixel point, and the pixel information comprises a color value and a transparency; determining a preset area of a preset area by taking each pixel point as a center; calculating a target color value of a center pixel point according to the pixel information of each pixel point in the preset area, wherein the center pixel point is the pixel point positioned in the center of the preset area; determining an image to be converted at least according to all the target color values; and converting the image to be converted into a character string to generate a signature of the target image.
Optionally, the step of determining a predetermined area of a preset area by taking each of the pixel points as a center includes: and determining the preset area of the preset area by taking the pixel point as a circle center and the preset distance as a radius.
Optionally, the step of calculating the target color value of the center pixel point according to the pixel information of each pixel point in the predetermined area includes: calculating an average color value of each pixel point, wherein the average color value is an average value of a first color channel value, a second color channel value and a third color channel value in the color values; acquiring the average color value of each pixel point in the preset area; and calculating the target color value of the corresponding central pixel point according to the average color value of each pixel point in the preset area.
Optionally, the step of calculating the target color value of the corresponding center pixel according to the average color value of each pixel in the predetermined region includes: calculating the average value of the average color values of all the pixel points in the preset area to obtain an updated average value; and taking the updated average value as the target color value of the corresponding central pixel point.
Optionally, the step of determining an image to be converted according to at least all of the target color values includes: processing all the target color values to obtain a second pixel array; and determining the image to be converted according to the second pixel array.
Optionally, the step of processing all the target color values to obtain a second pixel array includes: determining preset pixel points, wherein a preset number of the pixel points of the target image are arranged between two adjacent preset pixel points; and determining the second pixel array, wherein the second pixel array is formed by the target color values and the transparencies of all the preset pixels.
Optionally, the step of determining the image to be converted according to the second pixel array includes: acquiring an image corresponding to the second pixel array; and taking the image corresponding to the second pixel array as the image to be converted.
Optionally, the step of determining the image to be converted according to the second pixel array includes: acquiring a preset height and a preset width; zooming the image corresponding to the second pixel array at least according to the preset width and the preset height to obtain a zoomed image; and determining the image to be converted according to the scaled image.
Optionally, the step of scaling the image corresponding to the second pixel array according to at least the preset width and the preset height to obtain a scaled image includes: scaling the width of the image corresponding to the second pixel array to the preset width; scaling the height of the image corresponding to the second pixel array to the preset height; the step of determining the image to be converted according to the scaled image comprises: and determining the zooming image with the width equal to the preset width and the height equal to the preset height as the image to be converted.
Optionally, the step of scaling the image corresponding to the second pixel array according to at least the preset width and the preset height to obtain a scaled image includes: acquiring the aspect ratio of the image corresponding to the second pixel array; determining a scaling value according to the aspect ratio of the image corresponding to the second pixel array and a preset size value, wherein the preset size value is the maximum value of the preset height and the preset width; and scaling one of the width and the height of the image corresponding to the second pixel array to the scaling value, and scaling the other of the width and the height of the image corresponding to the second pixel array to the preset size value to obtain the scaled image, wherein the aspect ratio of the scaled image is equal to the aspect ratio of the image corresponding to the second pixel array.
Optionally, the step of determining the image to be converted according to the scaled image includes: acquiring an initialized pixel array, wherein the initialized pixel array comprises initialized pixel information, the initialized pixel information comprises an initialized color value and an initialized transparency, and the length of the initialized pixel array is equal to the product of the preset height and the preset width; and processing the initialized pixel array and the zoomed image to obtain the image to be converted.
Optionally, the step of processing the initialized pixel array and the scaled image to obtain the image to be converted includes: acquiring pixel information of each pixel point in the zoomed image; replacing the initialized pixel information with the pixel information to obtain a replaced initialized pixel array, wherein the pixel point corresponding to the replaced initialized pixel information is the same as the pixel point corresponding to the replaced pixel information in position; and acquiring the image corresponding to the replaced initialization pixel array to obtain the image to be converted.
Optionally, the initializing the color values includes initializing a first color channel value, initializing a second color channel value, and initializing a third color channel value, where the initializing the first color channel value, the initializing the second color channel value, the initializing the third color channel value, and the initializing transparency are equal.
Optionally, the initialization first color channel value, the initialization second color channel value, the initialization third color channel value, and the initialization transparency are all equal to 0.
Optionally, the method further comprises: storing the signature of the target image to a database.
Optionally, the signature of the target image is a digitized representation of image features in the target image.
According to a second aspect of the embodiments of the present disclosure, there is provided a method for generating an image signature, including: acquiring a first pixel array of a target image, wherein the first pixel array comprises pixel information of each pixel point, and the pixel information comprises a color value and a transparency; acquiring a zoom image according to the first pixel array, wherein the width of the zoom image is equal to a preset width and the height of the zoom image is equal to a preset height; determining an image to be converted according to the zoomed image; and converting the image to be converted into a character string to generate a signature of the target image.
Optionally, the step of obtaining a scaled image according to the first pixel array includes: calculating a target color value of a central pixel point according to the pixel information of each pixel point in a preset area, wherein the central pixel point is the pixel point positioned in the center of the preset area; and acquiring the zoom image according to all the target color values.
Optionally, before the step of calculating a target color value of a center pixel according to the pixel information of each pixel point in the predetermined area, the step of obtaining a scaled image according to the first pixel array further includes: and determining the preset area with each pixel point as a center.
Optionally, the step of obtaining the scaled image according to all the target color values includes: processing all the target color values to obtain a second pixel array; acquiring a preset height and a preset width; and zooming the image corresponding to the second pixel array at least according to the preset width and the preset height to obtain a zoomed image.
Optionally, the step of scaling the image corresponding to the second pixel array according to at least the preset width and the preset height to obtain a scaled image includes: scaling the width of the image corresponding to the second pixel array to the preset width; scaling the height of the image corresponding to the second pixel array to the preset height; the step of determining an image to be converted according to the scaled image comprises: and determining the zooming image with the width equal to the preset width and the height equal to the preset height as the image to be converted.
Optionally, the step of scaling the image corresponding to the second pixel array according to at least the preset width and the preset height to obtain the scaled image includes: acquiring the aspect ratio of the image corresponding to the second pixel array; determining a scaling value according to the aspect ratio of the image corresponding to the second pixel array and a preset size value, wherein the preset size value is the maximum value of the preset height and the preset width; and scaling one of the scaled width and height of the image corresponding to the second pixel array to the scaling value, and scaling the other of the scaled width and height of the image corresponding to the second pixel array to the predetermined size value to obtain the scaled image, wherein the aspect ratio of the image corresponding to the second pixel array is equal to the aspect ratio of the scaled image.
Optionally, the step of determining an image to be converted according to the scaled image includes: acquiring an initialized pixel array, wherein the initialized pixel array comprises initialized pixel information, the initialized pixel information comprises an initialized color value and an initialized transparency, and the length of the initialized pixel array is equal to the product of the preset height and the preset width; and processing the initialized pixel array and the zoomed image to obtain the image to be converted.
Optionally, the step of processing the initialized pixel array and the scaled image to obtain the image to be converted includes: acquiring pixel information of each pixel point in the zoomed image; replacing the initialized pixel information with the pixel information to obtain a replaced initialized pixel array, wherein the pixel point corresponding to the replaced initialized pixel information is the same as the pixel point corresponding to the replaced pixel information in position; and acquiring the image corresponding to the replaced initialization pixel array to obtain the image to be converted.
Optionally, the initializing the color values includes initializing a first color channel value, initializing a second color channel value, and initializing a third color channel value, where the initializing the first color channel value, the initializing the second color channel value, the initializing the third color channel value, and the initializing transparency are equal.
Optionally, the initialization first color channel value, the initialization second color channel value, the initialization third color channel value, and the initialization transparency are all equal to 0.
Optionally, the method further comprises: storing the signature of the target image to a database.
Optionally, the signature of the target image is a digitized representation of image features in the target image.
According to a third aspect of the embodiments of the present disclosure, an image signature generation apparatus is provided, including a first acquisition unit, a first determination unit, a first calculation unit, a second determination unit, and a first generation unit, where the first acquisition unit is configured to perform acquisition of a first pixel array of a target image, the first pixel array including pixel information of each pixel point, the pixel information including a color value and a transparency; a first determination unit configured to perform determination of a predetermined region of a preset area with each of the pixel points as a center; a first calculation unit configured to perform calculation of a target color value of a center pixel point according to the pixel information of each of the pixel points in the predetermined area, the center pixel point being the pixel point located at the center of the predetermined area; the second determining unit is configured to determine an image to be converted according to at least all the target color values; a first generating unit configured to perform conversion of the image to be converted into a character string, and generate a signature of the target image.
Optionally, the first determining unit includes: a first determining subunit, configured to determine the predetermined area of the preset area by taking the pixel point as a center of a circle and a predetermined distance as a radius.
Optionally, the first computing unit includes: a first calculating subunit, configured to perform calculation of an average color value of each pixel point, where the average color value is an average value of a first color channel value, a second color channel value, and a third color channel value in the color values; a first obtaining subunit configured to perform obtaining an average color value of each of the pixel points of the predetermined region; and the second calculation subunit is configured to calculate the target color value of the corresponding center pixel according to the average color value of each pixel in the predetermined area.
Optionally, the second computing subunit includes: the first calculation module is configured to calculate an average value of the average color values of all the pixel points in the predetermined area to obtain an updated average value; and the first determining module is used for taking the updated average value as the target color value of the corresponding central pixel point.
Optionally, the second determining unit includes: the first processing subunit is configured to execute processing on all the target color values to obtain a second pixel array; a second determining subunit configured to perform determining the image to be converted according to the second pixel array.
Optionally, the first processing subunit includes: a second determining module configured to perform determining predetermined pixel points, wherein a predetermined number of the pixel points of the target image are between two adjacent predetermined pixel points; a third determining module configured to perform determining the second pixel array formed for the target color values and the transparency of all the predetermined pixels.
Optionally, the second determining subunit includes: a first obtaining module configured to obtain an image corresponding to the second pixel array; and the fourth determining module is configured to execute the step of taking the image corresponding to the second pixel array as the image to be converted.
Optionally, the second determining subunit includes: a second obtaining module configured to perform obtaining a preset height and a preset width; the first zooming module is configured to zoom the image corresponding to the second pixel array according to at least the preset width and the preset height to obtain a zoomed image; a fifth determining module configured to perform determining the image to be converted according to the scaled image.
Optionally, the first scaling module is configured to perform: scaling the width of the image corresponding to the second pixel array to the preset width; scaling the height of the image corresponding to the second pixel array to the preset height;
the fifth determining module is configured to perform: and determining the zooming image with the width equal to the preset width and the height equal to the preset height as the image to be converted.
Optionally, the first scaling module comprises: a first obtaining sub-module configured to perform obtaining an aspect ratio of an image corresponding to the second pixel array; a first determining sub-module configured to determine a scaling value according to an aspect ratio of an image corresponding to the second pixel array and a predetermined size value, where the predetermined size value is a maximum value of the preset height and the preset width; a first scaling sub-module configured to scale one of the width and the height of the image corresponding to the second pixel array to the scaling value, and scale the other of the width and the height of the image corresponding to the second pixel array to the predetermined size value, so as to obtain the scaled image, where an aspect ratio of the scaled image is equal to an aspect ratio of the image corresponding to the second pixel array.
Optionally, the fifth determining module includes: a second obtaining sub-module configured to perform obtaining an initialized pixel array, the initialized pixel array including initialized pixel information, the initialized pixel information including an initialized color value and an initialized transparency, a length of the initialized pixel array being equal to a product of the preset height and the preset width; and the first processing submodule is configured to execute processing on the initialized pixel array and the scaled image to obtain the image to be converted.
Optionally, the first processing sub-module includes: a third obtaining submodule configured to perform obtaining pixel information of each of the pixel points in the scaled image; a first replacement sub-module configured to perform replacement of the initialized pixel information by using the pixel information to obtain a replaced initialized pixel array, where a position of the pixel point corresponding to the replaced initialized pixel information is the same as a position of the pixel point corresponding to the replaced pixel information; and the fourth obtaining submodule is configured to obtain the image corresponding to the replaced initialization pixel array, so as to obtain the image to be converted.
Optionally, the initializing the color values includes initializing a first color channel value, initializing a second color channel value, and initializing a third color channel value, where the initializing the first color channel value, the initializing the second color channel value, the initializing the third color channel value, and the initializing transparency are equal.
Optionally, the initialization first color channel value, the initialization second color channel value, the initialization third color channel value, and the initialization transparency are all equal to 0.
Optionally, the apparatus further comprises: a first storage unit configured to perform storing the signature of the target image to a database.
Optionally, the signature of the target image is a digitized representation of image features in the target image.
According to a fourth aspect of the embodiments of the present disclosure, there is provided an image signature generation apparatus including: a second acquisition unit configured to perform acquisition of a first pixel array of a target image, the first pixel array including pixel information of each pixel point, the pixel information including a color value and a transparency; a third obtaining unit configured to obtain a zoom image having a width equal to a preset width and a height equal to a preset height according to the first pixel array; a third determination unit configured to perform determination of an image to be converted from the scaled image; and the second generation unit is configured to convert the image to be converted into a character string and generate a signature of the target image.
Optionally, the third obtaining unit includes: a third calculation subunit configured to perform calculation of a target color value of a center pixel point according to the pixel information of each of the pixel points in a predetermined region, the center pixel point being the pixel point located at the center of the predetermined region; a second obtaining subunit configured to perform obtaining the scaled image according to all the target color values.
Optionally, the third obtaining unit further includes: a third determining subunit configured to determine the predetermined area of a preset area with each of the pixel points as a center before the step of calculating a target color value of a center pixel point according to the pixel information of each of the pixel points in the predetermined area is performed.
Optionally, the second obtaining subunit includes: the first processing module is configured to execute processing on all the target color values to obtain a second pixel array; a sixth obtaining module configured to perform obtaining a preset height and a preset width; and the third scaling module is configured to scale the image corresponding to the second pixel array according to at least the preset width and the preset height to obtain the scaled image.
Optionally, the third scaling module is configured to perform: scaling the width of the image corresponding to the second pixel array to the preset width; scaling the height of the image corresponding to the second pixel array to the preset height; the third determination unit is configured to perform: and determining the zooming image with the width equal to the preset width and the height equal to the preset height as the image to be converted.
Optionally, the third scaling module comprises: a fifth obtaining sub-module configured to perform obtaining an aspect ratio of an image corresponding to the second pixel array; a second determining sub-module configured to determine a scaling value according to an aspect ratio of an image corresponding to the second pixel array and a predetermined size value, where the predetermined size value is a maximum value of the preset height and the preset width; a second scaling sub-module configured to scale one of a width and a height of the scaled image corresponding to the second pixel array to the scaling value, and scale the other of the width and the height of the image corresponding to the second pixel array to the predetermined size value, so as to obtain the scaled image, where an aspect ratio of the image corresponding to the second pixel array is equal to an aspect ratio of the scaled image.
Optionally, the third determining unit includes: a third obtaining subunit configured to perform obtaining an initialized pixel array, the initialized pixel array including initialized pixel information, the initialized pixel information including an initialized color value and an initialized transparency, a length of the initialized pixel array being equal to a product of the preset height and the preset width; and the second processing subunit is configured to execute processing on the initialized pixel array and the scaled image to obtain the image to be converted.
Optionally, the second processing subunit includes: a seventh obtaining module configured to perform obtaining pixel information of each of the pixel points in the scaled image; a second replacement module configured to perform replacement of the initialized pixel information by using the pixel information to obtain a replaced initialized pixel array, where a position of the pixel point corresponding to the replaced initialized pixel information is the same as a position of the pixel point corresponding to the replaced pixel information; and the eighth obtaining module is configured to obtain the image corresponding to the replaced initialization pixel array to obtain the image to be converted.
Optionally, the initializing the color values includes initializing a first color channel value, initializing a second color channel value, and initializing a third color channel value, where the initializing the first color channel value, the initializing the second color channel value, the initializing the third color channel value, and the initializing transparency are equal.
Optionally, the initialization first color channel value, the initialization second color channel value, the initialization third color channel value, and the initialization transparency are all equal to 0.
Optionally, the apparatus further comprises: a second storage unit configured to perform storing the signature of the target image to a database.
Optionally, the signature of the target image is a digitized representation of image features in the target image.
According to a fifth aspect of the embodiments of the present disclosure, there is provided an electronic device comprising a processor and a memory configured to execute the instructions stored in the memory, wherein the processor is configured to execute the instructions to implement any one of the image signature generation methods.
According to a sixth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein instructions of the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to execute any one of the image signature generation methods.
According to a seventh aspect of embodiments of the present disclosure, there is provided a computer program product comprising computer instructions which, when executed by a processor, implement any one of the generation methods.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
the method for generating the image signature comprises the steps of firstly, obtaining a first pixel array of a target image, wherein the first pixel array comprises pixel information of each pixel point; then, determining a preset area of a preset area by taking each pixel point as a center; then, calculating the target color value of a central pixel point according to the pixel information of each pixel point in the preset area of the target image; then, determining an image to be converted at least according to all the target color values; and finally, converting the image to be converted into a character string to generate a signature of the target image. In the scheme, the preset area is determined by taking each pixel point as the center, the preset area of the preset area can be flexibly adjusted, so that the accuracy of obtaining the zoom image and the accuracy of obtaining the zoom image can be adjusted by adjusting the size of the preset area aiming at the same target image, the speed of obtaining the signature of the target image and the accuracy of obtaining the signature of the target image can be flexibly adjusted, and the problems that the time required for obtaining the image signature and the accuracy of the image signature cannot be flexibly adjusted aiming at the same image in the prior art are well solved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, are configured to carry out the principles of the disclosure and are not to be construed as limiting the disclosure.
Fig. 1 is an architecture diagram illustrating an application scenario of a method of generating an image signature according to an exemplary embodiment.
Fig. 2 is a flowchart illustrating a method of generating an image signature according to an example embodiment.
Fig. 3 is a flow chart illustrating another method of generating an image signature according to an example embodiment.
Fig. 4 is a block diagram illustrating an apparatus for generating an image signature according to an exemplary embodiment.
Fig. 5 is a block diagram illustrating another image signature generation apparatus according to an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are configured to perform similar objects and are not necessarily configured to perform the description in a specific order or sequence. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is an architecture diagram illustrating an implementation environment in which the following image signature generation method may be configured to be performed, as shown in fig. 1, according to an exemplary embodiment. The implementation environment includes an electronic device 01 and a server 02. Wherein, the electronic device 01 and the server 02 may be interconnected and communicate through a network.
The electronic device 01 may be a device that stores or displays a target image. The electronic device 01 may acquire the signature of the target image from the server 02. Alternatively, the electronic device 01 itself may determine the signature of the target image and store the signature of the target image.
The electronic device 01 may be any electronic product that can interact with a user through one or more modes, such as a keyboard, a touch pad, a touch screen, a remote controller, a voice interaction device, or a handwriting device, for example, a mobile phone, a tablet Computer, a palm Computer, a Personal Computer (PC), a wearable device, a smart television, and the like.
The server 02 may be one server, a server cluster composed of a plurality of servers, or a cloud computing service center. The server 02 may include a processor, memory, and a network interface, among others.
It will be appreciated by those of ordinary skill in the art that the above-described electronic devices and servers are merely exemplary, and that other existing or future electronic devices or servers, as may be suitable for implementing the present disclosure, are intended to be included within the scope of the present disclosure and are hereby incorporated by reference.
Based on this, embodiments of the present disclosure provide a method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product for generating an image signature.
The execution subject of the image signature generation method provided in the embodiment of the present disclosure may be the electronic device or the server, or may also be a functional module and/or a functional entity in the electronic device or the server, which can implement the image signature generation method, and may be specifically determined according to actual use requirements, and the embodiment of the present disclosure is not limited. The following takes an execution subject as an electronic device as an example, and exemplarily describes a display method provided by the embodiment of the present disclosure.
Fig. 2 is a flowchart illustrating a method for generating an image signature according to an exemplary embodiment, where the method for generating an image signature is configured to be executed in an electronic device, as shown in fig. 2, and includes the following steps:
in step S11, a first pixel array of the target image is obtained, where the first pixel array includes pixel information of each pixel point.
The pixel information includes a color value and a transparency a (Alpha, transparency), where the color value includes a first color channel value, a second color channel value, and a third color channel value, the first color channel value may be an R (Red ) value, the second color channel value may be a G (green ) value, and the third color channel value may be a B (Blue ) value, and the pixel information ranges from 0 to 255, where 0 of the transparency represents transparency, and 255 of the transparency represents complete visibility.
In step S12, a predetermined area of a predetermined area is determined with each of the above-mentioned pixels as a center.
In step S13, a target color value of a center pixel is calculated according to the pixel information of each of the pixels in the predetermined area, where the center pixel is the pixel located in the center of the predetermined area.
In step S14, determining an image to be converted according to at least all of the target color values;
in step S15, the image to be converted is converted into a character string, and a signature of the target image is generated.
In the above embodiment, first, a first pixel array of a target image is obtained, where the first pixel array includes pixel information of each pixel point; then, determining a preset area of a preset area by taking each pixel point as a center; then, calculating the target color value of a central pixel point according to the pixel information of each pixel point in the preset area of the target image; then, determining an image to be converted at least according to all the target color values; and finally, converting the image to be converted into a character string to generate the signature of the target image. In the scheme, the preset area is determined by taking each pixel point as the center, the preset area of the preset area can be flexibly adjusted, so that the accuracy of obtaining the zoom image and the accuracy of obtaining the zoom image can be adjusted by adjusting the size of the preset area aiming at the same target image, the speed of obtaining the signature of the target image and the accuracy of obtaining the signature of the target image can be flexibly adjusted, and the problems that the time required for obtaining the image signature and the accuracy of the image signature cannot be flexibly adjusted aiming at the same image in the prior art are well solved.
In the actual application process, when the area of the selected predetermined area is large, the signature of the image occupying a small memory can be obtained roughly, and when the area of the selected predetermined area is small, the signature of the image occupying a large memory can be obtained more accurately.
In an actual application process, the step of determining a predetermined area of a preset area by taking each of the pixel points as a center includes: and determining the predetermined area corresponding to each pixel point by taking the pixel point as the center of a circle and the predetermined distance as the radius. Of course, the shape of the predetermined area is not limited to a circle, and the predetermined area may also be a rectangle or other irregular shape, and in addition, the skilled person can flexibly adjust the predetermined distance to determine the predetermined area with different areas.
For obtaining the target color value of the pixel point more simply and more accurately, according to a specific embodiment of the present application, the step of calculating the target color value of the center pixel point according to the pixel information of each pixel point in the predetermined area of the target image includes: calculating the average color value of each pixel point, wherein the average color value is the average value of the first color channel value, the second color channel value and the third color channel value, namely calculating the gray value of each pixel point; acquiring the average color value of each pixel point in the preset area; and calculating the target color value of the corresponding central pixel point according to the average color value of each pixel point in the preset area. According to the method, the gray value of each pixel point in the preset area is calculated, and the target color value is calculated according to the gray value, so that the target color value of the pixel point is obtained simply and accurately, and a good data basis is provided for subsequently determining the signature of the target image.
According to another specific embodiment of the present application, the step of calculating the target color value of the corresponding pixel point according to the average color value of each pixel point in the predetermined area includes: calculating the average color values of all the pixel points in the preset area to obtain an updated average value; and respectively taking the updated average values as target color values of the corresponding pixel points, wherein the target color values comprise a target first color channel value, a target second color channel value and a target third color channel value, and the target first color channel value, the target second color channel value and the target third color channel value form the target color values. Therefore, the noise of the image is ensured to be low, the detail level of the image is ensured to be low, and the image effect of the image under different proportions is ensured to be good.
It should be noted that, in the present application, the first color channel value, the second color channel value, and the third color channel value may correspond to an R value, a G value, and a B value, respectively.
In order to further ensure that the efficiency of obtaining the signature of the target image is high and that the smoothness and the definition of the image are good, according to another specific embodiment of the present application, the determining the image to be converted at least according to all the target color values includes: processing all the target color values to obtain a second pixel array; and determining the image to be converted according to the second pixel array. According to the method, the target color value is processed, and the efficiency of obtaining the signature of the target image, the smoothness and the definition of the image are considered.
In another specific embodiment of the present application, the step of processing all the target color values to obtain the second pixel array includes: determining preset pixel points, wherein a preset number of the pixel points are arranged between two adjacent preset pixel points; and determining the second pixel array, wherein the second pixel array is formed by the target color values and the transparencies of all the preset pixels.
In a specific embodiment, a value S is first set as a threshold, a predetermined pixel is taken every S pixels to obtain N predetermined pixels, and the predetermined pixels are obtained by using a formula SA [ [ R [0], G [0], B [0], a [0] ], … [ [ R [ S ], G [ S ], B [ S ], a [ S ] ], …, [ [ R [ N ] S ], G [ N ] S ], B [ N ] S ], a [ N ] S ], and SA is the second pixel array.
In an embodiment of the application, the determining the image to be converted according to the second pixel array includes: acquiring an image corresponding to the second pixel array; and taking the image corresponding to the second pixel array as the image to be converted.
In order to further ensure that the signature of the image is obtained more quickly and accurately, according to another specific embodiment of the present application, the step of determining the image to be converted according to the second pixel array includes: acquiring a preset height and a preset width; zooming the image corresponding to the second pixel array at least according to the preset width and the preset height to obtain a zoomed image; and determining the image to be converted according to the zoomed image.
In another specific embodiment of the present application, the scaling the image corresponding to the second pixel array according to at least the preset width and the preset height to obtain a scaled image includes: scaling the width of the image corresponding to the second pixel array to the preset width; scaling the height of the image corresponding to the second pixel array to the preset height; the step of determining the image to be converted according to the scaled image includes: and determining the zoomed image with the width equal to the preset width and the height equal to the preset height as the image to be converted. This embodiment ensures that different sized images can generate signatures of the same specification.
In the above embodiment, since the width and the height are forcibly set for the image corresponding to the second pixel array, the image corresponding to the second pixel array may be stretched or compressed to a certain extent, and there is a certain distortion, in order to further ensure that the obtained signature of the target image is accurate, in another specific embodiment of the present application, the scaling the image corresponding to the second pixel array at least according to the preset width and the preset height, and the step of obtaining the scaled image includes: acquiring the aspect ratio of the image corresponding to the second pixel array; determining a scaling value according to the aspect ratio of the image corresponding to the second pixel array and a predetermined size value, wherein the predetermined size value is the maximum value of the preset height and the preset width; and scaling one of the width and the height of the image corresponding to the second pixel array to the scaling value, and scaling the other of the width and the height of the image corresponding to the second pixel array to the preset size value to obtain the scaled image, wherein the aspect ratio of the scaled image is equal to the aspect ratio of the image corresponding to the second pixel array. According to the method, the image corresponding to the second pixel array is scaled in an equal proportion, and the image corresponding to the second pixel array does not need to be stretched or deformed, so that the obtained signature of the target image can be ensured to be more accurate. For example, when the maximum value of the preset height and the preset width is the preset width, the image corresponding to the second pixel array is scaled in an equal proportion by taking the preset height as a reference, that is, the height of the image corresponding to the second pixel array is scaled to the preset height, the width of the image corresponding to the second pixel array is scaled to a scaling value, the scaling value is equal to the ratio of the preset height to the aspect ratio of the image corresponding to the second pixel array, so as to obtain a scaled image, and the aspect ratio of the scaled image is consistent with the aspect ratio of the image corresponding to the second pixel array, that is, the image corresponding to the second pixel array is scaled in an equal proportion.
In practical applications, the scaling is not limited to the above-mentioned scaling based on the maximum value of the preset height and the preset width, and the scaling may be performed based on the minimum value of the preset height and the preset width. Specifically, the predetermined size value is the minimum value of the preset height and the preset width, a scaling value is calculated according to the aspect ratio and the preset width of the image corresponding to the second pixel array, that is, the height corresponding to the scaled image is calculated, and subsequently, the width of the image corresponding to the second pixel array is scaled to the preset width, and the height is scaled to the scaling value, so that the equal scaling is realized.
In order to further ensure that the distortion of the obtained signature of the target image is smaller and thus more accurate, in an embodiment of an actual application process, the determining the image to be converted according to the scaled image includes: acquiring an initialized pixel array, wherein the initialized pixel array comprises initialized pixel information, the initialized pixel information comprises an initialized color value and an initialized transparency, the initialized color value comprises an initialized first color channel value, an initialized second color channel value and an initialized third color channel value, and the length of the initialized pixel array is equal to the product of the preset height and the preset width; and processing the initialized pixel array and the zoomed image to obtain the image to be converted.
In another embodiment of the application, the processing the initialized pixel array and the scaled image to obtain the image to be converted includes: acquiring pixel information of each pixel point in the zoomed image; the first replacement submodule is configured to perform replacement of the initialized pixel information by using the pixel information to obtain a replaced initialized pixel array, and the position of the pixel point corresponding to the replaced initialized pixel information is the same as the position of the pixel point corresponding to the replaced pixel information; and acquiring the image corresponding to the replaced initialization pixel array to obtain the image to be converted. And by a replacement mode, a zoom image with a preset width and a preset height is obtained, and the small distortion degree of the signature of the image is further ensured.
In a specific embodiment, the initializing color values include initializing a first color channel value, initializing a second color channel value, and initializing a third color channel value, and the initializing the first color channel value, the initializing the second color channel value, the initializing the third color channel value, and the initializing transparency are equal. The specific values of the initialization first color channel value, the initialization second color channel value, the initialization third color channel value and the initialization transparency may be set according to actual situations.
In a more specific embodiment, the initialization first color channel value, the initialization second color channel value, the initialization third color channel value, and the initialization transparency are all equal to 0.
In order to facilitate subsequent use, in an embodiment of the present application, the method further includes: and storing the signature of the target image into a database. Specifically, the signature of the target image can be directly stored in the database or the signature of the target image is converted into a webpage image and stored in the database for use.
In a specific embodiment, the specific process of determining the signature of the target image according to the image corresponding to the second pixel array may further include: setting the src attribute value of the IMG element in the HTML document to the above character string (base64), thereby obtaining an image corresponding to the above second pixel array in the web page; acquiring the original width W and height H of the image by using an API (application programming interface) algorithm of naturalWidth or naturalHeight to obtain the aspect ratio r of the image corresponding to the second pixel array; acquiring the preset width W1 and the preset height H1, wherein H1/r is a zoom size, that is, the width of the zoomed image obtained after zooming, when the preset height is greater than the preset width, and the preset height is the height of the zoomed image obtained after zooming; performing scaling processing on the image by using an API algorithm of drawImage (IMG, 0, 0, H1, H1/r); using an API algorithm of getImageData to obtain an RGBA array ARR1 of all pixels of the scaled image, initializing an array with a length equal to W1 × H1 to obtain the initialized pixel array, where the initialized first color channel value, the initialized second color channel value, the initialized third color channel value, and the initialized transparency in the initialized pixel array are all equal to 0, that is, the default fill color value is black, for example, the initialized pixel array ARR2 [ [0, 0, 0, 0], [0, 0, 0, 0], …, [0, 0, 0] ]; replacing the pixel information of the ARR2 at the same position as the ARR1 with the value in the ARR1 to obtain the replaced image; converting the alternative Image into a base64 representation by using a toDataURL ("Image/Png") algorithm, wherein the base64 is the character string; the character string can be directly stored in a database as a normalized image signature or the character string code is converted into a webpage image to be stored in the database for later use. Therefore, the image corresponding to the second pixel array does not need to be stretched or deformed, and the obtained signature of the target image can be further ensured to be more accurate.
In an actual application process, the preset height and the preset width are generally set according to a requirement of a user for a specific size of a normalized signature, and for convenience of subsequent use, the preset height and the preset width are the same. Of course, the preset height and the preset width may be different.
In a specific embodiment, the step of converting the image corresponding to the second pixel array into the character string may further include:
presenting the second pixel array SA as canvas by using an API algorithm of putImageData;
the canvas is converted to a base64 representation of the target Image using the API algorithm of the TODataURL ("Image/Png"), where base64 is the above-described string.
In a specific embodiment, the specific process of determining the signature of the target image according to the image corresponding to the second pixel array is as follows: setting the src attribute value of the IMG element in the HTML document to the above character string (base64), thereby obtaining an image corresponding to the above second pixel array in the web page; the method may further include obtaining a signature of the target image having a uniform specification by assigning the image corresponding to the second pixel array with the predetermined width and the predetermined height, and may directly store the target image as the signature in a database or convert the scaled image into the character string and store the character string as the signature in the database for storage.
According to another exemplary embodiment of the present application, there is also provided a method for generating an image signature, and fig. 3 is a flowchart illustrating another method for generating an image signature according to an exemplary embodiment, and as shown in fig. 3, the method includes the following steps:
in step S21, a first pixel array of the target image is obtained, where the first pixel array includes pixel information of each pixel point.
The pixel information includes a color value and a transparency a (Alpha, transparency), where the color value includes a first color channel value, a second color channel value, and a third color channel value, the first color channel value may be an R (Red ) value, the second color channel value may be a G (green ) value, and the third color channel value may be a B (Blue ) value, and the pixel information ranges from 0 to 255, where 0 of the transparency represents transparency, and 255 of the transparency represents complete visibility.
In step S22, a scaled image having a width equal to a predetermined width and a height equal to a predetermined height is obtained according to the first pixel array.
In step S23, an image to be converted is determined from the above scaled image;
in step S24, the image to be converted is converted into a character string, and a signature of the target image is generated.
In the above embodiment, first, a first pixel array of a target image is obtained, where the first pixel array includes pixel information of each pixel point; then, obtaining a zoom image according to the first pixel array, wherein the width of the zoom image is equal to a preset width and the height of the zoom image is equal to a preset height; then, determining an image to be converted according to the zoomed image; and finally, converting the image to be converted into a character string to generate the signature of the target image. According to the scheme, the signatures of the target images are determined according to the zoom images, so that the signatures of the same specification can be generated by the images with different sizes.
According to a specific embodiment of the present application, the step of obtaining a scaled image according to the first pixel array includes: calculating a target color value of a center pixel point according to the pixel information of each pixel point in a predetermined area, wherein the center pixel point is the pixel point located in the center of the predetermined area; and acquiring the zoom image according to all the target color values.
According to another specific embodiment of the present application, before the step of calculating the target color value of the center pixel according to the pixel information of each of the pixels in the predetermined area, the step of obtaining the scaled image according to the first pixel array further includes: and determining the preset area with each pixel point as a center. According to the method, the preset area is determined by taking each pixel point as the center, the preset area of the preset area can be flexibly adjusted, so that the zooming image and the accuracy of the obtained zooming image can be adjusted by adjusting the size of the preset area aiming at the same target image, the speed of obtaining the signature of the target image and the accuracy of the obtained signature of the target image can be flexibly adjusted, and the problems that the time required for obtaining the image signature and the accuracy of the image signature cannot be flexibly adjusted aiming at the same image in the prior art are well solved.
For obtaining the target color value of the pixel point more simply and more accurately, according to a specific embodiment of the present application, the step of calculating the target color value of the center pixel point according to the pixel information of each pixel point in the predetermined area of the target image includes: calculating the average color value of each pixel point, wherein the average color value is the average value of the first color channel value, the second color channel value and the third color channel value, namely calculating the gray value of each pixel point; acquiring the average color value of each pixel point in the preset area; and calculating the target color value of the corresponding central pixel point according to the average color value of each pixel point in the preset area. According to the method, the gray value of each pixel point in the preset area is calculated, and the target color value is calculated according to the gray value, so that the target color value of the pixel point is obtained simply and accurately, and a good data basis is provided for subsequently determining the signature of the target image.
According to another specific embodiment of the present application, the step of calculating the target color value of the corresponding pixel point according to the average color value of each pixel point in the predetermined area includes: calculating the average color values of all the pixel points in the preset area to obtain an updated average value; and respectively taking the updated average values as target color values of the corresponding pixel points, wherein the target color values comprise a target first color channel value, a target second color channel value and a target third color channel value, and the target first color channel value, the target second color channel value and the target third color channel value form the target color values. Therefore, the noise of the image is ensured to be low, the detail level of the image is ensured to be low, and the image effect of the image under different proportions is ensured to be good.
In an actual application process, before the step of calculating the target color value of the corresponding pixel point according to the average color value of each pixel point in the predetermined area, the method includes: and determining the preset area of the preset area by taking the pixel point as a circle center and the preset distance as a radius. Of course, the shape of the predetermined area is not limited to a circle, and the predetermined area may also be a rectangle or other irregular shape, and one skilled in the art can flexibly adjust the predetermined distance to determine the predetermined area with different shapes.
According to another specific embodiment of the present application, the step of obtaining the scaled image according to all the target color values includes: processing all the target color values to obtain a second pixel array; acquiring a preset height and a preset width; and zooming the image corresponding to the second pixel array at least according to the preset width and the preset height to obtain the zoomed image. This ensures that different sized images can generate signatures of the same specification.
According to another specific embodiment of the present application, the scaling the image corresponding to the second pixel array according to at least the preset width and the preset height to obtain a scaled image includes: scaling the width of the image corresponding to the second pixel array to the preset width; scaling the height of the image corresponding to the second pixel array to the preset height; the step of determining an image to be converted according to the scaled image includes: and determining the zoomed image with the width equal to the preset width and the height equal to the preset height as the image to be converted.
In a specific embodiment, the specific process of determining the signature of the target image according to the image corresponding to the second pixel array is as follows: setting the src attribute value of the IMG element in the HTML document to the above character string (base64), thereby obtaining an image corresponding to the above second pixel array in the web page; the method may further include obtaining a signature of the target image having a uniform specification by assigning the image corresponding to the second pixel array with the predetermined width and the predetermined height, and may directly store the target image as the signature in a database or convert the scaled image into the character string and store the character string as the signature in the database for storage.
In the above embodiment, since the width and the height are forcibly set for the image corresponding to the second pixel array, the image corresponding to the second pixel array may be stretched or compressed to a certain extent, and there is a certain distortion, in order to further ensure that the obtained signature of the target image is accurate, in another specific embodiment of the present application, the scaling the image corresponding to the second pixel array at least according to the preset width and the preset height, and the step of obtaining the scaled image includes: acquiring the aspect ratio of the image corresponding to the second pixel array; determining a scaling value according to the aspect ratio of the image corresponding to the second pixel array and a predetermined size value, wherein the predetermined size value is the maximum value of the preset height and the preset width; and scaling one of the scaled width and height of the image corresponding to the second pixel array to the scaling value, and scaling the other of the scaled width and height of the image corresponding to the second pixel array to the predetermined size value to obtain the scaled image, wherein the aspect ratio of the image corresponding to the second pixel array is equal to the aspect ratio of the scaled image. According to the method, the image corresponding to the second pixel array is scaled in an equal proportion, and the image corresponding to the second pixel array does not need to be stretched or deformed, so that the obtained signature of the target image can be ensured to be more accurate. For example, when the maximum value of the preset height and the preset width is the preset width, the image corresponding to the second pixel array is scaled in an equal proportion by taking the preset height as a reference, that is, the height of the image corresponding to the second pixel array is scaled to the preset height, the width of the image corresponding to the second pixel array is scaled to a scaling value, the scaling value is equal to the ratio of the preset height to the aspect ratio of the image corresponding to the second pixel array, so as to obtain a scaled image, and the aspect ratio of the scaled image is consistent with the aspect ratio of the image corresponding to the second pixel array, that is, the image corresponding to the second pixel array is scaled in an equal proportion.
In practical applications, the scaling is not limited to the above-mentioned scaling based on the maximum value of the preset height and the preset width, and the scaling may be performed based on the minimum value of the preset height and the preset width. Specifically, the predetermined size value is the minimum value of the preset height and the preset width, a scaling value is calculated according to the aspect ratio and the preset width of the image corresponding to the second pixel array, that is, the height corresponding to the scaled image is calculated, and subsequently, the width of the image corresponding to the second pixel array is scaled to the preset width, and the height is scaled to the scaling value, so that the equal scaling is realized.
In order to further ensure that the obtained distortion of the signature of the target image is smaller and thus more accurate, in an actual application process, in an embodiment, the step of determining the image to be converted according to the scaled image includes: acquiring an initialized pixel array, wherein the initialized pixel array comprises initialized pixel information, the initialized pixel information comprises an initialized color value and an initialized transparency, the initialized color value comprises an initialized first color channel value, an initialized second color channel value and an initialized third color channel value, and the length of the initialized pixel array is equal to the product of the preset height and the preset width; and processing the initialized pixel array and the zoomed image to obtain the image to be converted.
In another embodiment of the application, the processing the initialized pixel array and the scaled image to obtain the image to be converted includes: acquiring pixel information of each pixel point in the zoomed image; the first replacement submodule is configured to perform replacement of the initialized pixel information by using the pixel information to obtain a replaced initialized pixel array, and the position of the pixel point corresponding to the replaced initialized pixel information is the same as the position of the pixel point corresponding to the replaced pixel information; and acquiring the image corresponding to the replaced initialization pixel array to obtain the image to be converted. And by a replacement mode, a zoom image with a preset width and a preset height is obtained, and the small distortion degree of the signature of the image is further ensured.
In a specific embodiment, the initializing color values include initializing a first color channel value, initializing a second color channel value, and initializing a third color channel value, and the initializing the first color channel value, the initializing the second color channel value, the initializing the third color channel value, and the initializing transparency are equal. The specific values of the initialization first color channel value, the initialization second color channel value, the initialization third color channel value and the initialization transparency may be set according to actual situations.
In a more specific embodiment, the initialization first color channel value, the initialization second color channel value, the initialization third color channel value, and the initialization transparency are all equal to 0.
For the convenience of subsequent use, in an embodiment of the present application, the signature of the target image is stored in a database. Specifically, the signature of the target image can be directly stored in the database or the signature of the target image is converted into a webpage image and stored in the database for use. In a specific embodiment, the specific process of determining the signature of the target image according to the image corresponding to the second pixel array may further include: setting the src attribute value of the IMG element in the HTML document to the above character string (base64), thereby obtaining an image corresponding to the above second pixel array in the web page; acquiring the original width W and height H of the image by using an API (application programming interface) algorithm of naturalWidth or naturalHeight to obtain the aspect ratio r of the image corresponding to the second pixel array; acquiring the preset width W1 and the preset height H1, wherein H1/r is a zoom size, that is, the width of the zoomed image obtained after zooming, when the preset height is greater than the preset width, and the preset height is the height of the zoomed image obtained after zooming; performing scaling processing on the image by using an API algorithm of drawImage (IMG, 0, 0, H1, H1/r); using an API algorithm of getImageData to obtain an RGBA array ARR1 of all pixels of the scaled image, initializing an array with a length equal to W1 × H1 to obtain the initialized pixel array, where the initialized first color channel value, the initialized second color channel value, the initialized third color channel value, and the initialized transparency in the initialized pixel array are all equal to 0, that is, the default fill color value is black, for example, the initialized pixel array ARR2 [ [0, 0, 0, 0], [0, 0, 0, 0], …, [0, 0, 0] ]; replacing the pixel information of the ARR2 at the same position as the ARR1 with the value in the ARR1 to obtain the replaced image; converting the alternative Image into a base64 representation by using a toDataURL ("Image/Png") algorithm, wherein the base64 is the character string; the character string can be directly stored in a database as a normalized image signature or the character string code is converted into a webpage image to be stored in the database for later use. Therefore, the image corresponding to the second pixel array does not need to be stretched or deformed, and the obtained signature of the target image can be further ensured to be more accurate.
In an actual application process, the preset height and the preset width are generally set according to a requirement of a user for a specific size of a normalized signature, and for convenience of subsequent use, the preset height and the preset width are the same. Of course, the preset height and the preset width may be different.
According to still another exemplary embodiment of the present application, there is also provided an image signature generation apparatus, fig. 4 is a block diagram of an image signature generation apparatus according to an exemplary embodiment, and referring to fig. 4, the apparatus includes a first acquisition unit 10, a first determination unit 20, a first calculation unit 30, a second determination unit 40, and a first generation unit 50.
The first obtaining unit 10 is configured to obtain a first pixel array of the target image, where the first pixel array includes pixel information of each pixel point.
The pixel information includes a color value and a transparency a (Alpha, transparency), where the color value includes a first color channel value, a second color channel value, and a third color channel value, the first color channel value may be an R (Red ) value, the second color channel value may be a G (green ) value, and the third color channel value may be a B (Blue ) value, and the pixel information ranges from 0 to 255, where 0 of the transparency represents transparency, and 255 of the transparency represents complete visibility.
A first determination unit 20 configured to perform determination of a predetermined region of a preset area with each of the above-described pixel points as a center.
A first calculating unit 30 configured to calculate a target color value of a center pixel according to the pixel information of each of the pixels in the predetermined area, wherein the center pixel is the pixel located in the center of the predetermined area.
A second determining unit 40 configured to determine an image to be converted according to at least all of the target color values;
and a first generating unit 50 configured to perform conversion of the image to be converted into a character string and generate a signature of the target image.
In the above embodiment, the first obtaining unit 10 obtains a first pixel array of the target image, where the first pixel array includes pixel information of each pixel point; the first determining unit 20 determines a predetermined area of a preset area with each of the pixel points as a center; the first calculating unit 30 calculates a target color value of a center pixel point according to the pixel information of each pixel point in a predetermined region of the target image; the second determining unit 40 determines the image to be converted at least according to all the target color values; the first generation unit 50 converts the image to be converted into a character string, and generates a signature of the target image. In the scheme, the preset area is determined by taking each pixel point as the center, the preset area of the preset area can be flexibly adjusted, so that the accuracy of obtaining the zoom image and the accuracy of obtaining the zoom image can be adjusted by adjusting the size of the preset area aiming at the same target image, the speed of obtaining the signature of the target image and the accuracy of obtaining the signature of the target image can be flexibly adjusted, and the problems that the time required for obtaining the image signature and the accuracy of the image signature cannot be flexibly adjusted aiming at the same image in the prior art are well solved.
In an actual application process, when the area of the selected predetermined area is large, the signature of the image can be obtained quickly and roughly, and when the area of the selected predetermined area is small, the signature of the image can be obtained slowly and accurately.
In an actual application process, the first determining unit includes a first determining subunit, where the first determining subunit determines the predetermined area corresponding to each pixel point by taking the pixel point as a center of a circle and a predetermined distance as a radius. Of course, the shape of the predetermined area is not limited to a circle, and the predetermined area may also be a rectangle or other irregular shape, and in addition, the skilled person can flexibly adjust the predetermined distance to determine the predetermined area with different areas.
In order to obtain the target color value of the pixel more simply and more accurately, according to a specific embodiment of the present application, the first calculating unit includes a first calculating subunit, a first obtaining subunit, and a second calculating subunit, where the first calculating subunit is configured to perform calculation of an average color value of each pixel, where the average color value is an average value of a first color channel value, a second color channel value, and a third color channel value in the color values, that is, a gray value of each pixel is calculated; the first obtaining subunit is configured to perform obtaining an average color value of each of the pixel points in the predetermined area; the second calculating subunit is configured to calculate the target color value of the corresponding center pixel according to the average color value of each pixel in the predetermined area. According to the device, the gray value of each pixel point in the preset area is calculated, and the target color value is calculated according to the gray value, so that the target color value of the pixel point is obtained simply and accurately, and a good data basis is provided for subsequently determining the signature of the target image.
According to another specific embodiment of the present application, the second calculating subunit includes a first calculating module and a first determining module, wherein the first calculating module is configured to calculate the average color values of all the pixel points in the predetermined area to obtain an updated average value; the first determining module is configured to perform taking the updated average value as the target color value of the corresponding central pixel point, that is, taking the updated average value as an updated first color channel value, an updated second color channel value, and an updated third color channel value of the corresponding pixel point, respectively, where the updated first color channel value, the updated second color channel value, and the updated third color channel value form the target color value. Therefore, the noise of the image is ensured to be low, the detail level of the image is ensured to be low, and the image effect of the image under different proportions is ensured to be good.
In order to further ensure that the efficiency of obtaining the signature of the target image is high and the smoothness and the definition of the image are good, according to another specific embodiment of the present application, the second determining unit includes a first processing subunit and a second determining subunit, where the first processing subunit is configured to perform processing on all the target color values to obtain a second pixel array; the second determining subunit is configured to determine the image to be converted according to the second pixel array. The device processes all the target color values, and gives consideration to the efficiency of acquiring the signature of the target image, and the smoothness and definition effects of the image.
In another specific embodiment of the present application, the first processing subunit includes a second determining module and a third determining module, where the second determining module is configured to determine predetermined pixel points, and a predetermined number of the pixel points are located between two adjacent predetermined pixel points; the third determining module is configured to determine the second pixel array formed by the target color values and the transparency of all the predetermined pixels.
In a specific embodiment, a value S is first set as a threshold, a predetermined pixel is taken every S pixels to obtain N predetermined pixels, and the predetermined pixels are obtained by using a formula SA [ [ R [0], G [0], B [0], a [0] ], … [ [ R [ S ], G [ S ], B [ S ], a [ S ] ], …, [ [ R [ N ] S ], G [ N ] S ], B [ N ] S ], a [ N ] S ], and SA is the second pixel array.
In an embodiment of the present application, the second determining subunit includes a first obtaining module and a fourth determining module, where the first obtaining module is configured to perform obtaining an image corresponding to a second pixel array; the fourth determining module is configured to perform taking the image corresponding to the second pixel array as the image to be converted.
In another specific embodiment of the present application, the second determining subunit includes a second obtaining module, a first scaling module, and a fifth determining module, where the second obtaining module is configured to obtain a preset height and a preset width; the first scaling submodule is configured to perform scaling processing on an image corresponding to the second pixel array according to at least the preset width and the preset height to obtain a scaled image; the fifth determining module is configured to determine the image to be converted according to the scaled image. This ensures that different sized images can generate signatures of the same specification.
In another specific embodiment of the present application, the first scaling module is further configured to scale the width of the image corresponding to the second pixel array to the preset width; scaling the height of the image corresponding to the second pixel array to the preset height; the first determining submodule is further configured to determine the scaled image having the width equal to the preset width and the height equal to the preset height as the image to be converted.
In the foregoing embodiment, since the width and the height are forcibly set for the image corresponding to the second pixel array, the image corresponding to the second pixel array may be stretched or compressed to a certain extent, and there is a certain distortion, in order to further ensure that the obtained signature of the target image is relatively accurate, in another specific embodiment of the present application, the first scaling module includes a first obtaining submodule, a first determining submodule, and a first scaling submodule, where the first obtaining submodule is configured to perform obtaining of an aspect ratio of the image corresponding to the second pixel array; the first determining submodule is configured to determine a scaling value according to an aspect ratio of an image corresponding to the second pixel array and a predetermined size value, wherein the predetermined size value is a minimum value of the preset height and the preset width; the first scaling submodule is configured to scale one of the width and the height of the image corresponding to the second pixel array to the scaling value, and scale the other of the width and the height of the image corresponding to the second pixel array to the predetermined size value, so as to obtain the scaled image, wherein the aspect ratio of the scaled image is equal to the aspect ratio of the image corresponding to the second pixel array. The device performs equal-scale scaling on the image corresponding to the second pixel array, and does not need to perform stretching or deformation operation on the image corresponding to the second pixel array, so that the obtained signature of the target image can be ensured to be more accurate. For example, when the maximum value of the preset height and the preset width is the preset width, the image corresponding to the second pixel array is scaled in an equal proportion by taking the preset height as a reference, that is, the height of the image corresponding to the second pixel array is scaled to the preset height, the width of the image corresponding to the second pixel array is scaled to a scaling value, the scaling value is equal to the ratio of the preset height to the aspect ratio of the image corresponding to the second pixel array, so as to obtain a scaled image, and the aspect ratio of the scaled image is consistent with the aspect ratio of the image corresponding to the second pixel array, that is, the image corresponding to the second pixel array is scaled in an equal proportion.
In practical applications, the scaling is not limited to the above-mentioned scaling based on the maximum value of the preset height and the preset width, and the scaling may be performed based on the minimum value of the preset height and the preset width. Specifically, the predetermined size value is the minimum value of the preset height and the preset width, a scaling value is calculated according to the aspect ratio and the preset width of the image corresponding to the second pixel array, that is, the height corresponding to the scaled image is calculated, and subsequently, the width of the image corresponding to the second pixel array is scaled to the preset width, and the height is scaled to the scaling value, so that the equal scaling is realized.
In order to further ensure that the obtained signature of the target image has a smaller distortion degree and thus is more accurate, in an actual application process, the fifth determining module includes a second obtaining sub-module and a first processing sub-module, wherein the second obtaining sub-module is configured to perform obtaining of an initialized pixel array, the initialized pixel array includes initialized pixel information, the initialized pixel information includes an initialized color value and an initialized transparency, the initialized color value includes an initialized first color channel value, an initialized second color channel value and an initialized third color channel value, and a length of the initialized pixel array is equal to a product of the preset height and the preset width; the first processing submodule is configured to perform processing on the initialized pixel array and the scaled image to obtain the image to be converted.
In another embodiment of the present application, the first processing submodule includes a third obtaining submodule, a first replacing submodule, and a fourth obtaining submodule, where the third obtaining submodule is configured to perform obtaining of pixel information of each pixel point in the zoomed image; the first replacement submodule is configured to perform replacement of the initialized pixel information by using the pixel information to obtain a replaced initialized pixel array, and the position of the pixel point corresponding to the replaced initialized pixel information is the same as the position of the pixel point corresponding to the replaced pixel information; and the fourth obtaining submodule is configured to obtain the image corresponding to the replaced initialization pixel array, so as to obtain the image to be converted. And by a replacement mode, a zoom image with a preset width and a preset height is obtained, and the small distortion degree of the signature of the image is further ensured.
In a specific embodiment, the initializing color values include initializing a first color channel value, initializing a second color channel value, and initializing a third color channel value, and the initializing the first color channel value, the initializing the second color channel value, the initializing the third color channel value, and the initializing transparency are equal. The specific values of the initialization first color channel value, the initialization second color channel value, the initialization third color channel value and the initialization transparency may be set according to actual situations.
In a more specific embodiment, the initialization first color channel value, the initialization second color channel value, the initialization third color channel value, and the initialization transparency are all equal to 0.
In order to facilitate subsequent use, in an embodiment of the present application, the apparatus includes a first storage unit configured to perform storing the signature of the target image in a database. Specifically, the signature of the target image can be directly stored in the database or the signature of the target image is converted into a webpage image and stored in the database for use.
In a specific embodiment, the specific process of determining the signature of the target image according to the image corresponding to the second pixel array may further include: setting the src attribute value of the IMG element in the HTML document to the above character string (base64), thereby obtaining an image corresponding to the above second pixel array in the web page; acquiring the original width W and height H of the image by using an API (application programming interface) algorithm of naturalWidth or naturalHeight to obtain the aspect ratio r of the image corresponding to the second pixel array; acquiring the preset width W1 and the preset height H1, wherein H1/r is a zoom size, that is, the width of the zoomed image obtained after zooming, when the preset height is greater than the preset width, and the preset height is the height of the zoomed image obtained after zooming; performing scaling processing on the image by using an API algorithm of drawImage (IMG, 0, 0, H1, H1/r); using an API algorithm of getImageData to obtain an RGBA array ARR1 of all pixels of the scaled image, initializing an array with a length equal to W1 × H1 to obtain the initialized pixel array, where the initialized first color channel value, the initialized second color channel value, the initialized third color channel value, and the initialized transparency in the initialized pixel array are all equal to 0, that is, the default fill color value is black, for example, the initialized pixel array ARR2 [ [0, 0, 0, 0], [0, 0, 0, 0], …, [0, 0, 0] ]; replacing the pixel information of the ARR2 at the same position as the ARR1 with the value in the ARR1 to obtain the replaced image; converting the alternative Image into a base64 representation by using a toDataURL ("Image/Png") algorithm, wherein the base64 is the character string; the character string can be directly stored in a database as a normalized image signature or the character string code is converted into a webpage image to be stored in the database for later use. Therefore, the image corresponding to the second pixel array does not need to be stretched or deformed, and the obtained signature of the target image can be further ensured to be more accurate.
In an actual application process, the preset height and the preset width are generally set according to a requirement of a user for a specific size of a normalized signature, and for convenience of subsequent use, the preset height and the preset width are the same. Of course, the preset height and the preset width may be different.
In a specific embodiment, the step of converting the image corresponding to the second pixel array into the character string may further include:
presenting the second pixel array SA as canvas by using an API algorithm of putImageData;
the canvas is converted to a base64 representation of the target Image using the API algorithm of the TODataURL ("Image/Png"), where base64 is the above-described string.
In a specific embodiment, the specific process of determining the signature of the target image according to the image corresponding to the second pixel array is as follows: setting the src attribute value of the IMG element in the HTML document to the above character string (base64), thereby obtaining an image corresponding to the above second pixel array in the web page; the device may obtain a signature of the target image having a uniform specification by assigning the preset width and the preset height to the image corresponding to the second pixel array, and may directly store the target image as a signature in a database or convert the scaled image into the character string and store the character string as a signature in a database for storage.
According to still another exemplary embodiment of the present application, there is also provided an image signature generation apparatus, fig. 5 is a block diagram of another image signature generation apparatus according to an exemplary embodiment, and referring to fig. 5, the apparatus includes a second acquisition unit 60, a third acquisition unit 70, a third determination unit 80, and a second generation unit 90.
The second obtaining unit 60 is configured to perform obtaining a first pixel array of the target image, where the first pixel array includes pixel information of each pixel point.
The pixel information includes a color value and a transparency a (Alpha, transparency), where the color value includes a first color channel value, a second color channel value, and a third color channel value, the first color channel value may be an R (Red ) value, the second color channel value may be a G (green ) value, and the third color channel value may be a B (Blue ) value, and the pixel information ranges from 0 to 255, where 0 of the transparency represents transparency, and 255 of the transparency represents complete visibility.
The third obtaining unit 70 is configured to obtain a scaled image having a width equal to a preset width and a height equal to a preset height according to the first pixel array.
The third determining unit 80 is configured to perform a determination of an image to be converted from the scaled image;
and a second generating unit 90 configured to perform conversion of the image to be converted into a character string, and generate a signature of the target image.
In the above embodiment, the second obtaining unit obtains a first pixel array of the target image, where the first pixel array includes pixel information of each pixel point; acquiring a zoom image according to the first pixel array by the third acquisition unit, wherein the width of the zoom image is equal to a preset width and the height of the zoom image is equal to a preset height; determining an image to be converted according to the zoomed image by the third determining unit; and the second generation unit converts the image to be converted into a character string and generates a signature of the target image. According to the scheme, the signatures of the target images are determined according to the zoom images, so that the signatures of the same specification can be generated by the images with different sizes.
According to a specific embodiment of the present application, the third obtaining unit includes a third calculating subunit and a second obtaining subunit, where the third calculating subunit is configured to execute a calculation process configured to calculate a target color value of a center pixel according to the pixel information of each of the pixels in a predetermined area, where the center pixel is the pixel located in the center of the predetermined area; the second acquiring subunit is configured to execute the step of acquiring the scaled image according to all of the target color values.
According to another specific embodiment of the present application, the third obtaining unit further includes a third determining subunit, where the third determining subunit is configured to determine the predetermined area with a preset area centered around each of the pixel points before the step of calculating the target color value of the center pixel point according to the pixel information of each of the pixel points in the predetermined area is performed. According to the device, the preset area is determined by taking each pixel point as the center, the preset area of the preset area can be flexibly adjusted, so that the accuracy of obtaining the zoom image and the accuracy of obtaining the zoom image can be adjusted by adjusting the size of the preset area aiming at the same target image, the speed of obtaining the signature of the target image and the accuracy of obtaining the signature of the target image can be flexibly adjusted, and the problems that the time required for obtaining the picture signature and the accuracy of the picture signature cannot be flexibly adjusted aiming at the same picture in the prior art are well solved.
In order to obtain the target color value of the pixel point more simply and accurately, in a specific embodiment of the present application, the second calculating unit includes a fourth calculating subunit and a fifth calculating subunit, where the fourth calculating subunit is configured to perform calculation of an average color value of each pixel point, where the average color value is an average value of the first color channel value, the second color channel value, and the third color channel value, that is, a gray value of each pixel point is calculated; the fifth calculating subunit is configured to calculate the target color value of the corresponding pixel point according to the average color value of each pixel point in the predetermined area. According to the device, the gray value of each pixel point in the preset area is calculated, and the target color value is calculated according to the gray value, so that the target color value of the pixel point is obtained simply and accurately, and a good data basis is provided for subsequently determining the signature of the target image.
In another specific embodiment of the present application, the fourth calculating subunit includes a second calculating module and a sixth determining module, where the second calculating module is configured to calculate the average color values of all the pixel points in the predetermined area to obtain an updated average value; the sixth determining module is configured to perform taking the updated average value as the target color value of the corresponding central pixel point, that is, taking the updated average value as an updated first color channel value, an updated second color channel value, and an updated third color channel value of the corresponding pixel point, respectively, where the updated first color channel value, the updated second color channel value, and the updated third color channel value form the target color value. Therefore, the noise of the image is ensured to be low, the detail level of the image is ensured to be low, and the image effect of the image under different proportions is ensured to be good.
In an actual application process, the third determining subunit of the apparatus is configured to determine the predetermined area corresponding to each of the pixel points by taking the pixel point as a center of a circle and taking a predetermined distance as a radius. Of course, the shape of the predetermined area is not limited to a circle, and the predetermined area may also be a rectangle or other irregular shape, and one skilled in the art can flexibly adjust the predetermined distance to determine the predetermined area with different shapes.
According to another specific embodiment of the present application, the second obtaining subunit includes a first processing module, a sixth obtaining module, and a third scaling module, where the first processing module is configured to perform processing on all the target color values to obtain a second pixel array; the sixth acquisition module is configured to perform acquisition of a preset height and a preset width; the third zooming module is configured to zoom the image corresponding to the second pixel array according to at least the preset width and the preset height, so as to obtain the zoomed image. This ensures that different sized images can generate signatures of the same specification.
In a specific embodiment, the specific process of determining the signature of the target image according to the image corresponding to the second pixel array is as follows: setting the src attribute value of the IMG element in the HTML document to the above character string (base64), thereby obtaining an image corresponding to the above second pixel array in the web page; the device may obtain a signature of the target image having a uniform specification by assigning the preset width and the preset height to the image corresponding to the second pixel array, and may directly store the target image as a signature in a database or convert the scaled image into the character string and store the character string as a signature in a database for storage.
In the foregoing embodiment, since the width and the height are forcibly set for the image corresponding to the second pixel array, the image corresponding to the second pixel array may be stretched or compressed to a certain extent, and there is a certain distortion, in order to further ensure that the obtained signature of the target image is accurate, in another specific embodiment of the present application, the third scaling module includes a fifth obtaining sub-module, a second determining sub-module, and a second scaling sub-module, where the fifth obtaining sub-module is configured to perform obtaining of an aspect ratio of the image corresponding to the second pixel array; the second determining submodule is configured to determine a scaling value according to an aspect ratio of an image corresponding to the second pixel array and a predetermined size value, wherein the predetermined size value is the maximum value of the preset height and the preset width; the second scaling submodule is configured to scale one of a width and a height of the image corresponding to the second pixel array to the scaling value, and scale the other of the width and the height of the image corresponding to the second pixel array to the predetermined size value to obtain the scaled image, wherein an aspect ratio of the image corresponding to the second pixel array is equal to the aspect ratio of the scaled image. The device does not need to stretch or deform the image corresponding to the second pixel array, so that the obtained signature of the target image can be ensured to be more accurate.
In practical applications, the scaling is not limited to the above-mentioned scaling based on the maximum value of the preset height and the preset width, and the scaling may be performed based on the minimum value of the preset height and the preset width. Specifically, the predetermined size value is the minimum value of the preset height and the preset width, a scaling value is calculated according to the aspect ratio and the preset width of the image corresponding to the second pixel array, that is, the height corresponding to the scaled image is calculated, and subsequently, the width of the image corresponding to the second pixel array is scaled to the preset width, and the height is scaled to the scaling value, so that the equal scaling is realized.
In order to further ensure that the obtained signature of the target image has a smaller distortion degree and thus is more accurate, in an actual application process, the third determining unit includes a third obtaining sub-unit configured to perform obtaining of an initialized pixel array, where the initialized pixel array includes initialized pixel information, the initialized pixel information includes an initialized color value and an initialized transparency, and a length of the initialized pixel array is equal to a product of the preset height and the preset width; and the second processing subunit is configured to execute processing on the initialized pixel array and the scaled image to obtain the image to be converted.
In another embodiment of the application, the second processing sub-module includes a seventh obtaining module, a second replacing module, and an eighth obtaining module, where the seventh obtaining module is configured to perform obtaining of pixel information of each pixel point in the zoomed image; the second replacement module is configured to perform replacement of the initialized pixel information by using the pixel information to obtain a replaced initialized pixel array, wherein the pixel point corresponding to the replaced initialized pixel information is at the same position as the pixel point corresponding to the replaced pixel information; the eighth obtaining module is configured to perform obtaining of the image corresponding to the replaced initialization pixel array, so as to obtain the image to be converted. And by a replacement mode, a zoom image with a preset width and a preset height is obtained, and the small distortion degree of the signature of the image is further ensured.
In a specific embodiment, the initializing color values include initializing a first color channel value, initializing a second color channel value, and initializing a third color channel value, and the initializing the first color channel value, the initializing the second color channel value, the initializing the third color channel value, and the initializing transparency are equal. The specific values of the initialization first color channel value, the initialization second color channel value, the initialization third color channel value and the initialization transparency may be set according to actual situations.
In a more specific embodiment, the initialization first color channel value, the initialization second color channel value, the initialization third color channel value, and the initialization transparency are all equal to 0.
In order to facilitate subsequent use, in an embodiment of the present application, the apparatus further includes: and the second storage unit is configured to store the signature of the target image into a database. Specifically, the signature of the target image can be directly stored in the database or the signature of the target image is converted into a webpage image and stored in the database for use.
In a specific embodiment, the specific process of determining the signature of the target image according to the image corresponding to the second pixel array may further include: setting the src attribute value of the IMG element in the HTML document to the above character string (base64), thereby obtaining an image corresponding to the above second pixel array in the web page; acquiring the original width W and height H of the image by using an API (application programming interface) algorithm of naturalWidth or naturalHeight to obtain the aspect ratio r of the image corresponding to the second pixel array; acquiring the preset width W1 and the preset height H1, wherein H1/r is a zoom size, that is, the width of the zoomed image obtained after zooming, when the preset height is greater than the preset width, and the preset height is the height of the zoomed image obtained after zooming; performing scaling processing on the image by using an API algorithm of drawImage (IMG, 0, 0, H1, H1/r); using an API algorithm of getImageData to obtain an RGBA array ARR1 of all pixels of the scaled image, initializing an array with a length equal to W1 × H1 to obtain the initialized pixel array, where the initialized first color channel value, the initialized second color channel value, the initialized third color channel value, and the initialized transparency in the initialized pixel array are all equal to 0, that is, the default fill color value is black, for example, the initialized pixel array ARR2 [ [0, 0, 0, 0], [0, 0, 0, 0], …, [0, 0, 0] ]; replacing the pixel information of the ARR2 at the same position as the ARR1 with the value in the ARR1 to obtain the replaced image; converting the alternative Image into a base64 representation by using a toDataURL ("Image/Png") algorithm, wherein the base64 is the character string; the character string can be directly stored in a database as a normalized image signature or the character string code is converted into a webpage image to be stored in the database for later use. Therefore, the image corresponding to the second pixel array does not need to be stretched or deformed, and the obtained signature of the target image can be further ensured to be more accurate.
In an actual application process, the preset height and the preset width are generally set according to a requirement of a user for a specific size of a normalized signature, and for convenience of subsequent use, the preset height and the preset width are the same. Of course, the preset height and the preset width may be different.
There is also provided, in accordance with another exemplary embodiment of the present application, an electronic device, including a processor and a memory configured to execute instructions stored in the memory, where the processor is configured to execute the instructions to implement any one of the above-mentioned image signature generation methods.
The electronic device includes a processor and a memory configured to execute instructions stored in the memory, where the processor is configured to execute the instructions to implement any one of the above image signature generation methods. The electronic equipment can flexibly adjust the size of the preset area, and can adjust the speed of acquiring the second pixel array and the accuracy of acquiring the second pixel array by adjusting the size of the preset area aiming at the same target image, so that the speed of acquiring the signature of the target image and the accuracy of acquiring the signature of the target image can be flexibly adjusted, and the problems that the time required for acquiring the picture signature and the accuracy of the picture signature cannot be flexibly adjusted aiming at the same picture in the prior art are well solved. Meanwhile, the scheme ensures that the images with different sizes can generate the signatures with the same specification by acquiring the zoom images and determining the signatures of the target images according to the zoom images, and better solves the problem that the existing images with different specifications cannot generate the signatures with the same specification.
According to still another exemplary embodiment of the present application, there is provided a computer-readable storage medium, wherein instructions of the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform any one of the above-described image signature generation methods.
The storage medium described above, wherein the instructions, when executed by a processor of an electronic device, enable the electronic device to perform any one of the above-described image signature generation methods. The storage medium can flexibly adjust the size of the preset area, and can adjust the speed of acquiring the second pixel array and the accuracy of acquiring the second pixel array by adjusting the size of the preset area aiming at the same target image, so that the speed of acquiring the signature of the target image and the accuracy of acquiring the signature of the target image can be flexibly adjusted, and the problems that the time required for acquiring the picture signature and the accuracy of the picture signature cannot be flexibly adjusted aiming at the same picture in the prior art are well solved. Meanwhile, the scheme ensures that the images with different sizes can generate the signatures with the same specification by acquiring the zoom images and determining the signatures of the target images according to the zoom images, and better solves the problem that the existing images with different specifications cannot generate the signatures with the same specification.
In yet another exemplary embodiment of the application, a computer program product is provided, comprising computer instructions which, when executed by a processor, implement any of the generation methods.
The computer program product can flexibly adjust the size of a preset area, and can adjust the speed of acquiring the second pixel array and the accuracy of acquiring the second pixel array by adjusting the size of the preset area aiming at the same target image, thereby ensuring the flexible adjustment of the speed of acquiring the signature of the target image and the accuracy of acquiring the signature of the target image, and better solving the problems that the time required for acquiring the picture signature and the accuracy of the picture signature cannot be flexibly adjusted aiming at the same picture in the prior art. Meanwhile, the scheme ensures that the images with different sizes can generate the signatures with the same specification by acquiring the zoom images and determining the signatures of the target images according to the zoom images, and better solves the problem that the existing images with different specifications cannot generate the signatures with the same specification.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A method for generating an image signature, comprising:
acquiring a first pixel array of a target image, wherein the first pixel array comprises pixel information of each pixel point, and the pixel information comprises a color value and a transparency;
determining a preset area of a preset area by taking each pixel point as a center;
calculating a target color value of a center pixel point according to the pixel information of each pixel point in the preset area, wherein the center pixel point is the pixel point positioned in the center of the preset area;
determining an image to be converted at least according to all the target color values;
and converting the image to be converted into a character string to generate a signature of the target image.
2. The method of claim 1, wherein the step of determining the image to be converted based on at least all of the target color values comprises:
processing all the target color values to obtain a second pixel array;
and determining the image to be converted according to the second pixel array.
3. The method of claim 2, wherein the determining the image to be converted from the second pixel array comprises:
acquiring a preset height and a preset width;
zooming the image corresponding to the second pixel array at least according to the preset width and the preset height to obtain a zoomed image;
and determining the image to be converted according to the scaled image.
4. The method of claim 3,
the step of scaling the image corresponding to the second pixel array at least according to the preset width and the preset height to obtain a scaled image comprises: scaling the width of the image corresponding to the second pixel array to the preset width; scaling the height of the image corresponding to the second pixel array to the preset height;
the step of determining the image to be converted according to the scaled image comprises: and determining the zooming image with the width equal to the preset width and the height equal to the preset height as the image to be converted.
5. The method according to claim 3, wherein the step of scaling the image corresponding to the second pixel array according to at least the preset width and the preset height to obtain a scaled image comprises:
acquiring the aspect ratio of the image corresponding to the second pixel array;
determining a scaling value according to the aspect ratio of the image corresponding to the second pixel array and a preset size value, wherein the preset size value is the maximum value of the preset height and the preset width;
and scaling one of the width and the height of the image corresponding to the second pixel array to the scaling value, and scaling the other of the width and the height of the image corresponding to the second pixel array to the preset size value to obtain the scaled image, wherein the aspect ratio of the scaled image is equal to the aspect ratio of the image corresponding to the second pixel array.
6. The method of claim 5, wherein the step of determining the image to be converted according to the scaled image comprises:
acquiring an initialized pixel array, wherein the initialized pixel array comprises initialized pixel information, the initialized pixel information comprises an initialized color value and an initialized transparency, and the length of the initialized pixel array is equal to the product of the preset height and the preset width;
and processing the initialized pixel array and the zoomed image to obtain the image to be converted.
7. The method of claim 6, wherein the step of processing the initialized pixel array and the scaled image to obtain the image to be converted comprises:
acquiring pixel information of each pixel point in the zoomed image;
replacing the initialized pixel information with the pixel information to obtain a replaced initialized pixel array, wherein the pixel point corresponding to the replaced initialized pixel information is the same as the pixel point corresponding to the replaced pixel information in position;
and acquiring the image corresponding to the replaced initialization pixel array to obtain the image to be converted.
8. An image signature generation device, comprising:
a first acquisition unit configured to perform acquisition of a first pixel array of a target image, the first pixel array including pixel information of each pixel point, the pixel information including a color value and a transparency;
a first determination unit configured to perform determination of a predetermined region of a preset area with each of the pixel points as a center;
a first calculation unit configured to perform calculation of a target color value of a center pixel point according to the pixel information of each of the pixel points in the predetermined area, the center pixel point being the pixel point located at the center of the predetermined area;
the second determining unit is configured to determine an image to be converted according to at least all the target color values;
a first generating unit configured to perform conversion of the image to be converted into a character string, and generate a signature of the target image.
9. An electronic device, comprising:
a processor;
a memory configured to execute instructions stored in the memory;
wherein the processor is configured to execute the instructions to implement the method of generating an image signature as claimed in any one of claims 1 to 7.
10. A storage medium characterized in that instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method of generating an image signature as claimed in any one of claims 1 to 7.
CN202110315365.3A 2021-03-24 2021-03-24 Image signature generation method and device, electronic equipment and storage medium Active CN113033394B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110315365.3A CN113033394B (en) 2021-03-24 2021-03-24 Image signature generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110315365.3A CN113033394B (en) 2021-03-24 2021-03-24 Image signature generation method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113033394A true CN113033394A (en) 2021-06-25
CN113033394B CN113033394B (en) 2024-05-14

Family

ID=76473419

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110315365.3A Active CN113033394B (en) 2021-03-24 2021-03-24 Image signature generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113033394B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2002089105A2 (en) * 2001-05-02 2002-11-07 Bitstream, Inc. Methods, systems, and programming for producing and displaying subpixel-optimized images and digital content including such images
WO2010139007A1 (en) * 2009-06-04 2010-12-09 Peter Bayley Apparatus and methods for storing image with embedded information
CN102292745A (en) * 2009-01-23 2011-12-21 日本电气株式会社 image signature extraction device
CN102349092A (en) * 2009-03-13 2012-02-08 日本电气株式会社 Image identifier extraction device
CN103116628A (en) * 2013-01-31 2013-05-22 新浪网技术(中国)有限公司 Image file digital signature and judgment method and judgment device of repeated image file
CN103871044A (en) * 2012-12-14 2014-06-18 阿里巴巴集团控股有限公司 Image signature generating method and image verifying method and device
CN109241470A (en) * 2018-09-27 2019-01-18 北京小米移动软件有限公司 Page display method, apparatus and system
CN110675465A (en) * 2019-09-23 2020-01-10 京东数字科技控股有限公司 Method and apparatus for generating image
CN111931756A (en) * 2020-10-15 2020-11-13 上海一嗨成山汽车租赁南京有限公司 Method, computing device, and computer storage medium for generating electronic signatures
CN112070866A (en) * 2019-06-11 2020-12-11 腾讯科技(深圳)有限公司 Animation data encoding method, animation data decoding method, animation data encoding apparatus, animation data decoding apparatus, storage medium, and computer device
CN112150394A (en) * 2020-10-12 2020-12-29 杭州睿琪软件有限公司 Image processing method and device, electronic equipment and storage medium

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2002089105A2 (en) * 2001-05-02 2002-11-07 Bitstream, Inc. Methods, systems, and programming for producing and displaying subpixel-optimized images and digital content including such images
CN102292745A (en) * 2009-01-23 2011-12-21 日本电气株式会社 image signature extraction device
CN102349092A (en) * 2009-03-13 2012-02-08 日本电气株式会社 Image identifier extraction device
WO2010139007A1 (en) * 2009-06-04 2010-12-09 Peter Bayley Apparatus and methods for storing image with embedded information
CN103871044A (en) * 2012-12-14 2014-06-18 阿里巴巴集团控股有限公司 Image signature generating method and image verifying method and device
CN103116628A (en) * 2013-01-31 2013-05-22 新浪网技术(中国)有限公司 Image file digital signature and judgment method and judgment device of repeated image file
CN109241470A (en) * 2018-09-27 2019-01-18 北京小米移动软件有限公司 Page display method, apparatus and system
CN112070866A (en) * 2019-06-11 2020-12-11 腾讯科技(深圳)有限公司 Animation data encoding method, animation data decoding method, animation data encoding apparatus, animation data decoding apparatus, storage medium, and computer device
CN110675465A (en) * 2019-09-23 2020-01-10 京东数字科技控股有限公司 Method and apparatus for generating image
CN112150394A (en) * 2020-10-12 2020-12-29 杭州睿琪软件有限公司 Image processing method and device, electronic equipment and storage medium
CN111931756A (en) * 2020-10-15 2020-11-13 上海一嗨成山汽车租赁南京有限公司 Method, computing device, and computer storage medium for generating electronic signatures

Also Published As

Publication number Publication date
CN113033394B (en) 2024-05-14

Similar Documents

Publication Publication Date Title
CN110503703B (en) Method and apparatus for generating image
CN109325532A (en) The image processing method of EDS extended data set under a kind of small sample
JP2020507850A (en) Method, apparatus, equipment, and storage medium for determining the shape of an object in an image
US20180204562A1 (en) Method and device for image recognition
CN111524166B (en) Video frame processing method and device
CN110517214B (en) Method and apparatus for generating image
WO2014187223A1 (en) Method and apparatus for identifying facial features
EP2420955A2 (en) Terminal device and method for augmented reality
CN108076384B (en) image processing method, device, equipment and medium based on virtual reality
US11908107B2 (en) Method and apparatus for presenting image for virtual reality device, device and non-transitory computer-readable storage medium
WO2019101005A1 (en) Pixel compensation method and apparatus, and terminal device
CN108351962B (en) Object detection with adaptive channel features
JP6811796B2 (en) Real-time overlay placement in video for augmented reality applications
US11127126B2 (en) Image processing method, image processing device, image processing system and medium
CN110516598B (en) Method and apparatus for generating image
JP2006073009A (en) Apparatus and method for histogram stretching
CN114298900A (en) Image super-resolution method and electronic equipment
CN111709428B (en) Method and device for identifying positions of key points in image, electronic equipment and medium
CN110363837B (en) Method and device for processing texture image in game, electronic equipment and storage medium
JP2011250013A (en) Image quality evaluation method, image quality evaluation apparatus, and program
WO2019239462A1 (en) Learning device, image generation device, learning method, image generation method, and program
CN113033394B (en) Image signature generation method and device, electronic equipment and storage medium
CN114237472B (en) Display method and device suitable for different LED display screens and LED display screen
CN116912387A (en) Texture map processing method and device, electronic equipment and storage medium
JP2015064761A (en) Matching processing apparatus and matching method

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