Image processing method and device and storage medium
By determining the target pixel in image expansion and generating an extended background using its pixel coordinate values, the problem of chromatic difference between the background and the image after image expansion is solved, improving the user experience.
Patent Information
- Application Number
- CN202311553302.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-20
- Publication Date
- 2025-05-20
AI Technical Summary
In the process of image expansion, obvious visual color difference is prone to occur between the extended background and the image to be processed, affecting the user's viewing experience.
By determining the target pixel from the image to be processed and expanding the image based on the pixel coordinate value of the target pixel, an extended background is generated so that its pixel coordinate value is consistent with the target pixel, thereby reducing the visual color difference between the background and the image.
It effectively reduces the visual color difference between the extended background and the image to be processed, and improves the user's viewing experience.
Smart Images

Figure CN120020858A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing, and in particular, to an image processing method, apparatus, and storage medium. Background Art
[0002] In image processing technology, Image Extension is a common processing technique. It is often used in aspects such as image enhancement, image registration, and image fusion. Through image extension, it can be ensured that the input and output images have the same size, maintaining the accuracy and consistency of image processing.
[0003] Image extension expands the size or dimensions of an image by filling pixel values at the edges or boundaries of the image. Summary of the Invention
[0004] To overcome the problems existing in the related art, the present disclosure provides an image processing method, apparatus, and storage medium.
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided an image processing method, including obtaining an image to be processed; determining a target pixel in the image to be processed, and determining the pixel coordinate value of the target pixel; performing image extension on the image to be processed based on the pixel coordinate value of the target pixel to obtain a target image, where the target image includes the image to be processed and an extended background.
[0006] In one implementation, the determining a target pixel in the image to be processed includes: cropping a specified area of the image to be processed, and determining the cropped specified area as a pixel acquisition area; randomly sampling pixel points in the pixel acquisition area to obtain at least one pixel; and determining a target pixel based on at least one pixel in the pixel acquisition area.
[0007] In another implementation, the determining a target pixel based on at least one pixel in the pixel acquisition area includes: obtaining the pixel information of each pixel in the at least one pixel; performing pixel clustering on the at least one pixel based on the pixel information of each pixel in the at least one pixel to obtain N first cluster center pixels, where N is an integer greater than or equal to 1; and determining the target pixel based on the first cluster center pixels.
[0008] In another implementation, the determining the target pixel based on the first cluster center pixels includes: in the case where N is equal to 1, using the first cluster center pixel as the target pixel; or in the case where N is greater than 1, performing secondary pixel clustering on the N first cluster center pixels to obtain a second cluster center pixel, and using the second cluster center pixel as the target pixel.
[0009] In another implementation, the image expansion of the to-be-processed image includes: determining an initial size of the to-be-processed image and a target size after the expansion of the to-be-processed image; determining an expansion direction and an expansion coefficient of the to-be-processed image based on the initial size and the target size; and performing image expansion on the to-be-processed image based on the expansion direction and the expansion coefficient.
[0010] In another implementation, the image expansion of the to-be-processed image includes: determining an expansion direction and an expansion coefficient based on an initial size of the to-be-processed image and a target size after the expansion of the to-be-processed image; setting a transparency adjustment parameter based on the expansion direction; and performing expansion on the to-be-processed image based on the expansion direction, the expansion coefficient, and the transparency adjustment parameter to obtain the target image.
[0011] According to a second aspect of the embodiments of the present disclosure, there is provided an image processing apparatus, including an acquisition unit configured to acquire a to-be-processed image; and a processing unit configured to determine a target pixel in the to-be-processed image and determine a pixel coordinate value of the target pixel; the processing unit is further configured to perform image expansion on the to-be-processed image based on the pixel coordinate value of the target pixel to obtain a target image, where the target image includes the to-be-processed image and an expanded background.
[0012] In one implementation, the processing unit determines the target pixel in the to-be-processed image in the following manner: cropping a specified area of the to-be-processed image and determining the cropped specified area as a pixel acquisition area; randomly sampling pixel points in the pixel acquisition area to obtain at least one pixel; and determining the target pixel based on the at least one pixel in the pixel acquisition area.
[0013] In another implementation, the processing unit determines the target pixel in the following manner, including: obtaining pixel information of each pixel in the at least one pixel; performing pixel clustering on the at least one pixel based on the pixel information of each pixel in the at least one pixel to obtain a first clustering center pixel with a number of N, where N is an integer greater than or equal to 1; and determining the target pixel based on the first clustering center pixel.
[0014] In another implementation, the processing unit determines the target pixel in the following manner, including: in the case where N is equal to 1, using the first clustering center pixel as the target pixel; or in the case where N is greater than 1, performing secondary pixel clustering on the first clustering center pixels with the number of N to obtain a second clustering center pixel and using the second clustering center pixel as the target pixel.
[0015] In another embodiment, the processing unit performs image expansion on the image to be processed in the following manner: determining the initial size of the image to be processed and the target size after expansion of the image to be processed; determining the expansion direction and expansion coefficient of the image to be processed based on the initial size and the target size; and performing image expansion on the image to be processed based on the expansion direction and the expansion coefficient.
[0016] In another embodiment, the processing unit performs image expansion on the image to be processed in the following manner: determining the expansion direction and expansion coefficient based on the initial size of the image to be processed and the target size after expansion of the image to be processed; setting a transparency adjustment parameter based on the expansion direction; and expanding the image to be processed based on the expansion direction, the expansion coefficient, and the transparency adjustment parameter to obtain the target image.
[0017] According to a third aspect of the embodiments of the present disclosure, there is provided an image processing apparatus, including: a memory for storing processor-executable instructions; wherein the processor is configured to: execute the image processing method according to the first aspect or any one of the first aspect.
[0018] According to a fourth aspect of the embodiments of the present disclosure, there is provided a storage medium storing instructions that, when run on a device, cause the device to execute the image processing method according to the first aspect or any one of the first aspect.
[0019] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: By determining target pixels from the image to be processed and performing image expansion based on the coordinate values of the target pixels, the visual color difference between the expanded background and the image to be processed is reduced, thereby enhancing the user viewing experience.
[0020] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.
[0022] Figure 1 is a contrast diagram of image expansion shown in an exemplary embodiment.
[0023] Figure 2 is a flowchart of an image processing method shown in an exemplary embodiment.
[0024] Figure 3 is a method for determining target pixels in an image to be processed.
[0025] Figure 4 It is a method for determining target pixels in an image to be processed.
[0026] Figure 5 It is a method for determining target pixels in an image to be processed.
[0027] Figure 6 It is a method for image expansion of the image to be processed.
[0028] Figure 7 It is a method for image expansion of the image to be processed.
[0029] Figure 8 It is a block diagram of an image device shown according to an exemplary embodiment.
[0030] Figure 9 It is a block diagram of a device for image processing shown according to an exemplary embodiment.
[0031] Figure 10 It is a block diagram of a device for image processing shown according to an exemplary embodiment. Detailed implementation
[0032] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure.
[0033] Image extension technology (Image Extension), also known as image magnification or image scaling, refers to the process of converting an image from one resolution to another by changing the size of the image. This technology is mainly used to change the size of the image, and can enlarge or reduce the image to the required size while maintaining the quality and details of the image.
[0034] Exemplarily, Figure 1 It is a comparison diagram of image extension shown according to an exemplary embodiment. As Figure 1 shown, the length dimension of the image 11 to be extended before image extension is a (for example, the unit can be pixel, etc.), and the width dimension is b (for example, the unit can be pixel, etc.). After the image extension process, the extended image 12 is obtained. Among them, the length dimension of the extended image 12 is a, and the width dimension is c (for example, the unit can be pixel, etc.), and c is greater than b.
[0035] Continue Figure 1Embodiments. It can be understood that after the image to be expanded 11 is expanded, there will be redundant image content. For example, in the expanded image 12, the content presented below the dotted line.
[0036] It should be noted that for the convenience of introducing and describing the embodiments, the part below the dotted line in the expanded image 12 is referred to as "background" or "expanded background".
[0037] In some embodiments, image expansion techniques usually fill pixel values at the edges or boundaries of an image to expand the size or dimensions of the image, thereby achieving image expansion.
[0038] Exemplarily, continuing Figure 1 Embodiment, the image to be expanded 11 can be expanded downward based on the pixel points at its bottom edge to obtain the expanded image 12. Among them, the pixel points at the bottom edge of the image to be expanded 11 are the dotted line part in the expanded image 12. And the specific implementation method of expanding downward based on the pixel points at its bottom edge can be: repeatedly copying the pixel points at the bottom edge multiple times to obtain the expanded background.
[0039] It can be understood that in the case of relatively complex image information (such as non-solid-color pictures or pictures with gradient colors), since the pixel coordinate values of the image edges (taking a square picture as an example, the image edges can refer to the upper, lower, left, and right edges of the image, etc.) may have obvious differences from the color coordinates corresponding to the central area of the image, if the image is expanded by repeatedly copying the edge pixel points, there may be an obvious color difference between the expanded background and the original image, thereby affecting the user's viewing experience.
[0040] Based on this, the embodiments of the present disclosure propose an image processing method, which includes obtaining an image to be processed; determining a target pixel in the image to be processed and determining the pixel coordinate value of the target pixel; performing image expansion on the image to be processed to obtain a target image, where the target image includes the image to be processed and an expanded background, and the pixel coordinate value of the expanded background is the pixel coordinate value of the target pixel. By determining the target pixel from the image to be processed and performing image expansion based on the coordinate value of the target pixel, the visual color difference between the expanded background and the image to be processed is reduced, thereby improving the user's viewing experience.
[0041] It should be noted that the image processing method involved in the embodiments of the present disclosure can be applied to a terminal. In some embodiments, the terminal includes, for example, at least one of a mobile phone, a wearable device, an Internet of Things device, a car with communication function, a smart car, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal device in industrial control, a wireless terminal device in self-driving, a wireless terminal device in remote medical surgery, a wireless terminal device in smart grid, a wireless terminal device in transportation safety, a wireless terminal device in smart city, and a wireless terminal device in smart home, but is not limited thereto.
[0042] For ease of understanding, in the following embodiments of the present disclosure, the exemplary description of "terminal", without special emphasis, can be understood as "smartphone".
[0043] It should be noted that, for ease of understanding the embodiments of the present disclosure, the following explains some terms in the embodiments of the present disclosure to facilitate the understanding of those skilled in the art.
[0044] Clustering: It is a technology that groups image pixels according to similarity. The goal of clustering is to group similar pixels in an image into one category, so as to achieve image segmentation, classification or other subsequent processing operations.
[0045] Clustering algorithm: It is a specific mathematical or computational method used to implement the clustering process. These algorithms divide pixels into different groups or categories according to the similarity metric between pixels. In a clustering algorithm, it is usually necessary to define a similarity metric index and an objective function of the clustering algorithm.
[0046] Common clustering algorithms include:
[0047] 1. K-Means algorithm: It divides the data set into K different clusters, and each cluster has similar features. The clustering is achieved by continuously iteratively optimizing the objective function.
[0048] 2. Hierarchical clustering algorithm: By constructing a hierarchical structure between clusters, the data is clustered layer by layer to form a tree structure.
[0049] 3. DBSCAN algorithm: A density-based clustering method that divides clusters by discovering regions with sufficient density.
[0050] 4. Gaussian Mixture Model (GMM): Assumes that the dataset is composed of a mixture distribution of multiple Gaussian distributions and uses maximum likelihood estimation to cluster the data.
[0051] It can be understood that the clustering algorithms used in the embodiments of the present disclosure can be implemented by any one or any combination of the above-listed clustering algorithms.
[0052] It can be understood that the above clustering algorithms are only exemplary listings rather than exhaustive, and other clustering algorithms that can be used for clustering calculations can also be applicable to the embodiments of the present disclosure.
[0053] Figure 2 is a flowchart of an image processing method shown according to an exemplary embodiment, as Figure 2 shown, including the following steps.
[0054] In step S11, an image to be processed is obtained.
[0055] In step S12, target pixels are determined in the image to be processed, and the pixel coordinate values of the target pixels are determined.
[0056] In step S13, the image to be processed is expanded based on the pixel coordinate values of the target pixels to obtain a target image, and the target image includes the image to be processed and the expanded background.
[0057] The image processing method provided by the embodiments of the present disclosure determines target pixels from the image to be processed and expands the image based on the coordinate values of the target pixels, reducing the visual color difference between the expanded background and the image to be processed, thereby improving the user viewing experience.
[0058] In some embodiments, the image processing method is applied to a terminal.
[0059] In some embodiments, an image is obtained by calling a preset image acquisition device, or an image to be processed transmitted by an external device is received.
[0060] In some embodiments, terms such as "image to be processed", "initial image", "original image", "image to be expanded", etc. can be replaced with each other.
[0061] In some embodiments, the target pixels are used to determine the expanded background.
[0062] Optionally, the pixel coordinate values of the target pixels are used as the pixel coordinate values of the expanded background.
[0063] Exemplarily, it is determined that the pixel coordinate value of the target pixel is (R1 , G 1 , B 1 ), then set the pixel coordinate value of the extended background as (R 1 , G 1 , B 1 ).
[0064] It can be understood that setting the pixel coordinate value of the extended background as (R 1 , G 1 , B 1 ) can be achieved by any of the following methods:
[0065] - a) Repeatedly copy the target pixel with the pixel coordinate value of (R 1 , G 1 , B 1 ) to obtain the extended background.
[0066] - b) Create the pixels of the extended background with the coordinate value of (R 1 , G 1 , B 1 ).
[0067] In some embodiments, "obtain", "acquire", "get", "receive", "transmit", "bidirectional transmission", "send and / or receive" can be replaced with each other, and it can be interpreted as receiving from other entities, but not limited to this.
[0068] In some embodiments, terms such as "certain", "preseted", "preset", "set", "indicated", "a certain", "any", "first", etc. can be replaced with each other. "Specific A", "preseted A", "preset A", "set A", "indicated A", "a certain A", "any A", "first A" can be interpreted as A pre - specified in a protocol, etc., or as A obtained through setting, configuration, or indication, etc., or as specific A, a certain A, any A, or first A, etc., but not limited to this.
[0069] The image processing method involved in the embodiments of the present disclosure may include at least one of steps S11 to S13. For example, step S11 can be implemented as an independent embodiment, step S12 can be implemented as an independent embodiment, step S11 + step S12 can be implemented as an independent embodiment, step S11 + step S12 + step S13 can be implemented as an independent embodiment, but not limited to this.
[0070] In some embodiments, steps S11 and S12 are optional, and one or more of these steps can be omitted or replaced in different embodiments.
[0071] In some embodiments, steps S11 and S13 are optional, and one or more of these steps may be omitted or replaced in different embodiments.
[0072] In some embodiments, steps S12 and S13 are optional, and one or more of these steps may be omitted or replaced in different embodiments.
[0073] In some embodiments, Figure 3 is a method for determining target pixels in an image to be processed, as Figure 3 shown, the method includes the following steps.
[0074] In step S21, a specified area of the image to be processed is cropped, and the cropped specified area is determined as the pixel acquisition area.
[0075] In step S22, pixel points in the pixel acquisition area are randomly sampled to obtain at least one pixel.
[0076] In step S23, based on at least one pixel in the pixel acquisition area, the target pixel is determined.
[0077] The image processing method provided by the embodiments of the present disclosure can make the pixel coordinate values of the extended background generated based on the target pixel closer to the image to be processed by determining the target pixel points for the selected pixel acquisition area in the image to be processed, thereby reducing the visual color difference between the extended background and the image to be processed, and improving the user viewing experience.
[0078] In some embodiments, the number of specified areas can be set to one or more.
[0079] In some embodiments, the specified area can be set based on a preset rule.
[0080] Optionally, the specified area can be a corner area of the image to be processed.
[0081] Exemplarily, continuing Figure 1 the embodiment, the specified area can be the four right-angle areas of the image 11 to be processed. The area size can be set based on a preset rule.
[0082] It can be understood that the area set based on the preset rule can be any one or more areas in an image to be processed with any initial shape (for example, circular, rectangular, etc.). The above embodiments are only exemplary listings rather than exhaustive. Any specified area that can be obtained from the image to be processed through the preset rule is within the scope described in the above embodiments.
[0083] In some embodiments, the specified area includes at least one pixel point.
[0084] In some embodiments, when the number of specified regions is one, the number of pixel acquisition regions is one, and the specified region is regarded as the pixel acquisition region.
[0085] In some embodiments, when the number of specified regions is multiple, the number of pixel acquisition regions is multiple, and each pixel acquisition region corresponds to one specified region, and each specified region is regarded as one pixel acquisition region.
[0086] In some embodiments, when the number of pixel acquisition regions is multiple, random sampling is performed on the pixel points in the image in the pixel acquisition regions, including:
[0087] -a) Randomly sample each pixel acquisition region respectively to obtain at least one pixel of each pixel acquisition region.
[0088] In the embodiments of the present disclosure, through the sampling method of -a), the correspondence between the sampled samples and the corresponding pixel acquisition regions can be stronger, so that after subsequent pixel clustering processing, the distances of the pixel coordinate values of the obtained clustering centers to the pixel coordinate values of each pixel acquisition region are nearly the same. Then, using this clustering center as the target pixel for image expansion can reduce the visual color difference between the expanded background and the image to be processed, thereby improving the user viewing experience.
[0089] -b) In one or more specified pixel acquisition regions among the multiple pixel acquisition regions, randomly sample the specified one or more pixel acquisition regions respectively to obtain at least one pixel of each specified pixel acquisition region.
[0090] In the embodiments of the present disclosure, through the sampling method of -b), the pixel acquisition regions with obvious differences or anomalies in pixel values are excluded during the process of determining the pixel acquisition regions, avoiding the interference of the pixels collected in the pixel acquisition regions with obvious abnormal pixel values on the final pixel values.
[0091] -c) Randomly sample the pixel points in all pixel acquisition regions uniformly.
[0092] In the embodiments of the present disclosure, for a specified image to be processed, uniformly randomly sampling the pixel points in all pixel acquisition regions can improve the sampling efficiency. Among them, the specified image to be processed can be: a solid-color image, or an image in which the number of pixels with the same pixel value exceeds a certain number threshold.
[0093] The image processing method involved in the embodiments of the present disclosure may include at least one of steps S21 to S23. For example, step S21 can be implemented as an independent embodiment, step S22 can be implemented as an independent embodiment, step S21 + step S22 can be implemented as an independent embodiment, and step S21 + step S22 + step S23 can be implemented as an independent embodiment, but not limited thereto.
[0094] In some embodiments, steps S21 and S22 are optional, and one or more of these steps can be omitted or replaced in different embodiments.
[0095] In some embodiments, steps S21 and S23 are optional, and one or more of these steps can be omitted or replaced in different embodiments.
[0096] In some embodiments, steps S22 and S23 are optional, and one or more of these steps can be omitted or replaced in different embodiments.
[0097] In some embodiments, Figure 4 is a method for determining target pixels in a to-be-processed image, as Figure 4 shown, the method includes the following steps.
[0098] In step S31, pixel information of each pixel in at least one pixel is obtained.
[0099] In step S32, based on the pixel information of each pixel in at least one pixel, pixel clustering is performed on at least one pixel to obtain N first clustering center pixels, where N is an integer greater than or equal to 1.
[0100] In step S33, based on the first clustering center pixels, target pixels are determined.
[0101] In the embodiments of the present disclosure, at least one pixel is clustered through a clustering algorithm to obtain a clustering center. The pixel value of the clustering center can be closer to the pixel value of the pixel acquisition area, thereby reducing the visual color difference between the extended background and the to-be-processed image, and thus improving the user viewing experience.
[0102] In some embodiments, the pixel information is the pixel coordinate value corresponding to the pixel value.
[0103] It can be understood that in different coordinate systems, pixel information can be represented by different types of pixel coordinates. The pixel coordinate representation methods include any one of the following: RGBA, grayscale value, CMYK, or HSV, etc.
[0104] For ease of understanding, in the embodiments of the present disclosure, pixel coordinates are described based on the RGBA method. Of course, other types of pixel coordinate representations can also be applicable.
[0105] In some embodiments, at least one pixel is pixel-clustered based on a preset clustering algorithm to obtain N first clustering center pixels.
[0106] It can be understood that at least one pixel is obtained by any one of the above - a), - b) or - c) random sampling methods.
[0107] In some embodiments, the setting of N is determined based on a preset rule.
[0108] In some embodiments, the preset clustering algorithm may include at least one of the following: K-Means algorithm, hierarchical clustering algorithm, or Gaussian mixture model, etc.
[0109] It can be understood that the clustering algorithms listed in the embodiments of the present disclosure are only exemplary listings, not exhaustive. Other clustering algorithms that can perform pixel clustering are all the clustering algorithms mentioned in the embodiments of the present disclosure.
[0110] In some embodiments, determining a target pixel based on the first clustering center pixel may include: determining the first clustering center pixel as the target pixel, or calculating the target pixel through the first clustering center pixel.
[0111] In some embodiments, terms such as "clustering center", "clustering center pixel", and "clustering center pixel point" can be replaced with each other.
[0112] The image processing method involved in the embodiments of the present disclosure may include at least one of steps S31 to S33. For example, step S31 can be implemented as an independent embodiment, step S32 can be implemented as an independent embodiment, step S31 + step S32 can be implemented as an independent embodiment, and step S31 + step S32 + step S33 can be implemented as an independent embodiment, but not limited thereto.
[0113] In some embodiments, steps S31 and S32 are optional, and one or more of these steps can be omitted or replaced in different embodiments.
[0114] In some embodiments, steps S31 and S33 are optional, and one or more of these steps can be omitted or replaced in different embodiments.
[0115] In some embodiments, steps S32 and S33 are optional, and one or more of these steps can be omitted or replaced in different embodiments.
[0116] In some embodiments, Figure 5 is a method for determining target pixels in an image to be processed, as Figure 5 shown, the method includes the following steps.
[0117] In step S41, determine the numerical value of N.
[0118] In step S42, when N is equal to 1, take the first cluster center pixel as the target pixel.
[0119] In step S43, when N is greater than 1, perform secondary pixel clustering on the N first cluster center pixels to obtain second cluster center pixels, and take the second cluster center pixels as the target pixels.
[0120] In the embodiments of the present disclosure, different target pixels are determined based on the first cluster center for different values of N. The image processing method can be applied to environments with various clustering requirements.
[0121] In some embodiments, when N is greater than 1, a preset clustering algorithm can be used to cluster the N first cluster center pixels (i.e., secondary clustering).
[0122] It can be understood that the clustering algorithm used for secondary clustering can be determined based on the clustering algorithm mentioned in the above Figure 4 related embodiments. To avoid repeated introduction, it will not be elaborated here one by one.
[0123] In some embodiments, when N is greater than 1, perform secondary pixel clustering on the N first cluster center pixels to obtain second cluster center pixels. When the number of second cluster center pixels is 1, take the second cluster center as the target pixel.
[0124] In some embodiments, when N is greater than 1, perform secondary pixel clustering on the N first cluster center pixels to obtain second cluster center pixels. When the number of second cluster center pixels is M (M is an integer greater than 1), tertiary pixel clustering can be performed on the second cluster center to obtain a third cluster center.
[0125] Optionally, if the number of third cluster centers is 1, determine the third cluster center as the target pixel.
[0126] Optionally, if the number of third cluster centers is greater than 1, perform quaternary pixel clustering on the third cluster center, and so on.
[0127] The image processing method involved in the embodiments of the present disclosure may include at least one of steps S41 to S43. For example, step S41 may be implemented as an independent embodiment, step S42 may be implemented as an independent embodiment, step S41 + step S42 may be implemented as an independent embodiment, and step S41 + step S42 + step S43 may be implemented as an independent embodiment, but not limited thereto.
[0128] In some embodiments, steps S41 and S42 are optional, and one or more of these steps may be omitted or replaced in different embodiments.
[0129] In some embodiments, steps S41 and S43 are optional, and one or more of these steps may be omitted or replaced in different embodiments.
[0130] In some embodiments, steps S42 and S43 are optional, and one or more of these steps may be omitted or replaced in different embodiments.
[0131] In some embodiments, Figure 6 is a method for image expansion of the to-be-processed image, as Figure 6 shown, the method includes the following steps.
[0132] In step S51, determine the initial size of the to-be-processed image and the target size after the expansion of the to-be-processed image.
[0133] In step S52, determine the expansion direction and expansion coefficient of the to-be-processed image based on the initial size and the target size.
[0134] In step S53, perform image expansion on the to-be-processed image based on the expansion direction and the expansion coefficient.
[0135] In the embodiments of the present disclosure, by determining the initial size and the target size, obtaining the expansion direction and expansion coefficient for image expansion, and completing the image expansion based on the expansion coefficient in the expansion direction, the image expansion result can be made more accurate.
[0136] In some embodiments, the initial size of the image may be the resolution size or the physical size, etc. Correspondingly, the target size after the image expansion is the resolution size or the physical size, etc.
[0137] In some embodiments, the expansion direction can be understood as the direction of the background pixels to be filled. Exemplarily, continuing Figure 1 the embodiment, expanding the initial image 11 to the target image 12, the expansion direction is from the lower edge of the initial image 11, downward.
[0138] In some embodiments, the expansion coefficient can be understood as the expansion ratio of the side length.
[0139] Exemplarily, continuing Figure 1 with the embodiment, assuming that the expansion coefficient is determined to be m based on the initial size and the target size, then during the process of expanding the initial image 11 to the target image 12, the length of the width (c) of the target image 12 is b * m.
[0140] Exemplarily, continuing Figure 1 with the embodiment, for determining the expansion direction based on the initial size and the target size, it can be achieved in the following manner:
[0141] Before image expansion, the initial size (such as a, b) and the target size (such as c, a) can be obtained. In the case where the ratio of b / a is greater than the ratio of c / a, it can be known that expansion needs to be performed based on the direction where b is located. That is, the expansion direction as shown Figure 1 can be selected, or the opposite direction of where b is located can also be selected.
[0142] For ease of understanding, the embodiments of the present disclosure will be described with actual image expansion examples:
[0143] It can be understood that the purpose of determining the expansion direction and the expansion coefficient of the image to be processed is to ensure that the original image does not distort during the expansion process. The core of non-distortion is to enlarge or reduce the original image proportionally. For example, for an original image with a ratio of 320 * 320 and an aspect ratio of 1:1, then during the image expansion process, this aspect ratio needs to be maintained.
[0144] Based on this, if the user's image expansion requirement is to expand an image with a width and height of A * B pixels into an image with C * D pixels. Then first, the image with A * A pixels should be enlarged to C * C. In the case where the image does not distort, it can be known that: C / C is less than D / C. Therefore, the image needs to be expanded in the direction of "height", and the expansion size is (D - C) pixels. Wherein, A, B, C, and D are all numbers greater than zero.
[0145] The image processing method involved in the embodiments of the present disclosure may include at least one of steps S51 to step S53. For example, step S51 can be implemented as an independent embodiment, step S52 can be implemented as an independent embodiment, step S51 + step S52 can be implemented as an independent embodiment, step S51 + step S52 + step S53 can be implemented as an independent embodiment, but is not limited thereto.
[0146] In some embodiments, steps S51 and step S52 are optional, and in different embodiments, one or more of these steps can be omitted or replaced.
[0147] In some embodiments, steps S51 and S53 are optional, and one or more of these steps may be omitted or replaced in different embodiments.
[0148] In some embodiments, steps S52 and S53 are optional, and one or more of these steps may be omitted or replaced in different embodiments.
[0149] In some embodiments, Figure 7 is a method for image expansion of the to-be-processed image, as Figure 7 shown, the method includes the following steps.
[0150] In step S61, based on the initial size of the to-be-processed image and the target size after expansion of the to-be-processed image, the expansion direction and the expansion coefficient are determined.
[0151] In step S62, transparency adjustment parameters are set based on the expansion direction.
[0152] In step S63, the to-be-processed image is expanded based on the expansion direction, the expansion coefficient, and the transparency adjustment parameters to obtain a target image.
[0153] In the embodiments of the present disclosure, by setting transparency adjustment parameters in the expansion direction, the transparency of the expanded image can be gradually changed, visual color difference can be reduced, and user experience can be improved.
[0154] In some embodiments, setting transparency adjustment parameters based on the expansion direction can be understood as performing transparency adjustment in the expansion direction.
[0155] In some embodiments, by adding an alpha channel in the expansion direction, the setting of transparency adjustment parameters can be achieved.
[0156] The image processing method involved in the embodiments of the present disclosure may include at least one of steps S61 to S63. For example, step S61 can be implemented as an independent embodiment, step S62 can be implemented as an independent embodiment, step S61 + step S62 can be implemented as an independent embodiment, and step S61 + step S62 + step S63 can be implemented as an independent embodiment, but not limited thereto.
[0157] In some embodiments, steps S61 and S62 are optional, and one or more of these steps may be omitted or replaced in different embodiments.
[0158] In some embodiments, steps S61 and S63 are optional, and one or more of these steps may be omitted or replaced in different embodiments.
[0159] In some embodiments, steps S62 and S63 are optional, and in different embodiments, one or more of these steps may be omitted or replaced.
[0160] Based on the same concept, an embodiment of the present disclosure also provides an image processing apparatus.
[0161] It can be understood that in order to implement the above functions, the image processing apparatus provided by the embodiments of the present disclosure includes the corresponding hardware structures and / or software modules for executing each function. Combining the units and algorithm steps of the various examples disclosed in the embodiments of the present disclosure, the embodiments of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiments of the present disclosure.
[0162] Figure 8 is a block diagram of an image device 100 shown according to an exemplary embodiment. Referring to Figure 8 , the device includes an acquisition unit 101 and a processing unit 102.
[0163] The acquisition unit 101 is configured to acquire an image to be processed.
[0164] The processing unit 102 is configured to determine a target pixel in the image to be processed and determine the pixel coordinate value of the target pixel.
[0165] The processing unit 102 is further configured to perform image expansion on the image to be processed based on the pixel coordinate value of the target pixel to obtain a target image, where the target image includes the image to be processed and an expanded background.
[0166] In some embodiments, the processing unit 102 determines the target pixel in the image to be processed by the following method: cropping a specified area of the image to be processed and determining the cropped specified area as a pixel acquisition area; randomly sampling pixel points in the pixel acquisition area to obtain at least one pixel; and determining the target pixel based on at least one pixel in the pixel acquisition area.
[0167] In some embodiments, the processing unit 102 determines the target pixel by the following method, including: acquiring the pixel information of each pixel in at least one pixel; performing pixel clustering on at least one pixel based on the pixel information of each pixel in at least one pixel to obtain N first clustering center pixels, where N is an integer greater than or equal to 1; and determining the target pixel based on the first clustering center pixels.
[0168] In some embodiments, the processing unit 102 determines the target pixel in the following manner, including: when N equals 1, taking the first cluster center pixel as the target pixel; or when N is greater than 1, performing secondary pixel clustering on the N first cluster center pixels to obtain second cluster center pixels, and taking the second cluster center pixels as the target pixels.
[0169] In some embodiments, the processing unit 102 performs image expansion on the image to be processed in the following manner: determining the initial size of the image to be processed and the target size after the expansion of the image to be processed; determining the expansion direction and expansion coefficient of the image to be processed based on the initial size and the target size; and performing image expansion on the image to be processed based on the expansion direction and the expansion coefficient.
[0170] In some embodiments, the processing unit 102 performs image expansion on the image to be processed in the following manner: determining the expansion direction and expansion coefficient based on the initial size of the image to be processed and the target size after the expansion of the image to be processed; setting a transparency adjustment parameter based on the expansion direction; and performing expansion on the image to be processed based on the expansion direction, the expansion coefficient, and the transparency adjustment parameter to obtain the target image.
[0171] Figure 9 is a block diagram of an apparatus 200 for image processing shown according to an exemplary embodiment. For example, the apparatus 200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0172] Referring to Figure 9 , the image processing apparatus 200 may include one or more of the following components: a processing component 202, a memory 204, a power component 206, a multimedia component 208, an audio component 210, an input / output (I / O) interface 212, a sensor component 214, and a communication component 216.
[0173] The processing component 202 generally controls the overall operation of the apparatus 200, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing component 202 may include one or more processors 220 to execute instructions to complete all or part of the steps of the above methods. In addition, the processing component 202 may include one or more modules to facilitate the interaction between the processing component 202 and other components. For example, the processing component 202 may include a multimedia module to facilitate the interaction between the multimedia component 208 and the processing component 202.
[0174] The memory 204 is configured to store various types of data to support the operation of the device 200. Examples of such data include instructions for any application or method operating on the device 200, contact data, phone book data, messages, pictures, videos, and the like. The memory 204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.
[0175] The power component 206 provides power for the various components of the device 200. The power component 206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 200.
[0176] The multimedia component 208 includes a screen that provides an output interface between the device 200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation. In some embodiments, the multimedia component 208 includes a front camera and / or a rear camera. When the device 200 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.
[0177] The audio component 210 is configured to output and / or input audio signals. For example, the audio component 210 includes a microphone (MIC) that is configured to receive external audio signals when the device 200 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 204 or transmitted via the communication component 216. In some embodiments, the audio component 210 further includes a speaker for outputting audio signals.
[0178] The I / O interface 212 provides an interface between the processing component 202 and a peripheral interface module, which can be a keyboard, a click wheel, buttons, etc. These buttons can include, but are not limited to: a home button, a volume button, a power-on button, and a lock button.
[0179] The sensor assembly 214 includes one or more sensors for providing an assessment of various aspects of the status of the device 200. For example, the sensor assembly 214 can detect the on / off state of the device 200, the relative positioning of components, such as the display and keypad of the device 200, the sensor assembly 214 can also detect a change in the position of the device 200 or a component of the device 200, the presence or absence of user contact with the device 200, the orientation or acceleration / deceleration of the device 200, and the temperature change of the device 200. The sensor assembly 214 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 214 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 214 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0180] The communication component 216 is configured to facilitate communication between the device 200 and other devices in a wired or wireless manner. The device 200 can access a wireless network based on communication standards, such as WiFi, 2G, or 3G, or a combination thereof. In one exemplary embodiment, the communication component 216 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 216 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0181] In an exemplary embodiment, the device 200 can be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above method.
[0182] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as the memory 204 including instructions, and the above instructions can be executed by the processor 220 of the device 200 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0183] Figure 10 is a block diagram of an apparatus 300 for image processing shown according to an exemplary embodiment. For example, the apparatus 300 can be provided as a server. Refer to Figure 10, Device 300 includes a processing component 322, which further includes one or more processors, and memory resources represented by a memory 332 for storing instructions executable by the processing component 322, such as application programs. The application programs stored in the memory 332 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 322 is configured to execute instructions to perform the above screen display method
[0184] Device 300 may further include a power component 326 configured to perform power management of the device 300, a wired or wireless network interface 350 configured to connect the device 300 to a network, and an input / output (I / O) interface 358. Device 300 may operate based on an operating system stored in the memory 332, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM or the like.
[0185] It can be understood that "a plurality of" in the present disclosure means two or more, and other quantifiers are similar. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after. The singular forms of "a", "the" and "said" are also intended to include the plural forms unless the context clearly indicates otherwise.
[0186] It can be further understood that the terms "first", "second", etc. are used to describe various information, but this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other and do not indicate a specific order or importance. In fact, the expressions "first", "second", etc. can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information can also be called the second information, and similarly, the second information can also be called the first information.
[0187] It can be further understood that the orientation or positional relationship indicated by the terms "center", "longitudinal", "lateral", "front", "rear", "upper", "lower", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing this embodiment and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation.
[0188] It can be further understood that unless otherwise specified, "connection" includes direct connection without other components between the two, and also includes indirect connection with other elements between the two.
[0189] It can be further understood that although operations are depicted in the drawings in a particular order in the embodiments of the present disclosure, it should not be construed as requiring that the operations be performed in the particular order shown or in a sequential order, or requiring all of the illustrated operations to obtain the desired result. Multitasking and parallel processing may be advantageous in certain environments.
[0190] Other embodiments of the present disclosure will be readily apparent to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include known or customary techniques in the art not disclosed herein.
Claims
1. An image processing method, characterized in that: include: Get the image to be processed; Determine a target pixel in the image to be processed, and determine a pixel coordinate value of the target pixel; The image to be processed is expanded based on the pixel coordinate value of the target pixel to obtain a target image, wherein the target image includes the image to be processed and an expanded background.
2. The method according to claim 1, characterized in that The step of determining a target pixel in the image to be processed comprises: Cropping a designated area of the image to be processed, and determining the cropped designated area as a pixel acquisition area; Randomly sampling pixel points in the pixel acquisition area to obtain at least one pixel; A target pixel is determined based on at least one pixel in the pixel acquisition area.
3. The method according to claim 2, characterized in that The determining of the target pixel based on at least one pixel in the pixel acquisition area comprises: Acquire pixel information of each pixel in the at least one pixel; Based on the pixel information of each pixel in the at least one pixel, pixel clustering is performed on the at least one pixel to obtain a number N of first cluster center pixels, wherein N is an integer greater than or equal to 1; Based on the first cluster center pixel, the target pixel is determined.
4. The method according to claim 3, characterized in that The determining the target pixel based on the first cluster center pixel includes: When N is equal to 1, taking the first cluster center pixel as the target pixel; or In the case where N is greater than 1, secondary pixel clustering is performed on the N first cluster center pixels to obtain second cluster center pixels, and the second cluster center pixels are used as the target pixels.
5. The method according to claim 1, characterized in that The step of performing image expansion on the image to be processed comprises: Determining an initial size of the image to be processed and a target size of the image to be processed after expansion; Determining an expansion direction and an expansion coefficient of the image to be processed based on the initial size and the target size; The image to be processed is expanded based on the expansion direction and the expansion coefficient.
6. The method according to claim 1, characterized in that The step of performing image expansion on the image to be processed comprises: Determining an expansion direction and an expansion coefficient based on an initial size of the image to be processed and a target size of the image to be processed after expansion; Setting a transparency adjustment parameter based on the extension direction; The image to be processed is expanded based on the expansion direction, the expansion coefficient, and the transparency adjustment parameter to obtain the target image.
7. An image processing device, characterized in that: include: An acquisition unit, used for acquiring an image to be processed; A processing unit, used to determine a target pixel in the image to be processed, and determine a pixel coordinate value of the target pixel; The processing unit is further used to perform image expansion on the image to be processed based on the pixel coordinate value of the target pixel to obtain a target image, wherein the target image includes the image to be processed and an expanded background.
8. The device according to claim 7, characterized in that The processing unit determines the target pixel in the image to be processed in the following manner: Cropping a designated area of the image to be processed, and determining the cropped designated area as a pixel acquisition area; Randomly sampling pixel points in the pixel acquisition area to obtain at least one pixel; A target pixel is determined based on at least one pixel in the pixel acquisition area.
9. The device according to claim 8, characterized in that The processing unit determines the target pixel in the following manner, including: Acquire pixel information of each pixel in the at least one pixel; Based on the pixel information of each pixel in the at least one pixel, pixel clustering is performed on the at least one pixel to obtain a number N of first cluster center pixels, wherein N is an integer greater than or equal to 1; Based on the first cluster center pixel, the target pixel is determined.
10. The device according to claim 9, characterized in that The processing unit determines the target pixel in the following manner, including: When N is equal to 1, taking the first cluster center pixel as the target pixel; or In the case where N is greater than 1, secondary pixel clustering is performed on the N first cluster center pixels to obtain second cluster center pixels, and the second cluster center pixels are used as the target pixels.
11. The device according to claim 7, characterized in that The processing unit performs image expansion on the image to be processed in the following manner: Determining an initial size of the image to be processed and a target size of the image to be processed after expansion; Determining an expansion direction and an expansion coefficient of the image to be processed based on the initial size and the target size; The image to be processed is expanded based on the expansion direction and the expansion coefficient.
12. The device according to claim 7, characterized in that The processing unit performs image expansion on the image to be processed in the following manner: Determining an expansion direction and an expansion coefficient based on an initial size of the image to be processed and a target size of the image to be processed after expansion; Setting a transparency adjustment parameter based on the extension direction; The image to be processed is expanded based on the expansion direction, the expansion coefficient, and the transparency adjustment parameter to obtain the target image.
13. An image processing device, characterized in that: include: a memory for storing processor executable instructions; Wherein, the processor is configured to: execute the image processing method described in any one of claims 1 to 6.
14. A storage medium storing instructions, characterized in that: When the instruction is executed on a device, the device executes the image processing method according to any one of claims 1 to 6.
Citation Information
Cited By
Image processing method and device, electronic equipment and readable medium
CN120751070A
Image processing methods, apparatus, electronic devices and readable media
CN120751070B