Disclosure of Invention
In view of the foregoing, it is desirable to provide an image processing method, apparatus, computer device, and storage medium.
An image processing method, the method comprising:
acquiring an original image and a background image to be displayed in a first image format;
overlapping the original image to be displayed on the background image to obtain a composite image;
Generating an image without an alpha channel according to RGB values of an image area corresponding to the original image to be displayed on the composite image;
The method comprises the steps of taking an image without an alpha channel as a target image to be displayed of target equipment, wherein the target equipment is equipment for storing the target image to be displayed in a second image format, and the number of color bits of the second image format is smaller than that of the first image format.
In one embodiment, the generating an image without an alpha channel according to RGB values of an image area corresponding to the original image to be displayed on the composite image includes:
acquiring RGB values of an image area corresponding to the original image to be displayed on the composite image to obtain an RGB bitmap;
The RGB bitmap is encoded into the image without alpha channel.
In one embodiment, the first image format is ARGB8888 and the second image format is ARGB1555.
In one embodiment, the original image to be displayed includes a png image with a background color that is fully transparent.
In one embodiment, after the image without the alpha channel is taken as the target image to be displayed of the target device, the method further includes:
And the target equipment is used for receiving and storing the target image to be displayed in the second image format.
In one embodiment, the target device is further configured to superimpose the target image to be displayed in the second image format with the background image in the second image format to obtain a composite image to be displayed, and display the composite image to be displayed in a third image format, where the third image format is a first image format without an alpha channel bit.
In one embodiment, the target device comprises an embedded device.
An image processing apparatus, the apparatus comprising:
the image acquisition module is used for acquiring an original image and a background image to be displayed in a first image format;
the image superposition module is used for superposing the original image to be displayed on the background image to obtain a composite image;
The image generation module is used for superposing the original image to be displayed on the background image to obtain a composite image;
The image obtaining module is used for taking the image without the alpha channel as a target image to be displayed of target equipment, wherein the target equipment is equipment for storing the target image to be displayed in a second image format, and the number of color bits of the second image format is smaller than that of the first image format.
A computer device comprising a memory storing a computer program and a processor which when executing the computer program performs the steps of:
the method comprises the steps of obtaining an original image to be displayed and a background image in a first image format, superposing the original image to be displayed on the background image to obtain a composite image, generating an image without an alpha channel according to RGB values of an image area corresponding to the original image to be displayed on the composite image, taking the image without the alpha channel as a target image to be displayed of target equipment, wherein the target equipment is equipment for storing the target image to be displayed in a second image format, and the color number of the second image format is smaller than that of the first image format.
A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
the method comprises the steps of obtaining an original image to be displayed and a background image in a first image format, superposing the original image to be displayed on the background image to obtain a composite image, generating an image without an alpha channel according to RGB values of an image area corresponding to the original image to be displayed on the composite image, taking the image without the alpha channel as a target image to be displayed of target equipment, wherein the target equipment is equipment for storing the target image to be displayed in a second image format, and the color number of the second image format is smaller than that of the first image format.
The image processing method, the device, the computer equipment and the storage medium acquire the original image and the background image to be displayed in the first image format, superimpose the original image to be displayed on the background image to obtain the composite image, generate the image without the alpha channel according to the RGB value of the image area corresponding to the original image to be displayed on the composite image, and take the image without the alpha channel as the target image to be displayed of the target equipment, wherein the target equipment is equipment for storing the target image to be displayed in the second image format, and the color number of the second image format is smaller than that of the first image format. According to the scheme, the original image to be displayed and the background image in the first image format with higher color bit number are obtained, the original image to be displayed which is used as a foreground is overlapped on the background image to obtain the overlapped composite image, RGB values of an image area corresponding to the original image to be displayed on the composite image are obtained, an image without an alpha channel is generated according to the RGB values, the image without the alpha channel is used as a target image to be displayed of target equipment to be stored and displayed in a second image format with lower color bit number, the target equipment can obtain and display the target image to be displayed with the alpha channel removed through the processing, and the image display effect is improved.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The image processing method provided by the application can be applied to the application scene shown in fig. 1, wherein the application scene can comprise the image processing device 110 and the target device 120, and the image processing device 110 and the target device 120 can be in communication connection. Specifically, the image processing device 110 obtains an original image to be displayed and a background image in a first image format, superimposes the original image to be displayed on the background image to obtain a composite image, then the image processing device 110 generates an image without an alpha channel according to RGB values of an image area corresponding to the original image to be displayed on the composite image, then the image processing device 110 uses the image without the alpha channel as a target image to be displayed of the target device 120, the image processing device 110 may send the target image to be displayed to the target device 120, and the target device 120 receives the target image to be displayed sent by the image processing device 110 and stores the target image to be displayed in a second image format, wherein the color number of the second image format is smaller than that of the first image format. Among them, the image processing device 110 may be, but not limited to, various personal computers, notebook computers, servers, and the target device 120 may be, but not limited to, an embedded device.
In one embodiment, as shown in fig. 2, an image processing method is provided, and the method is described as being applied to the image processing apparatus 110 as shown in fig. 1, and the method may include the steps of:
step S201, an original image and a background image to be displayed in a first image format are acquired.
The original image to be displayed refers to an image which is originally required to be directly displayed by the target device 120 but is not subjected to image processing provided by the image processing device 110, for example, a certain icon image in png format with a background color of full transparency, and the background image refers to an image for synthesizing the original image to be displayed as a background, for example, a solid black image. The first image format refers to an image format that has a number of color bits that is greater than the second image format, for example, the first image format may be ARGB8888 and the second image format may be ARGB1555.
Specifically, before the image processing device 110 is required to perform image processing on an original image to be displayed, the image processing device 110 may acquire the original image to be displayed and a background image in the first image format, so that the image processing device 110 may perform subsequent image processing according to the original image to be displayed and the background image.
Step S202, the original image to be displayed is superimposed on the background image, and a composite image is obtained.
In this step, the composite image refers to a superimposed image obtained by superimposing each pixel of the original image to be displayed as a foreground onto a corresponding pixel of the background image as a background. For example, the image processing apparatus 110 may superimpose and synthesize an icon image in png format with a background color of full transparency with a solid black image to obtain a synthesized image composed of the black background and the icon.
Step S203, according to RGB values of the corresponding image areas of the original image to be displayed on the synthesized image, an image without an alpha channel is generated.
Before step S203, the image processing apparatus 110 may superimpose the original image to be displayed as the foreground on the background image to obtain a superimposed composite image, so that the image processing apparatus 110 may further acquire RGB values of an image area corresponding to the original image to be displayed as the foreground on the composite image.
Specifically, the RGB values in the image area corresponding to the composite image refer to the RGB values of the area or the position of the original image to be displayed on the composite image, such as RGB888 (128,128,128). And an image without alpha channel refers to an image without transparency such as png image in RGB888 format.
In this step, after the original image to be displayed as the foreground is superimposed with the background image as the background, the image processing apparatus 110 acquires RGB values of the region or the position where the original image to be displayed is located on the composite image, and generates an image without an alpha channel according to the RGB values.
And step S204, taking the image without the alpha channel as a target image to be displayed of the target device.
The target device is a device for storing a target image to be displayed in a second image format, wherein the number of color bits of the second image format is smaller than that of the first image format, for example, the target device is an embedded device for storing images in an image format of ARGB 1555.
Specifically, the image processing device 110 uses the image without the alpha channel as the target image to be displayed of the target device, and stores and displays the target image in the second image format with a lower color bit number, so that the target device can obtain and display the target image to be displayed with the alpha channel removed through the above processing, and the image display effect of the target device is improved.
In the image processing method, an original image to be displayed and a background image in a first image format are obtained, the original image to be displayed is overlapped on the background image to obtain a composite image, an image without an alpha channel is generated according to RGB values of an image area corresponding to the original image to be displayed on the composite image, the image without the alpha channel is used as a target image to be displayed of target equipment, wherein the target equipment is equipment for storing the target image to be displayed in a second image format, and the color number of the second image format is smaller than that of the first image format. According to the scheme, the original image to be displayed and the background image in the first image format with higher color bit number are obtained, the original image to be displayed which is used as a foreground is overlapped on the background image to obtain the overlapped composite image, RGB values of an image area corresponding to the original image to be displayed on the composite image are obtained, an image without an alpha channel is generated according to the RGB values, the image without the alpha channel is used as a target image to be displayed of target equipment to be stored and displayed in a second image format with lower color bit number, the target equipment can obtain and display the target image to be displayed with the alpha channel removed through the processing, and the image display effect is improved.
In one embodiment, the generating an image without an alpha channel in step S203 according to the RGB values of the image area corresponding to the original image to be displayed on the composite image includes obtaining the RGB values of the image area corresponding to the original image to be displayed on the composite image, obtaining an RGB bitmap, and encoding the RGB bitmap into the image without an alpha channel.
In this embodiment, the RGB bitmap refers to an uncompressed RGB bitmap obtained according to RGB values of an area or a position where an original image to be displayed on a composite image, such as an RGB bitmap of an icon image in an uncompressed BMP format. Specifically, after the original image to be displayed as the foreground is superimposed with the background image as the background, the image processing apparatus 110 obtains RGB values of the region or the position where the original image to be displayed is located on the composite image, obtains an uncompressed RGB bitmap according to the RGB values, and then encodes the uncompressed RGB bitmap into an image without an alpha channel.
According to the technical scheme, the RGB values of the region or the position of the original image to be displayed on the composite image can be accurately recorded through the RGB bitmap, so that the image without the alpha channel obtained through encoding according to the RGB bitmap can accurately record the image information of the original image to be displayed, and the target device can be better in image display effect when the target device displays the target image to be displayed with the alpha channel removed through the processing.
In one example of an application, the first image format may be ARGB8888 and the second image format may be ARGB1555.
Specifically, the image processing device 110 obtains an original image to be displayed and a background image in the format of ARGB8888, superimposes the original image to be displayed on the background image to obtain a composite image, generates an image without an alpha channel according to the RGB value of an image area corresponding to the original image to be displayed on the composite image, and uses the image without the alpha channel as a target image to be displayed of the target device 120, so that the target device 120 can store the target image to be displayed in the format of ARGB 1555.
Further, in some embodiments, the image processing apparatus 110 may acquire a png image with a background color of full transparency and a background image in the ARGB8888 format, and the png image with a background color of full transparency may be an image as shown in fig. 3, for example. Then, the image processing apparatus 110 superimposes the png image with the background color being fully transparent on the background image to obtain a composite image, and then the image processing apparatus 110 generates an image without an alpha channel according to RGB values of an image area corresponding to the png image with the background color being fully transparent on the composite image, and the image processing apparatus 110 uses the image without an alpha channel as a target image to be displayed of the target apparatus 120, so that the target apparatus 120 can store the apparatus for the target image to be displayed in an ARGB1555 format.
Fig. 4, 5 (a) and 5 (b) are image display effect contrast charts of the target device. Fig. 4 is an image processed and displayed by a target device (with an ARGB1555 frame buffer) after being processed by the method of the present application, fig. 5 (a) is an image processed and displayed by a target device (with an ARGB1555 frame buffer) directly without being processed by the method of the present application, and fig. 5 (b) is an image processed and displayed by a device (with an frame buffer) of a higher configuration directly. Specifically, fig. 5 (a) shows an image display effect of the target device 120 storing and displaying images in the format of ARGB1555, which has a poor image display effect and a relatively serious jaggy phenomenon, and fig. 5 (b) shows an image display effect of a device of a relatively high configuration storing and displaying images in the format of ARGB8888, which has a good image display effect and does not have a relatively serious jaggy phenomenon.
Therefore, the image display effect corresponding to the method is basically consistent with the image display effect which is directly processed and displayed by the equipment with higher configuration, the display effect is better, the serious saw tooth phenomenon does not occur, and the image display effect is obviously better than the effect which is directly processed and displayed by the target equipment without being processed by the method. The key of this embodiment is that in the conversion process from ARGB8888 to ARGB1555, the Alpha channel is converted from 8bit to 1bit, and the precision loss is far greater than R, G, B channels (from 8bit to 5 bit), so that the value of the RGB channel is calculated in advance to replace the Alpha channel, so that the display effect can be improved.
In one embodiment, after the image without the alpha channel is taken as the target image to be displayed of the target device in the step S204, the method further comprises the step of sending the target image to be displayed to the target device.
The target image to be displayed refers to an image without an alpha channel, which is stored and displayed by the target device 120 in a second image format with a lower color number after being subjected to image processing by the image processing device 110, and the target device refers to a device which can be used for receiving and storing the target image to be displayed in the second image format, and the target device can be an embedded device which stores the image in the image format of the ARGB 1555.
Specifically, the image processing apparatus 110 sends the target image to be displayed without the alpha channel after the image processing performed by the image processing apparatus 110 to the target apparatus 120, and the target apparatus 120 receives the target image to be displayed sent by the image processing apparatus 110 and stores and displays the target image to be displayed in a second image format with a lower color number, such as the ARGB 1555. According to the technical scheme of the embodiment, the target device 120 can receive the target image to be displayed without the alpha channel after the image processing by the image processing device 110, so that the target device 120 can have a better display effect based on the target image to be displayed without the alpha channel.
In one embodiment, the target device is further configured to superimpose the target image to be displayed in the second image format with the background image in the second image format to obtain a composite image to be displayed and display the composite image to be displayed in the third image format.
The third image format refers to the first image format without alpha channel bits, and if the first image format is ARGB8888, the third image format is RGB 888.
Specifically, after the target device 120 receives the target image to be displayed, from which the alpha channel is removed, processed by the image processing device 110, and stores the target image in the second image format with a lower color number, for example, the ARGB1555, the target device 120 superimposes each pixel of the target image to be displayed, from which the alpha channel is removed, stored in the second image format with a lower color number, for example, the ARGB1555, as a foreground, onto a corresponding pixel of a background image in the second image format, for example, as a background, to obtain a superimposed composite image to be displayed, and displays the composite image to be displayed in the third image format, for example, RGB 888.
According to the technical scheme of the embodiment, the target device 120 can process and display the target image to be displayed after receiving the target image to be displayed after the image processing by the image processing device 110, so that the target device 120 can display the target image to be displayed and present a better image display effect.
It should be understood that, although the steps in the flowcharts are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least a portion of the steps in the flowcharts above may include a plurality of steps or stages that are not necessarily performed at the same time, but may be performed at different times, and the order of execution of the steps or stages is not necessarily sequential, but may be performed in rotation or alternately with at least a portion of the steps or stages in other steps or other steps.
In one embodiment, as shown in fig. 6, an image processing apparatus is provided, the apparatus 600 may include:
an image obtaining module 601, configured to obtain an original image and a background image to be displayed in a first image format;
The image superimposing module 602 is configured to superimpose the original image to be displayed on the background image to obtain a composite image;
An image generating module 603, configured to generate an image without an alpha channel according to RGB values of an image area corresponding to the original image to be displayed on the composite image;
the image obtaining module 604 is configured to take the image without the alpha channel as a target image to be displayed of a target device, where the target device is a device that stores the target image to be displayed in a second image format, and the number of color bits of the second image format is smaller than the number of color bits of the first image format.
In one embodiment, the image generating module 603 is configured to obtain RGB values of an image area corresponding to the original image to be displayed on the composite image, obtain an RGB bitmap, and encode the RGB bitmap into the image without the alpha channel.
In one embodiment, the first image format is ARGB8888 and the second image format is ARGB1555.
In one embodiment, the original image to be displayed comprises a png image with a background color that is fully transparent.
In one embodiment, the apparatus 600 further includes an image sending module configured to send the target image to be displayed to the target device, and the target device is configured to receive and store the target image to be displayed in the second image format.
In one embodiment, the target device is further configured to superimpose the target image to be displayed in the second image format with the background image in the second image format to obtain a composite image to be displayed and display the composite image to be displayed in a third image format, where the third image format is a first image format without an alpha channel bit.
In one embodiment, the target device comprises an embedded device.
For specific limitations of the image processing apparatus, reference may be made to the above limitations of the image processing method, and no further description is given here. The respective modules in the above-described image processing apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a terminal, and the internal structure of which may be as shown in fig. 7. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement an image processing method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be keys, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in FIG. 7 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, or the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.