CN110047043B - Background image processing method, background image processing device, computer equipment and storage medium - Google Patents
Background image processing method, background image processing device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN110047043B CN110047043B CN201910200336.5A CN201910200336A CN110047043B CN 110047043 B CN110047043 B CN 110047043B CN 201910200336 A CN201910200336 A CN 201910200336A CN 110047043 B CN110047043 B CN 110047043B
- Authority
- CN
- China
- Prior art keywords
- background image
- size
- matched
- image
- screen
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 27
- 238000012545 processing Methods 0.000 title claims abstract description 13
- 238000000034 method Methods 0.000 claims abstract description 14
- 238000000605 extraction Methods 0.000 claims description 17
- 238000006243 chemical reaction Methods 0.000 claims description 16
- 238000010606 normalization Methods 0.000 claims description 11
- 230000007704 transition Effects 0.000 claims description 10
- 239000003086 colorant Substances 0.000 claims description 4
- 239000000284 extract Substances 0.000 claims description 4
- 238000013461 design Methods 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 7
- 230000008569 process Effects 0.000 description 7
- 230000008901 benefit Effects 0.000 description 4
- 239000011159 matrix material Substances 0.000 description 4
- 230000000694 effects Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 230000006835 compression Effects 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000001788 irregular Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 230000001052 transient effect Effects 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/40—Scaling of whole images or parts thereof, e.g. expanding or contracting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/149—Segmentation; Edge detection involving deformable models, e.g. active contour models
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Processing (AREA)
- Image Analysis (AREA)
Abstract
The application relates to the technical field of webpage design, in particular to a background image processing method, a background image processing device, computer equipment and a storage medium, wherein the background image processing method comprises the following steps: acquiring a screen size and a background image size, judging whether the background image size is matched with the screen size, if so, not adjusting the background image, otherwise, adjusting the size of the background image to match the background image size with the screen size; traversing the matched background image, extracting the pixel value of each pixel point in the matched background image, and counting to obtain the pixel value which accounts for the most in the matched background image; and acquiring the contour of the matched background image, and filling the pixel value with the largest proportion to the outer edge of the contour of the matched background image to obtain a processed background image. The method and the device solve the problem that the attractiveness is reduced due to stretching deformation of the background image.
Description
Technical Field
The present application relates to the field of web page design technologies, and in particular, to a background image processing method and apparatus, a computer device, and a storage medium.
Background
With the development of terminal and software technology, the full-screen technology is gradually applied to electronic terminals such as mobile phones, notebooks, flat panels, televisions, computers and the like. When using these electronic terminals, users usually prefer to set the display desktop background of the electronic terminal to a favorite picture. This picture selected as the desktop background is called wallpaper.
Due to different proportional sizes of different mobile devices, when the same background image is used, the problems of partial image area occlusion, compression, stretching and the like exist, so that the visual effect is poor.
In addition, when a user sets a picture as wallpaper, the picture cannot highly restore the original image quality and display effect of the wallpaper due to the stretching problem, and the later use of the picture is seriously influenced.
Disclosure of Invention
Based on this, it is necessary to provide a background image processing method, an apparatus, a computer device and a storage medium for solving the problem that the display effect of the same background picture is poor in mobile terminals with different sizes.
A background image processing method comprises the following steps:
acquiring a screen size and a background image size, judging whether the background image size is matched with the screen size, if so, not adjusting the background image, otherwise, adjusting the size of the background image to enable the background image size to be matched with the screen size;
traversing the matched background image, extracting the pixel value of each pixel point in the matched background image, and counting to obtain the pixel value with the largest proportion in the matched background image;
and acquiring the contour of the matched background image, and filling the pixel value with the largest proportion to the outer edge of the contour of the matched background image to obtain a processed background image.
In one possible embodiment, the obtaining the screen size and the background image size, determining whether the background image size matches the screen size, if so, not adjusting the background image, otherwise, adjusting the size of the background image to match the background image size with the screen size includes:
emitting a light beam to the screen, receiving a reflection signal of the screen to the light beam, and determining the screen size of the screen according to the reflection signal;
obtaining a background image, dividing the background image into a plurality of sub-blocks, extracting pixel points of the sub-blocks, calculating pixel gradients of the sub-blocks according to the extracted pixel points of the sub-blocks, and determining the image size of the background image according to the pixel gradients of the sub-blocks;
after the unit normalization is carried out on the screen size and the image size, if the difference value of the image size and the screen size is within a preset error threshold value, the background image is matched with the screen;
otherwise, if the size of the background image is smaller than the size of the screen, the background image is enlarged in equal proportion to enable the transverse or longitudinal size of the background image to be consistent with the size of the screen; and if the size of the background image is larger than the size of the screen, reducing the background image in an equal proportion to enable the transverse or longitudinal size of the background image to be consistent with the size of the screen.
In one possible embodiment, the traversing the matched background image, extracting a pixel value of each pixel point in the matched background image, and obtaining a pixel value with the largest proportion in the matched background image after statistics, includes:
acquiring a matched background image, performing format conversion on the matched background image, and dividing the background image after format conversion into a plurality of image sub-blocks;
acquiring pixel values of the image sub-blocks;
summarizing the pixel values of the image subblocks and establishing a pixel value histogram, wherein the abscissa of the pixel value histogram is the image subblock number, and the ordinate is the pixel value;
and extracting the pixel value with the largest pixel value ratio from the histogram.
In one possible embodiment, the obtaining the contour of the matched background image, and filling the most significant pixel value into the outer edge of the contour of the matched background image to obtain a processed background image includes:
acquiring an approximate central point of the matched background image, performing pixel point scanning on the edge of the matched background image by taking the approximate central point of the matched background image as a starting point, and summarizing scanning results to obtain an image outline of the matched background image;
acquiring pixel values of the image contour, performing difference between the pixel values with the highest ratio and the pixel values of the image contour, and determining the position of the pixel values with the highest ratio on the screen according to the difference;
and acquiring a pixel difference value of the pixel value with the largest proportion and the uncovered area of the matched background image on the screen, acquiring a color transition gradient according to the pixel difference value, and filling colors in the uncovered area according to the color transition gradient to obtain the processed background image.
In one possible embodiment, the emitting the light beam to the screen, receiving a reflection signal of the screen to the light beam, and determining the screen size of the screen according to the reflection signal includes:
acquiring a preset emission angle range of the emission beam, and emitting the emission beam to the screen according to the emission angle range;
acquiring reflected light of the screen to the light beam, and recording the reflection angle and the reflection light intensity of the reflected light to form a reflected light recording table;
acquiring reflection intensity values of two adjacent reflection angles from the reflection light ray record table, if the difference value of the reflection intensity values of the two adjacent reflection angles is larger than a preset difference threshold value, taking the position of the screen corresponding to the reflection angle with the large reflection intensity value as the edge of the screen, and otherwise, excluding the two reflection angles;
and summarizing the screen positions corresponding to all the reflection angles larger than the difference threshold value to obtain the size of the screen.
In one possible embodiment, the obtaining the matched background image, performing format conversion on the matched background image, and dividing the background image after format conversion into a plurality of image sub-blocks includes:
acquiring the format name of the matched background image, and performing format normalization processing on the background images with different formats by using an image format conversion tool;
dividing the background image after format normalization into a plurality of original image sub-blocks with equal size, acquiring a preset region pixel extraction threshold, and extracting the original image sub-blocks larger than the region pixel extraction threshold to obtain final image sub-blocks;
and splicing the original sub-blocks smaller than the region pixel extraction threshold value to obtain new image sub-blocks, wherein if the pixel values of the new image sub-blocks are larger than the region pixel extraction threshold value, the new image sub-blocks are the final image sub-blocks, and otherwise, continuing splicing.
In one possible embodiment, the obtaining the approximate center point of the matched background image, taking the approximate center point of the matched background image as a starting point, performing pixel point scanning on the edge of the matched background image, and summarizing the scanning result to obtain the image contour of the matched background image includes:
acquiring an approximate central point of the matched background image, taking n points on an expected contour line of the matched background image, and dividing the contour line of the background image into n parts, wherein an included angle between a connecting line of two adjacent points and the approximate central point is 360/n degrees, and n is an integer greater than or equal to 4;
taking any point on the expected contour line as an initial end point, respectively connecting the point with the rest points to obtain a plurality of line segments, and taking the line segment with the largest length value as a local long axis of the matched background image;
comparing the lengths of the local long axes, and extracting the local long axis with the longest length as the image long axis of the matched background image;
dividing the matched background image into a left part and a right part through the image long axis of the matched background image, sequentially scanning pixel points on the expected contour line by line in the range of two end points of the image long axis of the matched background image, and respectively obtaining a left short axis and a right short axis which are farthest away from the image long axis of the matched background image on the left part and the right part of the matched background image;
and taking the length of the long axis of the image, the length of the left short axis, the length of the right short axis, the distance between the left short axis and the right short axis and the absolute value of the difference between the lengths of the left short axis and the right short axis as the size value of the matched background image, and obtaining the image contour of the matched background image according to the size value.
A background image processing apparatus includes the following modules:
the size matching module is set to obtain the size of a screen and the size of a background image, judge whether the size of the background image is matched with the size of the screen, if so, not adjust the size of the background image, otherwise, adjust the size of the background image to match the size of the background image with the size of the screen;
the pixel establishing module is set to traverse the matched background image, extract the pixel value of each pixel point in the matched background image and obtain the pixel value with the largest proportion in the matched background image after statistics;
and the image filling module is used for acquiring the outline of the matched background image and filling the pixel value with the largest proportion to the outer edge of the outline of the matched background image to obtain a processed background image.
A computer device comprising a memory and a processor, the memory having stored therein computer readable instructions which, when executed by the processor, cause the processor to perform the steps of the background image processing method described above.
A storage medium having computer-readable instructions stored thereon which, when executed by one or more processors, cause the one or more processors to perform the steps of the background image processing method described above.
Compared with the existing mechanism, the method and the device have the advantages that the pixels of the background image are collected and then filled into the screen area covered by the original background image, so that the background image is in natural transition, and the problem of reduction of attractiveness caused by stretching deformation of the background image is solved. Further, by acquiring the pixel value occupying the largest proportion in the background image, it is possible to know which color the dominant color of the background image is, and thus, a transitional unnatural phenomenon does not occur at the time of filling.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the application.
FIG. 1 is a flowchart illustrating an overall background image processing method according to an embodiment of the present application;
fig. 2 is a schematic diagram illustrating a route establishment process in a background image processing method according to an embodiment of the present application;
FIG. 3 is a schematic diagram illustrating a process of generating a layout chart in a background image processing method according to an embodiment of the present application;
fig. 4 is a schematic diagram illustrating a region dividing process in a background image processing method according to an embodiment of the present application;
fig. 5 is a block diagram of a background image processing apparatus according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
Fig. 1 is an overall flowchart of a background image processing method in an embodiment of the present application, and as shown in fig. 1, the background image processing method includes the following steps:
s1, obtaining a screen size and a background image size, judging whether the background image size is matched with the screen size, if so, not adjusting the background image, otherwise, adjusting the size of the background image to match the background image size with the screen size;
specifically, the matching of the screen size and the size of the background image means that any one of the length or the width of the background image is consistent with the length or the width of the screen; in the size adjustment, the length or width of the background image may be adjusted by means of enlarging or reducing the background image.
S2, traversing the matched background image, extracting the pixel value of each pixel point in the matched background image, and counting to obtain the pixel value with the largest proportion in the matched background image;
specifically, when traversing the matched background image, a coordinate system may be established on the background image, an origin of the coordinate system is an end point of a lower left corner of the background image, and the traversal of the pixel points is started from the origin along a horizontal axis or a longitudinal axis of the coordinate system.
And S3, acquiring the contour of the matched background image, and filling the pixel value with the largest proportion to the outer edge of the contour of the matched background image to obtain a processed background image.
Specifically, when filling the most significant pixel value to the outer edge of the background image contour, the specific position of the pixel value at the outer edge of the background image contour needs to be determined first, so that the processed background image can be naturally tiled on the screen. In determining the specific location of the most significant pixel value, the pixel gradient value is typically used for the determination.
In the embodiment, the pixels of the background image are collected and then filled in the uncovered screen area of the original background image, so that the background image is transited naturally, and the problem of reduced attractiveness caused by stretching deformation of the background image is solved.
Fig. 2 is a schematic diagram of a route establishment process in a background image processing method in an embodiment of the present application, where as shown in the drawing, the step S1 of obtaining a screen size and a background image size, determining whether the background image size matches the screen size, if yes, not adjusting the background image, otherwise, adjusting the background image size to match the background image size with the screen size includes:
s101, emitting a light beam to the screen, receiving a reflection signal of the screen to the light beam, and determining the screen size of the screen according to the reflection signal;
in particular, the transmitted beam may be visible or infrared, but the emitted beam must be a single wavelength beam to prevent interference of beams of different frequencies.
S102, obtaining a background image, dividing the background image into a plurality of sub-blocks, extracting pixel points of the sub-blocks, calculating pixel gradients of the sub-blocks according to the extracted pixel points of the sub-blocks, and determining the image size of the background image according to the pixel gradients of the sub-blocks;
specifically, the background image is obtained and is divided into n sub-blocks, wherein n is more than or equal to 4; establishing a coordinate template with the size of 5 multiplied by 5 on each sub-block, and establishing 6 different initial filter templates F1, F2, F3, F4, F5 and F6 based on the Gauss-Hermite special moment by utilizing the coordinate template; adding the sub-blocks into the initial filter template for normalization processing to obtain six normalized filter templates; convolving the filter template after the normalization processing to obtain initial directed gradients G1, G2, G3, G4, G5 and G6 of each pixel point (i, j); and solving the gradient amplitude m and the gradient direction theta of the target image representing the target image contour at each pixel point by using the obtained initial directional gradient, namely obtaining the size characteristic of the target image, wherein the calculation formula is as follows:
where the subscript k denotes the index of the initial directional gradients G1, G2, G3, G4, G5, G6.
Generally, the background image is a region covered by a single pixel value, such as a region covered by black color.
S103, after the unit normalization is carried out on the screen size and the image size, if the difference value between the image size and the screen size is within a preset error threshold value, the background image is matched with the screen; otherwise, if the size of the background image is smaller than the size of the screen, the background image is enlarged in equal proportion to enable the transverse or longitudinal size of the background image to be consistent with the size of the screen; and if the size of the background image is larger than the size of the screen, reducing the background image in an equal proportion to enable the transverse or longitudinal size of the background image to be consistent with the size of the screen.
Wherein, the preset error threshold value is generally 1% -2%.
According to the embodiment, the screen size can be effectively determined through a reflected light ray method, and the size of the background image is obtained by a method of extracting and calculating the gradient by using the pixels in different areas.
Fig. 3 is a schematic diagram of a process of generating a planning map in a background image processing method in an embodiment of the present application, where as shown in the drawing, S2 traverses a matched background image, extracts a pixel value of each pixel point in the matched background image, and obtains a pixel value that accounts for the most in the matched background image after statistics, including:
s201, acquiring a matched background image, performing format conversion on the matched background image, and dividing the background image after format conversion into a plurality of image sub-blocks;
specifically, format conversion is to convert a background image in a format such as png, tif (i.e., tiff) or the like into a jpg format, and may be equal-size or unequal-size when divided into a plurality of sub-blocks.
S202, acquiring pixel values of the image sub-blocks;
specifically, a pixel matrix of the subblock is established, wherein the pixel matrix is 4 m × m matrixes and forms an n × n neighborhood, at least one matrix comprises a pixel expected pixel value fx, and the matrix is set as A1, and the other 3 matrixes are numbered as A2, A3 and A4 in sequence in the clockwise direction; wherein m and n are positive integers, m is more than or equal to 2, n/2 is more than or equal to m and less than n; the pixel values of all the matrixes A1, A2, A3 and A4 are respectively calculatedAnd, noted as: Σ 1, Σ 2, Σ 3, Σ 4, and then the pixel f is calculated by the following formula x Edge extraction factor g of x :
g x =|∑1-∑3|+|∑2-∑4|;
Comparing the Edge extraction factor gx with the Edge parameter Edge _ coeff, if: g is a radical of formula x More than or equal to Edge _ coeff, then pixel f x Is an edge pixel; g x < Edge _ coeff, then pixel f x Is a non-edge pixel; and calculating the average value of the edge pixel value and the non-edge pixel value to obtain the pixel value of the sub-block.
S203, summarizing the pixel values of the image subblocks, and establishing a pixel value histogram, wherein the abscissa of the pixel value histogram is the image subblock number, and the ordinate is the pixel value;
the number of the image sub-block can be determined according to the position of the image sub-block in the background image. For example, the first image sub-block located at the upper left corner of the background image is numbered as "1", and the other image sub-blocks are numbered sequentially.
And S204, extracting the pixel value with the largest pixel value ratio from the histogram.
In this embodiment, the most significant pixel value in the background image is obtained, so that which color the dominant color of the background image is can be known, and thus, a transient unnatural phenomenon does not occur during filling.
Fig. 4 is a schematic diagram of a region division process in a background image processing method in an embodiment of the present application, where as shown in the drawing, in step S3, obtaining a contour of the matched background image, and filling the most significant pixel value into an outer edge of the contour of the matched background image to obtain a processed background image, where the process includes:
s301, obtaining an approximate center point of the matched background image, taking the approximate center point of the matched background image as a starting point, scanning pixel points to the edge of the matched background image, and summarizing scanning results to obtain an image outline of the matched background image;
specifically, an approximate center point of the matched background image is obtained, n points are taken from an expected contour line of the matched background image, the contour line of the background image is divided into n parts, wherein an included angle between two adjacent points and the connecting line of the approximate center point is 360/n degrees, and n is an integer greater than or equal to 4;
taking any point on the expected contour line as an initial end point, respectively connecting the point with the rest points to obtain a plurality of line segments, and taking the line segment with the largest length value as a local long axis of the matched background image;
the approximate center point is a diagonal intersection point under the default background image as a rectangle according to the image size, and the outline of the background image needs to be determined because the background image may not be a rectangle but an irregular polygon.
Comparing the lengths of the local long axes, and extracting the local long axis with the longest length as the image long axis of the matched background image;
dividing the matched background image into a left part and a right part through the image long axis of the matched background image, sequentially scanning pixel points on the expected contour line by line in the range of two end points of the image long axis of the matched background image, and respectively obtaining a left short axis and a right short axis which are farthest away from the image long axis of the matched background image on the left part and the right part of the matched background image;
and taking the length of the long axis of the image, the length of the left short axis, the length of the right short axis, the distance between the left short axis and the right short axis and the absolute value of the difference between the lengths of the left short axis and the right short axis as the size value of the matched background image, and obtaining the image contour of the matched background image according to the size value.
S302, obtaining a pixel value of the image contour, subtracting the pixel value with the highest proportion from the pixel value of the image contour, and determining the position of the pixel value with the highest proportion on the screen according to the difference;
specifically, for example, if the R value of RGB of the pixel value with the highest proportion is 125, and the R value of the image contour of the background image is 100, the pixel value with the highest proportion may be set at a screen position which is 25 pixels away from the image contour and is covered by the background image.
And S303, obtaining a pixel difference value of the pixel value with the largest proportion and the uncovered area of the matched background image on the screen, obtaining a color transition gradient according to the pixel difference value, and filling colors in the uncovered area according to the color transition gradient to obtain the processed background image.
As in the above example, the transition gradient may be 1, that is, the first pixel point outside the image contour is filled after increasing the R value by 1R value from the pixel value with the R value of 100.
According to the embodiment, the problem of color difference generated when the background image is filled into the uncovered area can be effectively solved.
In one embodiment, the emitting the light beam to the screen, receiving a reflection signal of the screen to the light beam, and determining the screen size of the screen according to the reflection signal includes:
acquiring a preset emission angle range of an emission beam, and emitting the emission beam to the screen according to the emission angle range;
specifically, the angle range of the emission angle is generally 30 ° to 150 °, so that the screen receives the emitted light beam without unnecessary refraction. The emitted light beam may be visible or infrared, but a single frequency of light must be used to avoid frequency interference.
Acquiring reflected light of the screen to the light beam, and recording the reflection angle and the reflection light intensity of the reflected light to form a reflected light recording table;
acquiring reflection intensity values of two adjacent reflection angles from the reflection light ray record table, if the difference value of the reflection intensity values of the two adjacent reflection angles is larger than a preset difference threshold value, taking the screen position corresponding to the reflection angle with the large reflection intensity value as the edge of the screen, otherwise, excluding the two reflection angles;
wherein, the setting of the margin threshold value is obtained according to historical data of the past tests, and the range of the margin threshold value is usually within 1%.
And summarizing the screen positions corresponding to all the reflection angles larger than the difference threshold value to obtain the size of the screen.
In the embodiment, the size of the screen is effectively determined by the method of reflecting the light beams.
In one embodiment, the obtaining the matched background image, performing format conversion on the matched background image, and dividing the format-converted background image into a plurality of image sub-blocks includes:
acquiring the format name of the matched background image, and performing format normalization processing on the background images with different formats by using an image format conversion tool;
specifically, the image format conversion tool may be an online format conversion tool or various format conversion software stored locally.
Dividing the background image after format normalization processing into a plurality of original image sub-blocks with equal size, acquiring a preset region pixel extraction threshold value, and extracting the original image sub-blocks larger than the region pixel extraction threshold value to obtain final image sub-blocks;
specifically, the region pixel extraction threshold may be a contour edge pixel value of the background image, a pixel value of an approximate center point of the background image, or a pixel value occupying the largest proportion. The area pixel value of each sub-block is the sum of all pixel point pixel values in the area.
And splicing the original sub-blocks smaller than the regional pixel extraction threshold value to obtain new image sub-blocks, wherein if the pixel values of the new image sub-blocks are larger than the regional pixel extraction threshold value, the new image sub-blocks are the final image sub-blocks, and otherwise, continuing splicing.
Specifically, any two original sub-blocks smaller than the region pixel extraction threshold are spliced during splicing, and if the region pixel value of a new image sub-block obtained after splicing is still smaller than the region pixel extraction threshold, a third block is spliced, and so on.
In the embodiment, the background image is effectively segmented, so that the pixel value occupying the most amount in the background image is better obtained, the background image is more accurately processed, and the best display effect is obtained.
In one embodiment, a background image processing apparatus is provided, as shown in fig. 5, including the following modules:
a size matching module 51 configured to obtain a screen size and a background image size, determine whether the background image size matches the screen size, if so, not adjust the background image, otherwise, adjust the size of the background image, so that the background image size matches the screen size;
the pixel establishing module 52 is configured to traverse the matched background image, extract a pixel value of each pixel point in the matched background image, and obtain a pixel value occupying the largest proportion in the matched background image after statistics;
and the image filling module 53 is configured to acquire the contour of the matched background image, and fill the pixel value with the largest proportion to the outer edge of the contour of the matched background image to obtain a processed background image.
In one embodiment, a computer device is provided, which includes a memory and a processor, the memory stores computer readable instructions, and the computer readable instructions, when executed by the processor, cause the processor to execute the steps of the background image processing method in the above embodiments.
In one embodiment, a storage medium storing computer-readable instructions is provided, which when executed by one or more processors, cause the one or more processors to perform the steps of the background image processing method in the above embodiments. Wherein the storage medium may be a non-volatile storage medium.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable storage medium, and the storage medium may include: a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic or optical disk, and the like.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of simplicity of description, all possible combinations of the technical features in the above embodiments are not described, however, as long as there is no contradiction between the combinations of the technical features, the technical features should be considered as the scope of description in the present specification.
The above-mentioned embodiments only express some exemplary embodiments of the present application, and the description therein is specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent application shall be subject to the appended claims.
Claims (9)
1. A background image processing method, comprising:
acquiring a screen size and a background image size, judging whether the background image size is matched with the screen size, if so, not adjusting the background image, otherwise, adjusting the size of the background image to match the background image size with the screen size;
traversing the matched background image, extracting the pixel value of each pixel point in the matched background image, and counting to obtain the pixel value with the largest proportion in the matched background image;
acquiring the contour of the matched background image, and filling the pixel value with the largest proportion to the contour outer edge of the matched background image to obtain a processed background image, and acquiring the contour of the matched background image, and filling the pixel value with the largest proportion to the contour outer edge of the matched background image to obtain the processed background image, including:
acquiring an approximate center point of the matched background image, performing pixel point scanning on the edge of the matched background image by taking the approximate center point of the matched background image as a starting point, and summarizing scanning results to obtain an image contour of the matched background image;
acquiring pixel values of the image contour, performing difference between the pixel values with the highest ratio and the pixel values of the image contour, and determining the position of the pixel values with the highest ratio on the screen according to the difference;
and acquiring a pixel difference value of the pixel value with the largest proportion and the uncovered area of the matched background image on the screen, acquiring a color transition gradient according to the pixel difference value, and filling colors in the uncovered area according to the color transition gradient to obtain the processed background image.
2. The method of claim 1, wherein the obtaining a screen size and a background image size, determining whether the background image size matches the screen size, and if so, not adjusting the background image, otherwise, adjusting the background image size to match the background image size to the screen size, comprises:
emitting a light beam to the screen, receiving a reflection signal of the screen to the light beam, and determining the screen size of the screen according to the reflection signal;
obtaining a background image, dividing the background image into a plurality of sub-blocks, extracting pixel points of the sub-blocks, calculating pixel gradients of the sub-blocks according to the extracted pixel points of the sub-blocks, and determining the image size of the background image according to the pixel gradients of the sub-blocks;
after the unit normalization is carried out on the screen size and the image size, if the difference value of the image size and the screen size is within a preset error threshold value, the background image is matched with the screen;
otherwise, if the size of the background image is smaller than the size of the screen, the background image is enlarged in equal proportion to enable the transverse or longitudinal size of the background image to be consistent with the size of the screen; and if the size of the background image is larger than the size of the screen, reducing the background image in an equal proportion to enable the transverse or longitudinal size of the background image to be consistent with the size of the screen.
3. The background image processing method according to claim 1, wherein traversing the matched background image, extracting a pixel value of each pixel point in the matched background image, and obtaining a pixel value with the largest proportion in the matched background image after statistics, comprises:
acquiring a matched background image, performing format conversion on the matched background image, and dividing the background image after format conversion into a plurality of image sub-blocks;
acquiring pixel values of the image sub-blocks;
summarizing the pixel values of the image subblocks, and establishing a pixel value histogram, wherein the abscissa of the pixel value histogram is the image subblock number, and the ordinate is the pixel value;
and extracting the pixel value with the largest pixel value ratio from the histogram.
4. A background image processing method according to claim 2, wherein said emitting the light beam to the screen, receiving a reflection signal of the light beam by the screen, and determining a screen size of the screen based on the reflection signal comprises:
acquiring a preset emission angle range of the emission beam, and emitting the emission beam to the screen according to the emission angle range;
acquiring the reflected light of the screen to the light beam, and recording the reflection angle and the reflection light intensity of the reflected light to form a reflected light record table;
acquiring reflection intensity values of two adjacent reflection angles from the reflection light ray record table, if the difference value of the reflection intensity values of the two adjacent reflection angles is larger than a preset difference threshold value, taking the position of the screen corresponding to the reflection angle with the large reflection intensity value as the edge of the screen, and otherwise, excluding the two reflection angles;
and summarizing the screen positions corresponding to all the reflection angles larger than the difference threshold value to obtain the size of the screen.
5. The background image processing method according to claim 3, wherein the obtaining the matched background image, performing format conversion on the matched background image, and dividing the format-converted background image into a plurality of image sub-blocks comprises:
acquiring the format name of the matched background image, and performing format normalization processing on background images with different formats by using an image format conversion tool;
dividing the background image after format normalization into a plurality of original image sub-blocks with equal size, acquiring a preset region pixel extraction threshold, and extracting the original image sub-blocks larger than the region pixel extraction threshold to obtain final image sub-blocks;
and splicing the original sub-blocks smaller than the regional pixel extraction threshold value to obtain new image sub-blocks, wherein if the pixel values of the new image sub-blocks are larger than the regional pixel extraction threshold value, the new image sub-blocks are the final image sub-blocks, and otherwise, continuing splicing.
6. The background image processing method according to claim 1, wherein the obtaining of the approximate center point of the matched background image, taking the approximate center point of the matched background image as a starting point, performing pixel point scanning on an edge of the matched background image, and obtaining an image contour of the matched background image after summarizing a scanning result includes:
acquiring an approximate central point of the matched background image, taking n points on an expected contour line of the matched background image, and dividing the contour line of the background image into n parts, wherein the included angle between the connecting line of two adjacent points and the approximate central point is 360/n degrees, and n is an integer greater than or equal to 4;
taking any point taken on the expected contour line as an initial end point, respectively connecting the initial end point with the rest points to obtain a plurality of line segments, and taking the line segment with the maximum length value as a local long axis of the matched background image;
comparing the lengths of the local long axes, and extracting the local long axis with the longest length as the image long axis of the matched background image;
dividing the matched background image into a left part and a right part through the image long axis of the matched background image, sequentially scanning pixel points on the expected contour line by line in the range of two end points of the image long axis of the matched background image, and respectively obtaining a left short axis and a right short axis which are farthest away from the image long axis of the matched background image on the left part and the right part of the matched background image;
and taking the length of the long axis of the image, the length of the left short axis, the length of the right short axis, the distance between the left short axis and the right short axis and the absolute value of the difference between the lengths of the left short axis and the right short axis as the size value of the matched background image, and obtaining the image contour of the matched background image according to the size value.
7. A background image processing apparatus characterized by comprising:
the size matching module is set to obtain the size of a screen and the size of a background image, judge whether the size of the background image is matched with the size of the screen, if so, not adjust the size of the background image, otherwise, adjust the size of the background image to match the size of the background image with the size of the screen;
the pixel establishing module is set to traverse the matched background image, extract the pixel value of each pixel point in the matched background image and obtain the pixel value with the largest proportion in the matched background image after statistics;
an image filling module configured to obtain a contour of the matched background image, fill the pixel value with the largest proportion to an outer edge of the contour of the matched background image to obtain a processed background image, obtain the contour of the matched background image, and fill the pixel value with the largest proportion to the outer edge of the contour of the matched background image to obtain the processed background image, including:
acquiring an approximate center point of the matched background image, performing pixel point scanning on the edge of the matched background image by taking the approximate center point of the matched background image as a starting point, and summarizing scanning results to obtain an image contour of the matched background image;
acquiring a pixel value of the image contour, making a difference between the pixel value with the highest proportion and the pixel value of the image contour, and determining the position of the pixel value with the highest proportion on the screen according to the difference;
and acquiring a pixel difference value of the pixel value with the largest proportion and the uncovered area of the matched background image on the screen, acquiring a color transition gradient according to the pixel difference value, and filling colors in the uncovered area according to the color transition gradient to obtain the processed background image.
8. A computer device comprising a memory and a processor, the memory having stored therein computer readable instructions which, when executed by the processor, cause the processor to carry out the steps of the background image processing method as claimed in any one of claims 1 to 7.
9. A storage medium storing computer readable instructions which, when executed by one or more processors, cause the one or more processors to perform the steps of the background image processing method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910200336.5A CN110047043B (en) | 2019-03-16 | 2019-03-16 | Background image processing method, background image processing device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910200336.5A CN110047043B (en) | 2019-03-16 | 2019-03-16 | Background image processing method, background image processing device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110047043A CN110047043A (en) | 2019-07-23 |
CN110047043B true CN110047043B (en) | 2022-11-08 |
Family
ID=67273757
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910200336.5A Active CN110047043B (en) | 2019-03-16 | 2019-03-16 | Background image processing method, background image processing device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110047043B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106095447A (en) * | 2016-06-14 | 2016-11-09 | 武汉深之度科技有限公司 | A kind of generation method of application interface, equipment and the equipment of calculating |
CN106934838A (en) * | 2017-02-08 | 2017-07-07 | 广州阿里巴巴文学信息技术有限公司 | Picture display method, equipment and programmable device |
CN107316567A (en) * | 2017-08-11 | 2017-11-03 | 天马微电子股份有限公司 | Flexible display systems and its control method |
CN108595239A (en) * | 2018-04-18 | 2018-09-28 | 腾讯科技(深圳)有限公司 | image processing method, device, terminal and computer readable storage medium |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8913087B1 (en) * | 2009-07-22 | 2014-12-16 | Amazon Technologies, Inc. | Digital image cropping |
EP3223272B1 (en) * | 2014-11-21 | 2020-06-24 | Rakuten, Inc. | Information processing device, information processing method, and information processing program |
US10074194B2 (en) * | 2016-12-08 | 2018-09-11 | Microsoft Technology Licensing, Llc | Graphical object content rendition |
-
2019
- 2019-03-16 CN CN201910200336.5A patent/CN110047043B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106095447A (en) * | 2016-06-14 | 2016-11-09 | 武汉深之度科技有限公司 | A kind of generation method of application interface, equipment and the equipment of calculating |
CN106934838A (en) * | 2017-02-08 | 2017-07-07 | 广州阿里巴巴文学信息技术有限公司 | Picture display method, equipment and programmable device |
CN107316567A (en) * | 2017-08-11 | 2017-11-03 | 天马微电子股份有限公司 | Flexible display systems and its control method |
CN108595239A (en) * | 2018-04-18 | 2018-09-28 | 腾讯科技(深圳)有限公司 | image processing method, device, terminal and computer readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110047043A (en) | 2019-07-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11194536B2 (en) | Image processing method and apparatus for displaying an image between two display screens | |
US7352898B2 (en) | Image processing apparatus, image processing method and program product therefor | |
CN102682446B (en) | Adaptive combined two-sided filter is used to generate equipment and the method for dense depth map | |
US8472753B2 (en) | Method and system of adaptive reformatting of digital image | |
CN112017222B (en) | Video panorama stitching and three-dimensional fusion method and device | |
EP3690801A1 (en) | Image processing method and device, storage medium and computer device | |
KR20070008652A (en) | Method for extracting raw data of a photographed image | |
JP7537095B2 (en) | Information processing device, program, information generation method, and information processing system | |
US10580122B2 (en) | Method and system for image enhancement | |
US10297009B2 (en) | Apparatus and method for generating an extrapolated image using a recursive hierarchical process | |
US9667833B2 (en) | History generating apparatus and history generating method | |
US9087272B2 (en) | Optical match character classification | |
CN109360144A (en) | An improved method for real-time image correction based on mobile phone platform | |
US20080037902A1 (en) | Image processing apparatus and control method therefor | |
EP3067857A1 (en) | Method and device for processing a peripheral image | |
CN110047043B (en) | Background image processing method, background image processing device, computer equipment and storage medium | |
CN113888509B (en) | Image clarity evaluation method, device, equipment and storage medium | |
CN110458754B (en) | Image generation method and terminal equipment | |
CN110248147A (en) | A kind of image display method and apparatus | |
CN117095417A (en) | Screen shot form image text recognition method, device, equipment and storage medium | |
WO2023193648A1 (en) | Image processing method and apparatus, electronic device, and storage medium | |
JPH10145604A (en) | Image sharpness processing method, its device and storage medium recording program | |
Liu et al. | A novel deep learning-based disocclusion hole-filling approach for stereoscopic view synthesis | |
CN103250185A (en) | Image processing device using an energy value, and image processing method and display method thereof | |
CN115170581A (en) | Portrait segmentation model generation method, portrait segmentation model and portrait segmentation 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 |