CN110851147A - Image replacement method, device and equipment - Google Patents

Image replacement method, device and equipment Download PDF

Info

Publication number
CN110851147A
CN110851147A CN201810956480.7A CN201810956480A CN110851147A CN 110851147 A CN110851147 A CN 110851147A CN 201810956480 A CN201810956480 A CN 201810956480A CN 110851147 A CN110851147 A CN 110851147A
Authority
CN
China
Prior art keywords
image
color
fonts
font
images
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
CN201810956480.7A
Other languages
Chinese (zh)
Other versions
CN110851147B (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.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201810956480.7A priority Critical patent/CN110851147B/en
Publication of CN110851147A publication Critical patent/CN110851147A/en
Application granted granted Critical
Publication of CN110851147B publication Critical patent/CN110851147B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Processing (AREA)

Abstract

The embodiment of the invention provides an image replacement method, a device and equipment, wherein the method comprises the following steps: and acquiring an image in an application program, and determining the number of the color types contained in the image according to the similarity between the color attributes of each pixel in the image. And if the number of the color types is less than or equal to the preset number, generating a font corresponding to the image, and finally replacing the image by the font corresponding to the image. Because each font and the image corresponding to the font all contain the identical image information, the quality of the image is not affected after replacement. Meanwhile, the storage space occupied by the fonts is smaller than that occupied by the images corresponding to the fonts, so that the effect of greatly reducing the size of the application program installation package while ensuring the image quality can be realized by replacing the images in the application program with the fonts corresponding to the images.

Description

Image replacement method, device and equipment
Technical Field
The present invention relates to the field of internet, and in particular, to an image replacement method, apparatus, and device.
Background
In order to meet daily requirements of users, users generally install various application programs (apps) in terminal devices such as smart phones, for example, some shopping apps, some entertainment apps, and the like.
Various apps often provide multiple functions in order to meet various requirements of users and improve user experience, and a lot of picture elements may be used for realizing the functions, generally speaking, the storage space occupied by pictures is often large, which also leads to that the data volume of App installation packages is very large, and a lot of storage space of terminal equipment will be occupied.
In the prior art, the size of an App installation package is reduced by reducing the size of each picture in the App. However, in this way, the "slimming" effect of the application installation package is not significant, and it is also likely that picture quality will be affected. Therefore, how to improve the 'slimming' effect of the application program installation package becomes a problem to be solved urgently.
Disclosure of Invention
In view of this, embodiments of the present invention provide an image replacement method, apparatus and device, which replace an image with a font corresponding to the image, so as to reduce the size of an application installation package while ensuring image quality.
In a first aspect, an embodiment of the present invention provides an image replacement method, including:
acquiring an image in an application program;
determining the number of the color types contained in the image according to the similarity among the color attributes of the pixels in the image;
if the number of the color types is less than or equal to a preset number, generating fonts corresponding to the images;
replacing the image with the generated font.
In a second aspect, an embodiment of the present invention provides an image replacement apparatus, including:
the acquisition module is used for acquiring images in the application program;
the similarity determining module is used for determining the number of the color types contained in the image according to the similarity among the color attributes of the pixels in the image;
the generating module is used for generating fonts corresponding to the images if the number of the color types is less than or equal to a preset number;
a replacement module to replace the image with the generated font.
In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, where the memory is used to store one or more computer instructions, and when the one or more computer instructions are executed by the processor, the image replacement method in the first aspect is implemented. The electronic device may also include a communication interface for communicating with other devices or a communication network.
In a fourth aspect, an embodiment of the present invention provides a computer storage medium for storing and storing a computer program, where the computer program is used to enable a computer to implement the picture replacement method in the first aspect when executed.
The image replacement method provided by the embodiment of the invention comprises the steps of firstly obtaining an image in an application program, and then determining the number of color types contained in the image according to the similarity between the color attributes of each pixel in the image. And if the number of the color types is less than or equal to the preset number, generating a font corresponding to the image, and finally replacing the image by the font corresponding to the image. After the image replacement, the font, the executable file, the configuration file and the like in the application program can be compressed, so that the application program installation package is generated. Because each font and the image corresponding to the font all contain the identical image information, the quality of the image is not affected after replacement. Meanwhile, the storage space occupied by the fonts is smaller than that occupied by the images corresponding to the fonts, so that the image in the application program is replaced by the fonts corresponding to the image, the image quality is ensured, and the size of the application program installation package is greatly reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a flowchart of an image replacement method according to an embodiment of the present invention;
FIG. 2 is a flow chart of another image replacement method according to an embodiment of the present invention;
FIG. 3 is a flow chart of another image replacement method according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of an image replacement apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device corresponding to the image replacing apparatus provided in the embodiment shown in fig. 4.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, and "a" and "an" generally include at least two, but do not exclude at least one, unless the context clearly dictates otherwise.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
The words "if," "if," as used herein may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a recognition," depending on the context. Similarly, the phrases "if determined" or "if identified (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when identified (a stated condition or event)" or "in response to an identification (a stated condition or event)", depending on the context.
It is also noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a good or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such good or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a commodity or system that includes the element.
In addition, the sequence of steps in each method embodiment described below is only an example and is not strictly limited.
Fig. 1 is a flowchart of an image replacement method according to an embodiment of the present invention, where the scene of an application installation package mentioned in the background art is accepted, and the image replacement method according to the embodiment of the present invention may be executed by a replacement device. As shown in fig. 1, the method comprises the steps of:
and S101, acquiring an image in the application program.
S102, determining the number of the color types contained in the image according to the similarity between the color attributes of the pixels in the image.
The application program may generally include executable files, configuration files, resource files, and the like, and the replacement device may obtain images to be replaced directly from the resource files. The acquired image may be a color image. The replacement device will then perform further processing on each image, and the processing for each image will be the same. Therefore, for the sake of brevity and clarity of description, the present embodiment and the following embodiments describe the image replacement process from the perspective of one image.
Specifically, after the replacement device acquires the image, the color attribute of each pixel in the image can be known. Wherein, optionally, the color attribute may comprise an RGBA color value or a gray value. And the replacement equipment respectively calculates the similarity between every two pixels in the image according to the color attributes, and determines that the two pixels with the similarity higher than the preset similarity belong to the same color, so that the number of the color types contained in the image is finally obtained.
When the color attribute comprises an RGBA color value, in an optional similarity calculation mode, the replacing device calculates the numerical difference between the R value, the G value, the B value and the transparency value of each two pixels in the image, that is, for any two pixels in the image, the replacing device calculates four numerical differences. If the four numerical differences are smaller than the preset value, the similarity of the two pixel points is high, and the two pixel points are determined to belong to the same color. For example, the preset value may be set to 0.25.
When the color attribute includes a grayscale value, since the color image is acquired in step 101, the replacement device also needs to perform grayscale conversion processing on the image after step 101 to convert the color image into a grayscale image. The gray scale conversion process is a mature image processing technology, and the detailed conversion process thereof is not described herein. After the gray conversion processing, the replacement device can acquire the gray value of each pixel in the gray image.
At this time, in another alternative similarity calculation manner, the replacement device calculates the numerical difference between the gray values of two pixels in the image respectively. If the numerical value difference of any two pixels is smaller than the preset value, the similarity of the two pixels is high, and the two pixels are determined to belong to the same color. For example, the preset value may be set to 0.25. It should be noted that the preset values involved in the two similarity calculation methods may also be set to different values.
S103, if the number of the color types is less than or equal to the preset number, generating a font corresponding to the image.
And S104, replacing the image with the generated font.
If the number of the color types contained in the image is less than or equal to the preset number, the color richness degree of the image is not high, and at the moment, the font corresponding to the image can be directly generated. And finally, replacing the image in the application program acquired in the step 101 with the generated font.
Alternatively, some image processing applications exist in the prior art that are dedicated to generating fonts corresponding to images from the images. The image replacement device is also integrated with a functional module capable of realizing the function, and the functional module can have the same working process with the image processing application programs. When the number of the color types of the image is less than or equal to the preset number, the replacement device can directly call the functional module to complete the step of generating the font corresponding to the image.
After the image replacement is completed, the executable file, the configuration file, and the font included in the application program may be further packaged, thereby generating an application program installation package. At this time, the generated application program installation package occupies a smaller storage space of the terminal device, that is, the effect of slimming the application program installation package is achieved. The above-described packing process may also be performed by a replacement device or other devices.
After the application installation package after being "slimmed" is installed on the terminal device, the terminal device responds to a display operation triggered by a user, and displays a font corresponding to the image. Since the generated font and image contain exactly the same image information, the font presented to the user has the same image quality as the image before replacement.
In practical applications, the replacement device in this embodiment and each of the following embodiments may be a server.
In the embodiment of the invention, the replacing device firstly acquires the image in the application program, and then determines the number of the color types contained in the image according to the similarity between the color attributes of each pixel in the image. And if the number of the color types is less than or equal to the preset number, generating a font corresponding to the image, and finally replacing the image by the font corresponding to the image. After the image replacement, the font, the executable file, the configuration file and the like in the application program can be compressed, so that the application program installation package is generated. Because each font and the image corresponding to the font all contain the identical image information, the quality of the image is not affected after replacement. Meanwhile, the storage space occupied by the fonts is smaller than that occupied by the images corresponding to the fonts, so that the image in the application program is replaced by the fonts corresponding to the image, the image quality is ensured, and the size of the application program installation package is greatly reduced.
In addition, in practical applications, in addition to the case of step 103, there may be a case where the number of color types is larger than the preset number. At this time, fig. 2 is a flowchart of another image replacement method according to an embodiment of the present invention, as shown in fig. 2, after step 102, the image replacement method may further include the following steps:
s201, if the number of the color types is larger than the preset number, generating a plurality of sub-images respectively corresponding to the image according to a plurality of colors contained in the image, wherein each sub-image contains a pixel of one color of the plurality of colors.
S202, a plurality of fonts corresponding to the plurality of sub-images, respectively, are generated.
S203, replacing the image with the generated plurality of fonts.
Specifically, if the number of the color types is greater than the preset number, it indicates that the color richness of the image is high, and at this time, if the font corresponding to the image is directly generated, the terminal device may possibly distort or even deform the image when displaying the directly generated font.
Therefore, when the number of the color types is greater than the preset number, optionally, the replacement device may first extract the pixels belonging to the same color in the image, and retain the positional relationship of the pixels belonging to the same color in the image to generate a sub-image. In this way, for an image with a rich color, a number of sub-images equal to the number of color types is generated. And generating fonts respectively corresponding to the sub-images according to the sub-images, and replacing the images with the generated fonts. For a generation process for generating a plurality of fonts, the detailed description can refer to the related description in step 103 of the above embodiment.
When the number of the color types is greater than the preset number, in another optional manner, the replacement device may further extract pixels corresponding to K colors from the image, and retain a positional relationship of the pixels in the image to generate a sub-image, where K is less than the preset number. In this case, a plurality of sub-images are generated, but the number of sub-images is smaller than the number of color types.
As can be seen from the above description, when the color richness of the image is high, the replacement of the image is essentially to replace one image with a plurality of fonts. Therefore, in order to ensure the "slimming" effect of the application installation package, optionally, before step 203, the image replacement method may further include:
s204, judging whether the storage space occupied by the plurality of fonts is smaller than the storage space occupied by the image, if so, executing the step 203, otherwise, executing the step S205.
And S205, reserving the image.
The replacement device determines whether a storage space occupied by a plurality of fonts corresponding to the image is smaller than a storage space occupied by the image. And if the storage space occupied by the plurality of fonts is smaller than the storage space occupied by the image, replacing the image with the plurality of fonts, thereby achieving the purpose of reducing the size of the application program installation package. If the storage space occupied by the plurality of fonts is larger than the storage space occupied by the image, the effect of slimming the application program installation package cannot be achieved by replacing the image with the plurality of fonts, at this moment, the generated fonts are discarded, and the image is reserved.
In the embodiment of the present invention, on the basis of the embodiment shown in fig. 1, for the case that the number of the color types is greater than the preset number, the replacement device generates a plurality of sub-images, and further generates a plurality of fonts corresponding to the plurality of sub-images, respectively. When the storage space occupied by the plurality of fonts is smaller than the storage space occupied by the image, the plurality of fonts are used for replacing the image, so that the slimming effect of the application program installation package is ensured.
By combining the two embodiments, the font generation of the images with different color richness degrees in different modes is realized. Meanwhile, the size of the storage space occupied by the fonts and the images is compared, whether the images are replaced or not is selected, and the purpose of ensuring the slimming effect of the application program installation package while not reducing the image quality is achieved.
Since images in an application tend to have multiple types, such as images with background colors and images without background colors. Whereas images capable of generating fonts are typically images without ground colour. Therefore, in order to enable different types of images to generate corresponding fonts and ensure the "slimming" effect of the application installation package, fig. 3 is a flowchart of another image replacement method provided by an embodiment of the present invention, as shown in fig. 3, where the method includes the following steps:
s301, acquiring an image in the application program.
The execution process of step 301 is similar to the corresponding steps in the foregoing embodiment, and reference may be made to the related description in the embodiment shown in fig. 1, which is not repeated herein.
S302, determining the number of pixels with the same RGBA color value according to the RGBA color value of each pixel in the image.
And S303, determining the RGBA color value with the largest number of pixels as a background color.
And S304, adjusting the transparency parameter of the pixel with the background color to be in a completely transparent state.
Specifically, the replacement device determines which pixels have the same RGBA color value from the RGBA color value of each pixel in the image, and counts the number of pixels having the same RGBA color value. Then, the RGBA color value having the largest number of pixels is determined as the background color of the image. Next, the transparency parameter of the pixel having the background color is adjusted to be in a completely transparent state, that is, the transparency value in the RGBA color value is adjusted to be 0. The process of adjusting the transparency parameter is to convert all the images obtained in step 301 into images without background color.
S305, adjusting the saturation of the pixels with the saturation lower than the preset value in the image to be the preset value.
Because the shooting environments of different images are different, the color of an object in the image is inevitably affected by the shooting environments, and chromatic aberration occurs. The replacement device also adjusts the saturation of each pixel in the image for the effect of color difference on the determination of the number of image color classes. That is, the saturation of the pixel having the saturation lower than the preset value is adjusted to the preset value. For example, the preset value may be set to 0.15.
S306, determining the number of the color types contained in the image according to the similarity between the color attributes of the pixels in the image.
S307, if the number of the color types is less than or equal to the preset number, generating a font corresponding to the image.
And S308, replacing the image with the generated font.
The execution process of the above steps 306 to 308 is similar to the corresponding steps of the foregoing embodiment, and reference may be made to the related description in the embodiment shown in fig. 1, which is not repeated herein.
In addition, in practical applications, the image obtained in step 301 may have different shapes, such as rectangle, square, etc., besides having different types. Since the generated font is required for the shape of the image, optionally, after step 301, it may also be determined whether the shape of the image matches the font graph corresponding to the font.
And if the shape of the image does not match with the font graph, adjusting the shape of the image to be the font graph corresponding to the font. Wherein the font graphic is generally square. Alternatively, when the shape of the image is a rectangle, the replacement device respectively counts the number of pixels M and N in each row and each column of the image. If M is larger than N, the edges along the two long sides of the image are filled up respectivelyAnd the row and transparency parameters are pixels in a full transparent state. If M is less than N, the edges of two long edges of the image are respectively filled up
Figure BDA0001772792550000092
Column, pixel with transparency parameter in full transparent state.
In the above-described flow, the shape of the image is adjusted first, and then the background color of the image is adjusted. However, these two adjustments do not have strict timing restrictions, and the order of the two adjustments may be reversed.
In the embodiment of the invention, the adjustment of the background color and the shape of the image can ensure that all the images can generate corresponding fonts. Meanwhile, the influence of the shooting environment on the image color can be avoided by adjusting the saturation of the pixels in the image, so that the replacement equipment can accurately determine the type and the number of the pixel colors contained in the image, and the image effect is ensured when the generated font is displayed.
In addition, the embodiments shown in fig. 1 to 3 are described by taking a scenario in which an application installation package is generated as an example. In practical application, the image replacement method can also be applied to a webpage browsing scene. All resource data, such as images, text, video, audio, and so on, may be stored in the server of the website. The aim of reducing the size of the resource data can also be achieved by replacing the image with the font. After the user triggers the webpage display operation, the terminal device may receive a data packet containing a font, which is sent by the server and corresponds to the webpage to be opened. Because the received data packet is smaller than the data packet containing the image, the terminal device can receive the smaller data packet at a higher speed, and the opening speed of the webpage is improved.
An image replacement apparatus according to one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these image substitution means can be constructed by configuring the steps taught in the present embodiment using commercially available hardware components.
Fig. 4 is a schematic structural diagram of an image replacement apparatus according to an embodiment of the present invention, and as shown in fig. 4, the apparatus includes: the device comprises an acquisition module 11, a similarity determination module 12, a generation module 13 and a replacement module 14.
And the acquisition module 11 is used for acquiring the image in the application program.
And a similarity determining module 12, configured to determine, according to a similarity between color attributes of each pixel in the image, a number of color types included in the image.
A generating module 13, configured to generate a font corresponding to the image if the number of the color types is less than or equal to a preset number.
A replacing module 14, configured to replace the image with the generated font.
Optionally, the generating module 13 is further configured to: if the number of the color types is larger than the preset number, generating a plurality of sub-images respectively corresponding to the image according to a plurality of colors contained in the image, wherein each sub-image contains a pixel of one color of the plurality of colors; and generating a plurality of fonts corresponding to the plurality of sub-images, respectively.
The replacing module 14 is further configured to replace the image with the generated plurality of fonts.
Optionally, the apparatus further comprises: a determining module 21, configured to determine whether a storage space occupied by the multiple fonts is smaller than a storage space occupied by the image.
Optionally, the apparatus further comprises: and the gray processing module 22 is used for performing gray conversion processing on the image.
Optionally, the apparatus further comprises: and a shape adjusting module 23, configured to adjust the shape of the image to the font graph if the shape of the image does not match the font graph corresponding to the font.
Optionally, the apparatus further comprises: a quantity determination module 24, a background color determination module 25, and a transparency adjustment module 26.
A quantity determining module 24, configured to determine, according to the RGBA color value of each pixel in the image, a quantity of pixels having the same RGBA color value.
And a background color determining module 25, configured to determine the RGBA color value with the largest number of pixels as a background color.
And a transparency adjusting module 26, configured to adjust a transparency parameter of the pixel with the background color to a completely transparent state.
Optionally, the apparatus further comprises: and a saturation adjusting module 27, configured to adjust the saturation of the pixel in the image, where the saturation is lower than a preset value, to the preset value.
The apparatus shown in fig. 4 can perform the method of the embodiment shown in fig. 1 to 3, and reference may be made to the related description of the embodiment shown in fig. 1 to 3 for a part not described in detail in this embodiment. The implementation process and technical effect of the technical solution refer to the descriptions in the embodiments shown in fig. 1 to fig. 3, and are not described herein again.
The internal functions and structures of the image replacement apparatus are described above, and in one possible design, the structure of the image replacement apparatus may be implemented as an electronic device, which may be a server storing all files in an application, as shown in fig. 5, and the electronic device may include: a processor 31 and a memory 32. Wherein the memory 32 is used for storing a program for supporting the electronic device to execute the image replacing method provided in the embodiments shown in fig. 1 to 3, and the processor 31 is configured to execute the program stored in the memory 32.
The program comprises one or more computer instructions which, when executed by the processor 31, are capable of performing the steps of:
acquiring an image in an application program;
determining the number of the color types contained in the image according to the similarity among the color attributes of the pixels in the image;
if the number of the color types is less than or equal to a preset number, generating fonts corresponding to the images;
replacing the image with the generated font.
Optionally, the processor 31 is further configured to perform all or part of the steps in the foregoing embodiments shown in fig. 1 to 3.
The electronic device may further include a communication interface 33 for communicating with other devices or a communication network.
In addition, an embodiment of the present invention provides a computer storage medium for storing computer software instructions for the electronic device, which includes a program for executing the image replacement method in the method embodiments shown in fig. 1 to 3.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course, can also be implemented by a combination of hardware and software. With this understanding in mind, the above-described aspects and portions of the present technology which contribute substantially or in part to the prior art may be embodied in the form of a computer program product, which may be embodied on one or more computer-usable storage media having computer-usable program code embodied therein, including without limitation disk storage, CD-ROM, optical storage, and the like.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. An image replacement method, comprising:
acquiring an image in an application program;
determining the number of the color types contained in the image according to the similarity among the color attributes of the pixels in the image;
if the number of the color types is less than or equal to a preset number, generating fonts corresponding to the images;
replacing the image with the generated font.
2. The method of claim 1, further comprising:
if the number of the color types is larger than the preset number, generating a plurality of sub-images respectively corresponding to the image according to a plurality of colors contained in the image, wherein each sub-image contains a pixel of one color of the plurality of colors;
generating a plurality of fonts corresponding to the plurality of sub-images respectively;
replacing the image with the generated plurality of fonts.
3. The method of claim 2, wherein prior to replacing the image with the generated plurality of fonts, the method further comprises:
judging whether the storage space occupied by the fonts is smaller than the storage space occupied by the image or not;
and if the storage space occupied by the plurality of fonts is smaller than the storage space occupied by the image, executing the step of generating the plurality of fonts to replace the image.
4. The method of claim 1, wherein the color attribute comprises an RGBA color value or a grayscale value.
5. The method of claim 4, wherein the color attribute comprises the grayscale value, and wherein after the obtaining the image in the application, the method further comprises:
and carrying out gray scale conversion processing on the image.
6. The method of any of claims 1-5, wherein after the obtaining the image in the application, the method further comprises:
and if the shape of the image is not matched with the font graph corresponding to the font, adjusting the shape of the image into the font graph.
7. The method of any of claims 1-5, wherein after the obtaining the image in the application, the method further comprises:
determining the number of pixels with the same RGBA color value according to the RGBA color value of each pixel in the image;
determining the RGBA color value with the largest number of pixels as a background color;
the transparency parameter of the pixel with the background color is adjusted to a fully transparent state.
8. The method of claim 7, further comprising:
and adjusting the saturation of the pixels with the saturation lower than a preset value in the image to be the preset value.
9. An image replacement apparatus characterized by comprising:
the acquisition module is used for acquiring images in the application program;
the similarity determining module is used for determining the number of the color types contained in the image according to the similarity among the color attributes of the pixels in the image;
the generating module is used for generating fonts corresponding to the images if the number of the color types is less than or equal to a preset number;
a replacement module to replace the image with the generated font.
10. An electronic device, comprising: a memory, a processor; wherein the content of the first and second substances,
the memory is to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the image replacement method of any of claims 1 to 8.
CN201810956480.7A 2018-08-21 2018-08-21 Image replacement method, device and equipment Active CN110851147B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810956480.7A CN110851147B (en) 2018-08-21 2018-08-21 Image replacement method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810956480.7A CN110851147B (en) 2018-08-21 2018-08-21 Image replacement method, device and equipment

Publications (2)

Publication Number Publication Date
CN110851147A true CN110851147A (en) 2020-02-28
CN110851147B CN110851147B (en) 2022-11-01

Family

ID=69595254

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810956480.7A Active CN110851147B (en) 2018-08-21 2018-08-21 Image replacement method, device and equipment

Country Status (1)

Country Link
CN (1) CN110851147B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112188304A (en) * 2020-09-28 2021-01-05 广州酷狗计算机科技有限公司 Video generation method, device, terminal and storage medium
CN113158977A (en) * 2021-05-12 2021-07-23 河南师范大学 Image character editing method for improving FANnet generation network
CN113608740A (en) * 2021-08-09 2021-11-05 车主邦(北京)科技有限公司 Icon replacement method, device and equipment and readable storage medium
CN117409397A (en) * 2023-12-15 2024-01-16 河北远东通信系统工程有限公司 Real-time portrait comparison method, device and system based on position probability

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013049736A1 (en) * 2011-09-30 2013-04-04 Bhardwaj Anurag Image feature data extraction and use
CN105138355A (en) * 2015-08-10 2015-12-09 北京金山安全软件有限公司 Method and device for inserting elements in interface of application program and electronic equipment
CN106055295A (en) * 2016-05-24 2016-10-26 腾讯科技(深圳)有限公司 Picture processing method and device, and picture drawing method and device
CN106681735A (en) * 2016-12-30 2017-05-17 迈普通信技术股份有限公司 Method, device and apparatus for generating dynamic icons based fonts

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013049736A1 (en) * 2011-09-30 2013-04-04 Bhardwaj Anurag Image feature data extraction and use
CN105138355A (en) * 2015-08-10 2015-12-09 北京金山安全软件有限公司 Method and device for inserting elements in interface of application program and electronic equipment
CN106055295A (en) * 2016-05-24 2016-10-26 腾讯科技(深圳)有限公司 Picture processing method and device, and picture drawing method and device
CN106681735A (en) * 2016-12-30 2017-05-17 迈普通信技术股份有限公司 Method, device and apparatus for generating dynamic icons based fonts

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112188304A (en) * 2020-09-28 2021-01-05 广州酷狗计算机科技有限公司 Video generation method, device, terminal and storage medium
CN112188304B (en) * 2020-09-28 2022-11-15 广州酷狗计算机科技有限公司 Video generation method, device, terminal and storage medium
CN113158977A (en) * 2021-05-12 2021-07-23 河南师范大学 Image character editing method for improving FANnet generation network
CN113158977B (en) * 2021-05-12 2022-07-29 河南师范大学 Image character editing method for improving FANnet generation network
CN113608740A (en) * 2021-08-09 2021-11-05 车主邦(北京)科技有限公司 Icon replacement method, device and equipment and readable storage medium
CN117409397A (en) * 2023-12-15 2024-01-16 河北远东通信系统工程有限公司 Real-time portrait comparison method, device and system based on position probability
CN117409397B (en) * 2023-12-15 2024-04-09 河北远东通信系统工程有限公司 Real-time portrait comparison method, device and system based on position probability

Also Published As

Publication number Publication date
CN110851147B (en) 2022-11-01

Similar Documents

Publication Publication Date Title
CN110851147B (en) Image replacement method, device and equipment
CN107015788B (en) Method and device for displaying images on mobile device in animation mode
US20210390657A1 (en) Media content management for a fixed orientation display
EP3467679B1 (en) Data processing method and device
CN108021671B (en) Page transparent processing method and device
CN110908762B (en) Dynamic wallpaper implementation method and device
US20150110419A1 (en) Method and device for image processing
US20180018018A1 (en) Foveated rendering
WO2020063030A1 (en) Theme color adjusting method and apparatus, storage medium, and electronic device
EP2874054A1 (en) Application text adjusting method, device, and terminal
US20210271383A1 (en) Picture displaying method, electronic device and storage medium
US10043298B2 (en) Enhanced document readability on devices
CN113538502A (en) Picture clipping method and device, electronic equipment and storage medium
US10311060B2 (en) Glyph management in texture atlases
CN105389308B (en) Webpage display processing method and device
CN106547792B (en) Picture sharing method and device
CN112527424A (en) Control method and device for popup window
CN103914223A (en) Terminal application interface generation method and device
US20120070080A1 (en) Color correction for digital images
CN110968810A (en) Webpage data processing method and device
CN114666621A (en) Page processing method, device and equipment
CN114416089A (en) Page display method and device, mobile terminal and storage medium
CN114466228A (en) Method, equipment and storage medium for improving screen projection display fluency
CN108376161B (en) Method, device, terminal and storage medium for displaying webpage
CN107608947B (en) HTML file processing method and device and electronic equipment

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