Image display method and device and electronic equipment
By identifying and processing deformable and non-deformable elements in an image, and using stretching or shrinking dividing lines to generate a new image, the problems of image distortion and disharmony in proportion are solved, achieving visual aesthetic effects when the size changes.
Patent Information
- Application Number
- CN202411069516.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2026-02-06
AI Technical Summary
Existing technologies can easily lead to image element distortion and disproportion when changing the size and aspect ratio of image materials, affecting the visual aesthetics.
By identifying deformable and non-deformable elements in an image, and using stretching or shrinking dividing lines, a new image is generated to maintain the original layout and alignment of the elements, avoiding deformation and distortion.
It ensures that the image maintains its original layout and alignment when the image size changes, without affecting the visual aesthetics and guaranteeing the neatness and beauty of the image elements.
Smart Images

Figure CN121481831A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and more specifically, to a method, apparatus, and electronic device for image display. Background Technology
[0002] In various scenarios (such as handwritten notes, presentation creation, etc.), users often need to change the size and aspect ratio of image materials to suit personalized content needs. However, using ordinary image scaling currently results in image elements being distorted, disproportionate, and aesthetically unappealing, which is difficult for users to accept. Summary of the Invention
[0003] This application provides a method, apparatus, and electronic device for displaying images, which can enable the image layout to adapt to the size of the image, avoid image deformation and distortion, and ensure visual aesthetics.
[0004] In a first aspect, a method for displaying an image is provided, the method comprising: in response to an operation by a user to stretch a first image along a first direction, determining a stretching dimension of the first image, the first image including deformable elements and non-deformable elements; displaying a second image, the second image having a target region including target pixels, the target pixels being pixels that are repeated by the deformable elements along the first direction, the target region having a dimension along the first direction equal to the stretching dimension, and the non-deformable elements being located outside the target region.
[0005] The first image is the image before stretching, and the second image is the image after stretching. The size of the second image is larger than that of the first image. The first image can include deformable and non-deformable elements. Deformable elements can be understood as elements whose size changes during image stretching or shrinking without affecting the displayed effect; deformable elements can include, for example, lines and rectangles. Non-deformable elements can be understood as elements whose size remains fixed during image stretching or shrinking and cannot be deformed or distorted. If the element deforms, it may affect the displayed effect; non-deformable elements can include, for example, special characters, symbols, fonts, patterns formed by certain arrangements and combinations, and patterns with special shapes.
[0006] The term "target pixel" can be understood as the pixel value of the target pixel being the same as the pixel value of the deformable element along the first direction.
[0007] In this embodiment, the electronic device can generate and display a second image based on the user's operation of stretching the first image. The second image includes a target area (i.e., a newly added area), and the target pixels in the target area are the pixels of deformable elements that repeat along the stretching direction, while non-deformable elements are located outside the target area. That is, when the first image includes both deformable and non-deformable elements, when stretching the first image, the size of the deformable elements on the first image changes and can be stretched, while the size of the non-deformable elements on the first image remains unchanged, maintaining their original alignment. This enables the image layout to adaptively change with the image size, ensuring that the stretched image maintains its original layout and alignment without causing deformation or distortion of elements, thus guaranteeing a visually appealing aesthetic.
[0008] In conjunction with the first aspect, in some implementations of the first aspect, the first image further includes repeatable elements, and the method further includes: displaying the repeatable elements in the target area when the first direction is the same as the arrangement direction of the repeatable elements.
[0009] It should be understood that the repeatable element is an element that appears repeatedly in the first image. In other words, an element that appears twice or more in the first image can be considered a repeatable element. For example, the first image may include multiple repeatable circles, lines, etc.
[0010] In the embodiments of this application, when the first image includes repeatable elements, when stretching the first image, the repeatable elements can be adaptively increased according to the arrangement rules, so that the image layout can adaptively change with the aspect ratio of the image.
[0011] In conjunction with the first aspect, in some implementations of the first aspect, before displaying the second image, the method further includes: in response to a first operation by a user, determining a first dividing line, wherein pixels on the first dividing line include the target pixel.
[0012] In this embodiment of the application, the user can draw a first dividing line on the first image, thereby stretching the first image according to the first dividing line, that is, by repeatedly filling the target area with pixels on the first dividing line, the pixel filling of the target area is achieved, and a second image is obtained.
[0013] In conjunction with the first aspect, in some implementations of the first aspect, the pixels on the first dividing line do not include the pixels of the indeformable element.
[0014] In this embodiment, the pixels on the first dividing line do not include pixels of non-deformable elements. That is, when stretching the first image based on the first dividing line, the non-deformable elements on the first image will not be distorted or deformed, and will not affect the image layout of the stretched second image, thus ensuring visual aesthetics.
[0015] In conjunction with the first aspect, in some implementations of the first aspect, the pixels on the first dividing line do not include the pixels of the repeatable element.
[0016] In this embodiment, the pixels on the first dividing line do not include the pixels of repeatable elements. That is, when stretching the first image based on the first dividing line, the repeatable elements on the first image will not be distorted or deformed, thus avoiding affecting the image layout of the stretched second image and ensuring visual aesthetics.
[0017] In conjunction with the first aspect, in some implementations of the first aspect, the indeformable element includes a first element, and the first dividing line is set within a preset range of the first element.
[0018] In this embodiment, the first dividing line can avoid the non-deformable elements and be set within a preset range of the non-deformable elements, so that when the pixels on the first dividing line are repeatedly filled in the target area, the non-deformable elements will not be distorted or deformed, and the image layout of the stretched second image will not be affected, thus ensuring the visual aesthetics.
[0019] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: in response to a second user operation, determining a second dividing line, wherein the second dividing line and the first dividing line are located on opposite sides of the first element.
[0020] In this embodiment, the user can set dividing lines on both sides of the indeformable first element, so that when the first image is stretched, the first element will not be distorted or deformed, and the image layout of the stretched second image will not be affected, thus ensuring the visual aesthetics.
[0021] In conjunction with the first aspect, in some implementations of the first aspect, the non-deformable element further includes a second element, the second element being spaced apart from the first element along the first direction, the first element and the second element being located inside the deformable element, and the method further includes: in response to a second operation by a user, determining a second dividing line, the second dividing line being set within a preset range of the second element.
[0022] In this embodiment of the application, when there are multiple non-deformable elements, multiple dividing lines can be drawn within a preset range of the multiple non-deformable elements, so that when the first image is stretched, the non-deformable elements on the first image will not be distorted or deformed, and the image layout of the stretched second image will not be affected, thus ensuring the visual aesthetics.
[0023] In conjunction with the first aspect, in some implementations of the first aspect, the target region further includes background pixels, and the pixel values on the background pixels are filled according to the pixel values on the first dividing line.
[0024] In this embodiment of the application, when the background color of the first image is manipulated, the background pixels of the target area can be filled according to the pixel values on the stretching dividing line (such as the first dividing line), so that the stretched second image retains the original color and ensures the visual aesthetics.
[0025] In conjunction with the first aspect, in some implementations of the first aspect, the non-deformable element includes a third element, the relative position of the third element on the first image being different from the relative position of the third element on the second image.
[0026] In the embodiments of this application, during the stretching of the first image, the position of the non-deformable elements on the first image may change, for example, from the first position to the second position. That is, the relative position of the non-deformable third element on the first image is different from the relative position of the non-deformable third element on the second image, so that the non-deformable elements on the first image will not be distorted or deformed, while ensuring the original layout design of the image and ensuring the visual aesthetics.
[0027] In conjunction with the first aspect, in some implementations of the first aspect, before displaying the second image, the method further includes: displaying an intermediate image, the intermediate image including the first image and a first region, the first region being a region between the boundary of the first image and the boundary of the second image, the display color of the first region being of the same color family as the background color of the first image.
[0028] In the embodiments of this application, considering the different performance characteristics of electronic devices, in some examples, an intermediate image can be displayed on the electronic device before displaying the second image. The intermediate image includes a first image and a first region. The first region is the area between the boundary of the first image and the boundary of the second image, and the display color of the first region belongs to the same color family as the background color of the first image. For example, the first region can be filled with the background color of the first image with a transparency of 30%. Furthermore, the above method can achieve the filling of the first region, ultimately displaying the stretched second image, ensuring that the non-deformable elements in the stretched second image are not deformed, resulting in a neat and aesthetically pleasing layout.
[0029] Secondly, a method for displaying an image is provided, the method comprising: determining a stretching direction and a stretching dimension of a first image; determining, based on the stretching direction, the element types of the first image, the element types including deformable elements and non-deformable elements; determining a stretching dividing line based on the element types of the first image and the stretching direction; determining a target region of a second image, the second image being a stretched image, based on the first image, the stretching direction, and the stretching dimension; and filling the target region with pixels along the stretching dividing line.
[0030] In this embodiment of the application, when stretching the first image, the element types included in the first image are first determined based on the stretching direction; then, the stretching dividing line is determined according to the element types and stretching direction of the first image; finally, the target area (or newly added area) of the second image can be filled by the pixels on the stretching dividing line; thereby, the image layout can be adaptively changed with the size of the image, so that the stretched image can maintain the original layout and alignment, without causing deformation and distortion of elements, thus ensuring visual aesthetics.
[0031] In conjunction with the second aspect, in some implementations of the second aspect, the element type further includes repeatable elements, and the method further includes: if the repeatable elements are located on both sides of the stretching dividing line, then fill the target area with the repeatable elements.
[0032] In this embodiment, when the first image includes repeatable elements and the repeatable elements are located on both sides of the stretching dividing line, repeatable elements can be filled into the target area (or newly added area). That is, for repeatable elements in the image, they can be adaptively increased according to the arrangement pattern of the repeatable elements, so that the image layout can adaptively change with the aspect ratio of the image.
[0033] In conjunction with the second aspect, in some implementations of the second aspect, before filling the target area with the repeatable element, the method further includes: removing the repeatable element from the first image; and using the average pixel value within a preset range surrounding the repeatable element to fill the pixel value at the position corresponding to the repeatable element on the first image.
[0034] In this embodiment of the application, for repeatable elements on the first image, the repeatable elements can first be removed from the first image, and then the background holes of the first image can be repaired. For example, the pixel value at the position corresponding to the repeatable element on the first image can be filled by using the pixel average value within a preset range around the repeatable element, so that the first image after removing the repeatable elements can be obtained. Then, the pixel filling of the new area or target area can be achieved by repeatedly copying and stretching the pixels on the dividing line.
[0035] In conjunction with the second aspect, in some implementations of the second aspect, filling the target area with the repeatable elements includes: determining the total number of repeatable elements to be filled in the second image based on the stretching size, the maximum distance between repeatable elements in the first image, and the spacing between adjacent repeatable elements; and determining the filling position of the repeatable elements in the second image based on the total number of repeatable elements, the position of the first repeatable element, and the spacing between adjacent repeatable elements.
[0036] In this embodiment, when repeatable elements are located on both sides of the stretching dividing line, all repeatable elements need to be removed from the first image first, and the background holes in the first image need to be repaired. Then, the pixels on the stretching dividing line are repeatedly copied to fill the target area of the second image. Finally, the total number of repeatable elements to be filled on the second image is determined according to the stretching size, the maximum distance between repeatable elements on the first image, and the spacing between adjacent repeatable elements. Starting from the first repeatable element, the repeatable elements are filled sequentially according to the total number of repeatable elements and the spacing between adjacent repeatable elements, and the target area of the second image will also be filled with corresponding repeatable elements.
[0037] In conjunction with the second aspect, in some implementations of the second aspect, the stretching dividing line does not overlap with the non-deformable element.
[0038] In this embodiment, the pixels on the stretching dividing line do not include pixels of non-deformable elements. That is, when stretching the first image based on the stretching dividing line, the non-deformable elements on the first image will not be distorted or deformed, and will not affect the image layout of the stretched second image, thus ensuring the visual aesthetics.
[0039] In conjunction with the second aspect, in some implementations of the second aspect, determining the element types included in the first image according to the stretching direction includes: performing binarization processing on the first image to determine the binarized image corresponding to the first image; performing contour detection and line segment detection on the binarized image to determine the hierarchical elements of the first image; and classifying each hierarchical element according to the stretching direction to determine the element type of each hierarchical element.
[0040] In this embodiment of the application, after acquiring the first image, the first image can be classified into layers according to the stretching direction of the first image to determine the element type of each layer. Based on the layer classification results, the original alignment of non-deformable elements can be maintained, the size of deformable elements can be changed, and the number of repeatable elements can be increased at equal intervals in the stretching direction.
[0041] In conjunction with the second aspect, in some implementations of the second aspect, the hierarchical elements include first-level elements, and determining the element type of each level's elements includes: if the shape similarity, area intersection-union ratio, and distance of the first element and the second element of the first level's elements all satisfy preset conditions, then the first element is determined to be a repeatable element; if any one of the shape similarity, area intersection-union ratio, and distance of the first element and the second element of the first level's elements does not satisfy the preset conditions, then the first element is determined to be a non-repeatable element.
[0042] In one possible implementation, if the shape similarity between the first element and other elements (such as the second element) is greater than a first threshold, and the area intersection-union ratio of the first element and other elements (such as the second element) is greater than a second threshold, and the distance between the average color vector of the first element and other elements (such as the second element) is less than a third threshold, then the first element can be considered as the same repeatable element.
[0043] In the embodiments of this application, when classifying elements at each level, the existence of repeatable elements can be determined based on the above-mentioned shape similarity, area intersection-union ratio and average color vector distance. Thus, based on the hierarchical classification results, the original alignment of non-deformable elements can be maintained, the size of deformable elements can be changed, and the number of repeatable elements can be increased at equal intervals in the stretching direction.
[0044] In conjunction with the second aspect, in some implementations of the second aspect, when it is determined that the first element is a non-repeatable element, determining the element type of the element at each level includes: if it is determined that the first element is located in the deformable image library, then the first element is determined to be a deformable element; if it is determined that the first element is not located in the deformable image library, then the first element is determined to be a non-deformable element.
[0045] In this embodiment, if the first element is determined to be a non-repeatable element, it can be further matched against a deformable image library. If the first element is found to be in the deformable image library, it is determined to be a deformable element; otherwise, it is determined to be a non-deformable element. Thus, based on the hierarchical classification results, the original alignment of non-deformable elements can be maintained, the size of deformable elements can be changed, and the number of repeatable elements can be increased at equal intervals in the stretching direction.
[0046] Thirdly, a method for displaying an image is provided, the method comprising: in response to a user's operation of shrinking a first image along a first direction, determining a shrinkage size of the first image, the first image including deformable elements and non-deformable elements, the first image including a target region and a non-target region, the target region including target pixels, the target pixels being pixels repeated by the deformable elements along the first direction, the shrinkage size of the target region along the first direction being equal to the shrinkage size, the non-deformable elements being located outside the target region; and displaying a second image, the second image including the non-target region.
[0047] The first image is the image before shrinking, and the second image is the image after shrinking. The size of the second image is smaller than the size of the first image. The first image can include deformable and non-deformable elements. Deformable elements can be understood as elements whose size changes during image stretching or shrinking without affecting the displayed effect; deformable elements can include, for example, lines and rectangles. Non-deformable elements can be understood as elements whose size remains fixed during image stretching or shrinking and cannot be deformed or distorted. If the element deforms, it may affect the displayed effect; non-deformable elements can include, for example, special characters, symbols, fonts, patterns formed by certain arrangements and combinations, and patterns with special shapes.
[0048] In this embodiment, the electronic device can generate and display a second image based on the user's operation of shrinking a first image. The first image includes a target region and a non-target region. The target region includes target pixels that are repeated along the stretching direction of deformable elements, while non-deformable elements are located outside the target region, i.e., within the non-target region. The shrunk second image only includes the non-target region; that is, the target region is deleted, and the non-target region is retained. In other words, when the first image includes both deformable and non-deformable elements, shrinking the first image changes the size of the deformable elements, allowing them to be shortened, while the size of the non-deformable elements remains unchanged, maintaining their original alignment. This enables the image layout to adaptively change with the image size, ensuring that the stretched image maintains its original layout and alignment without deformation or distortion of elements, thus guaranteeing a visually appealing aesthetic.
[0049] In conjunction with the third aspect, in some implementations of the third aspect, the first image further includes a plurality of repeatable elements, and when the first direction is the same as the arrangement direction of the repeatable elements, the target region includes at least one of the repeatable elements.
[0050] It should be understood that the repeatable element is an element that appears repeatedly in the first image. In other words, an element that appears twice or more in the first image can be considered a repeatable element. For example, the first image may include multiple repeatable circles, lines, etc.
[0051] In this embodiment of the application, when the first image includes repeatable elements, the repeatable elements in the target area are deleted when the first image is shrunk. The repeatable elements can be reduced adaptively according to the arrangement rules of the repeatable elements, so that the image layout can adapt to the changes in the aspect ratio of the image.
[0052] In conjunction with the third aspect, in some implementations of the third aspect, prior to displaying the second image, the method further includes: in response to a first operation by the user, determining a first dividing line, wherein pixels on the first dividing line include pixels repeated by the deformable element along the first direction.
[0053] In this embodiment of the application, the user can draw a first dividing line on the first image, thereby shrinking the first image according to the first dividing line, that is, repeatedly deleting pixels on the first dividing line to achieve the purpose of deleting the target area, and the resulting second image does not include the target area.
[0054] In conjunction with the third aspect, in some implementations of the third aspect, the pixels on the first dividing line do not include the pixels on the indeformable element.
[0055] In this embodiment, the pixels on the first dividing line do not include the pixels on the non-deformable elements. That is, when the first image is shrunk based on the first dividing line, the non-deformable elements on the first image will not be distorted or deformed, and the image layout of the shrunk second image will not be affected, thus ensuring the visual aesthetics.
[0056] In conjunction with the third aspect, in some implementations of the third aspect, the pixels on the first dividing line do not include the pixels of the repeatable element.
[0057] In this embodiment, the pixels on the first dividing line do not include the pixels of repeatable elements. That is, when the first image is shrunk based on the first dividing line, the repeatable elements on the first image will not be distorted or deformed, thus avoiding affecting the image layout of the shrunk second image and ensuring visual aesthetics.
[0058] In conjunction with the third aspect, in some implementations of the third aspect, the indeformable element includes a first element, and the first dividing line is set within a preset range of the first element.
[0059] In this embodiment, the first dividing line can avoid the non-deformable elements and is set within a preset range of the non-deformable elements, so that when pixels on the first dividing line are repeatedly deleted in the target area, the non-deformable elements will not be distorted or deformed, and the image layout of the shrunk second image will not be affected, thus ensuring the visual aesthetics.
[0060] In conjunction with the third aspect, in some implementations of the third aspect, the method further includes: in response to a second user operation, determining a second dividing line, wherein the second dividing line and the first dividing line are located on opposite sides of the first element.
[0061] In this embodiment, the user can set dividing lines on both sides of the indeformable first element, so that when the first image is shrunk, the first element will not be distorted or deformed, and the image layout of the shrunk second image will not be affected, thus ensuring the visual aesthetics.
[0062] In conjunction with the third aspect, in some implementations of the third aspect, the non-deformable element further includes a second element, which is spaced apart from the first element along the first direction, and the first element and the second element are located inside the deformable element. The method further includes: in response to a second operation by the user, determining a second dividing line, which is set within a preset range of the second element.
[0063] In this embodiment of the application, when there are multiple non-deformable elements, multiple dividing lines can be drawn within a preset range of the multiple non-deformable elements, so that when the first image is shrunk, the non-deformable elements on the first image will not be distorted or deformed, and the image layout of the shrunk second image will not be affected, thus ensuring the visual aesthetics.
[0064] In conjunction with the third aspect, in some implementations of the third aspect, the non-deformable element includes a third element whose relative position on the first image is different from its relative position on the second image.
[0065] In the embodiments of this application, during the shrinking of the first image, the position of the non-deformable elements on the first image may change, for example, from the first position to the second position. That is, the relative position of the non-deformable third element on the first image is different from the relative position of the non-deformable third element on the second image, so that the non-deformable elements on the first image will not be distorted, while ensuring the original layout design of the image and ensuring the visual aesthetics.
[0066] Fourthly, a method for displaying an image is provided, the method comprising: determining a shrinkage direction and a shrinkage size of a first image; determining, based on the shrinkage direction, the element types included in the first image, the element types including deformable elements and non-deformable elements; determining a shrinkage dividing line based on the element types of the first image and the shrinkage direction; determining a target region of the first image based on the first image, the shrinkage direction, and the shrinkage size; and repeatedly deleting pixels on the shrinkage dividing line to delete the target region.
[0067] In this embodiment of the application, when shrinking the first image, the element types included in the first image are first determined based on the shrinking direction; then, the shrinking dividing line is determined according to the element types and shrinking direction of the first image; finally, the target area of the first image can be deleted by repeatedly deleting pixels on the shrinking dividing line; thereby, the image layout can be adaptively changed with the size of the image, so that the shrunk image can maintain the original layout and alignment, without causing deformation and distortion of elements, thus ensuring visual aesthetics.
[0068] In conjunction with the fourth aspect, in some implementations of the fourth aspect, the element type further includes repeatable elements, and the method further includes: if the repeatable elements are located on both sides of the shrinking dividing line, then delete the repeatable elements in the target area.
[0069] In this embodiment, when the first image includes repeatable elements and these repeatable elements are located on both sides of the stretching dividing line, the repeatable elements within the target area can be deleted. That is, the number of repeatable elements in the image can be adaptively reduced according to their arrangement, thereby allowing the image layout to adapt to changes in the image's aspect ratio.
[0070] In conjunction with the fourth aspect, in some implementations of the fourth aspect, before repeatedly deleting pixels on the shrinking dividing line, the method further includes: removing the repeatable element from the first image; and filling the pixel value at the position corresponding to the repeatable element on the first image with the average pixel value within a preset range surrounding the repeatable element.
[0071] In this embodiment of the application, for repeatable elements on the first image, the repeatable elements can first be removed from the first image, and then the background holes of the first image can be repaired. For example, the pixel value at the position corresponding to the repeatable element on the first image can be filled by using the pixel average value within a preset range around the repeatable element, so that the first image after removing the repeatable elements can be obtained. Then, the deletion of the target area can be achieved by repeatedly deleting the pixels on the stretching dividing line.
[0072] In conjunction with the fourth aspect, in some implementations of the fourth aspect, the method further includes: determining the total number of repeatable elements to be filled in the second image based on the shrinkage size, the maximum distance between repeatable elements in the first image, and the spacing between adjacent repeatable elements; and determining the filling position of the repeatable elements in the second image based on the total number of repeatable elements, the position of the first repeatable element, and the spacing between adjacent repeatable elements.
[0073] In this embodiment, when repeatable elements are located on both sides of the shrinking dividing line, all repeatable elements need to be removed from the first image first, and the background holes of the first image need to be repaired; then, the target area is deleted by repeatedly deleting pixels on the shrinking dividing line; finally, the total number of repeatable elements to be filled in the second image is determined according to the shrinking size, the maximum distance between repeatable elements in the first image, and the spacing between adjacent repeatable elements; starting from the first repeatable element, repeatable elements are filled sequentially according to the total number of repeatable elements and the spacing between adjacent repeatable elements.
[0074] In conjunction with the fourth aspect, in some implementations of the fourth aspect, the contraction dividing line does not overlap with the non-deformable element.
[0075] In this embodiment of the application, the pixels on the shrinking dividing line do not include the pixels on the non-deformable elements. That is to say, when the first image is stretched based on the shrinking dividing line, the non-deformable elements on the first image will not be distorted or deformed, and will not affect the image layout of the shrunken second image, thus ensuring the visual aesthetics.
[0076] In conjunction with the fourth aspect, in some implementations of the fourth aspect, determining the element types included in the first image according to the contraction direction includes: performing binarization processing on the first image to determine the binarized image corresponding to the first image; performing contour detection and line segment detection on the binarized image to determine the hierarchical elements of the first image; and classifying each hierarchical element according to the contraction direction to determine the element type of each hierarchical element.
[0077] In this embodiment of the application, after acquiring the first image, the first image can be classified into layers according to the shrinkage direction of the first image to determine the element type of each layer. Thus, based on the layer classification results, the original alignment of non-deformable elements can be maintained, the size of deformable elements can be changed, and repeatable elements can be reduced at equal intervals in the shrinkage direction.
[0078] In conjunction with the fourth aspect, in some implementations of the fourth aspect, the hierarchical elements include first-level elements, and determining the element type of each level's elements includes: if the shape similarity, area intersection-union ratio, and distance of the first element and the second element of the first-level element all satisfy preset conditions, then the first element is determined to be a repeatable element; if any one of the shape similarity, area intersection-union ratio, and distance of the first element and the second element of the first-level element does not satisfy the preset conditions, then the first element is determined to be a non-repeatable element.
[0079] In one possible implementation, if the shape similarity between the first element and other elements (such as the second element) is greater than a first threshold, and the area intersection-union ratio between the first element and other elements (such as the second element) is greater than a second threshold, and the distance between the average color vectors of the first element and other elements (such as the second element) is less than a fourth threshold, then the first element and other elements (such as the second element) can be considered as the same repeatable element.
[0080] In the embodiments of this application, when classifying elements at each level, the existence of repeatable elements can be determined based on the above-mentioned shape similarity, area intersection-union ratio and average color vector distance. Thus, based on the hierarchical classification results, the original alignment of non-deformable elements can be maintained, the size of deformable elements can be changed, and repeatable elements can be reduced at equal intervals in the contraction direction.
[0081] In conjunction with the fourth aspect, in some implementations of the fourth aspect, when it is determined that the first element is a non-repeatable element, determining the element type of the element at each level includes: if it is determined that the first element is located in the deformable image library, then the first element is determined to be a deformable element; if it is determined that the first element is not located in the deformable image library, then the first element is determined to be a non-deformable element.
[0082] In this embodiment, if the first element is determined to be a non-repeatable element, it can be further matched against a deformable image library. If the first element is found to be in the deformable image library, it is determined to be a deformable element; otherwise, it is determined to be a non-deformable element. Thus, based on the hierarchical classification results, the original alignment of non-deformable elements can be maintained, the size of deformable elements can be changed, and repeatable elements can be reduced at equal intervals in the contraction direction.
[0083] Fifthly, a method for displaying an image is provided, the method comprising: in response to an operation by a user to stretch a first image along a first direction, determining a stretching dimension of the first image, the first image including repeatable elements; and displaying a second image, the target region of the second image including the repeatable elements, the dimension of the target region along the first direction being equal to the stretching dimension.
[0084] In this embodiment, the first image can be an aesthetically pleasing sticker image or artistic lines formed by a special arrangement of repeatable elements. When the first image only includes repeatable elements, the electronic device can generate and display a second image based on the user's operation of stretching the first image. The second image includes a target area (i.e., the newly added area). The target area can present repeatable elements at equal intervals, so that when stretching the first image, the repeatable elements can be added adaptively according to the arrangement rules of the repeatable elements, avoiding manual copying of repeatable elements, which is more efficient and convenient.
[0085] A sixth aspect provides a method for displaying an image, the method comprising: in response to an operation by a user to shrink a first image along a first direction, determining a shrinkage size of the first image, the first image including repeatable elements, the first image including a target region and a non-target region, the target region including at least one of the repeatable elements, the size of the target region along the first direction being equal to the shrinkage size; and displaying a second image, the second image including the non-target region.
[0086] In this embodiment, the first image can be an aesthetically pleasing sticker image or artistic lines formed by a special arrangement of repeatable elements. When the first image only includes repeatable elements, the electronic device can generate and display a second image based on the user's operation of shrinking the first image. The first image includes a target area and a non-target area, and the second image only includes the non-target area, which is equivalent to deleting the repeatable elements in the target area. This allows the first image to be adaptively reduced according to the arrangement rules of the repeatable elements when shrinking, avoiding manual deletion of repeatable elements and making it more efficient and convenient.
[0087] For detailed explanations and descriptions of the beneficial effects of the following technical solutions, please refer to the relevant content in aspects one through six, which will not be repeated here.
[0088] In a seventh aspect, an image display apparatus is provided, the apparatus including a processing module and a display module, the processing module being configured to: determine a stretching dimension of the first image in response to a user's operation of stretching a first image along a first direction, the first image including deformable elements and non-deformable elements; the display module being configured to: display a second image, the second image having a target region including target pixels, the target pixels being pixels that are repeated by the deformable elements along the first direction, the target region having a dimension along the first direction equal to the stretching dimension, and the non-deformable elements being located outside the target region.
[0089] In conjunction with the seventh aspect, in some implementations of the seventh aspect, the first image further includes repeatable elements, and the display module is further configured to: display the repeatable elements in the target area when the first direction is the same as the arrangement direction of the repeatable elements.
[0090] In conjunction with the seventh aspect, in some implementations of the seventh aspect, before displaying the second image, the processing module is further configured to: in response to a first operation by the user, determine a first dividing line, wherein pixels on the first dividing line include the target pixel.
[0091] In conjunction with the seventh aspect, in some implementations of the seventh aspect, the pixels on the first dividing line do not include the pixels on the indeformable element.
[0092] In conjunction with the seventh aspect, in some implementations of the seventh aspect, the pixels on the first dividing line do not include the pixels of the repeatable element.
[0093] In conjunction with the seventh aspect, in some implementations of the seventh aspect, the indeformable element includes a first element, wherein the first dividing line is set within a preset range of the first element.
[0094] In conjunction with the seventh aspect, in some implementations of the seventh aspect, the processing module is further configured to: in response to a second operation by the user, determine a second dividing line, wherein the second dividing line and the first dividing line are located on opposite sides of the first element.
[0095] In conjunction with the seventh aspect, in some implementations of the seventh aspect, the non-deformable element further includes a second element, the second element and the first element are spaced apart along the first direction, the first element and the second element are located inside the deformable element, and the processing module is further configured to: in response to a second operation by the user, determine a second dividing line, the second dividing line being set within a preset range of the second element.
[0096] In conjunction with the seventh aspect, in some implementations of the seventh aspect, the target region further includes background pixels, the pixel values of which are filled according to the pixel values on the first dividing line.
[0097] In conjunction with the seventh aspect, in some implementations of the seventh aspect, the indeformable element includes a third element, the relative position of which on the first image is different from the relative position of which on the second image.
[0098] In conjunction with the seventh aspect, in some implementations of the seventh aspect, before displaying the second image, the display module is further configured to: display an intermediate image, the intermediate image including the first image and a first region, the first region being a region between the boundary of the first image and the boundary of the second image, the display color of the first region being of the same color family as the background color of the first image.
[0099] Eighthly, an image display apparatus is provided, the apparatus including a processing module configured to: determine a stretching direction and a stretching dimension of a first image; determine, based on the stretching direction, an element type comprising deformable elements and non-deformable elements in the first image; determine a stretching dividing line based on the element type of the first image and the stretching direction; determine a target region of a second image, the second image being a stretched image, based on the first image, the stretching direction, and the stretching dimension; and fill the target region with pixels along the stretching dividing line.
[0100] In conjunction with the eighth aspect, in some implementations of the eighth aspect, the element type further includes repeatable elements, and the processing module is further configured to: fill the target area with repeatable elements if the repeatable elements are located on both sides of the stretching dividing line.
[0101] In conjunction with the eighth aspect, in some implementations of the eighth aspect, before filling the target area with the repeatable element, the processing module is further configured to: remove the repeatable element from the first image; and fill the pixel value at the position corresponding to the repeatable element on the first image using the pixel mean value within a preset range surrounding the repeatable element.
[0102] In conjunction with the eighth aspect, in some implementations of the eighth aspect, the processing module is further configured to: determine the total number of repeatable elements to be filled in the second image based on the stretching size, the maximum distance between repeatable elements in the first image, and the spacing between adjacent repeatable elements; and determine the filling position of the repeatable elements in the second image based on the total number of repeatable elements, the position of the first repeatable element, and the spacing between adjacent repeatable elements.
[0103] In conjunction with the eighth aspect, in some implementations of the eighth aspect, the stretching dividing line does not overlap with the non-deformable element.
[0104] In conjunction with the eighth aspect, in some implementations of the eighth aspect, the processing module is further configured to: perform binarization processing on the first image to determine the binarized image corresponding to the first image; perform contour detection and line segment detection on the binarized image to determine the hierarchical elements of the first image; and classify each hierarchical element according to the stretching direction to determine the element type of each hierarchical element.
[0105] In conjunction with the eighth aspect, in some implementations of the eighth aspect, the hierarchical elements include first-level elements, and the processing module is further configured to: determine the first element as a repeatable element if the shape similarity, area intersection-union ratio, and distance of the first element and the second element of the first-level element all satisfy preset conditions; and determine the first element as a non-repeatable element if any one of the shape similarity, area intersection-union ratio, and distance of the first element and the second element of the first-level element does not satisfy the preset conditions.
[0106] In conjunction with the eighth aspect, in some implementations of the eighth aspect, when it is determined that the first element is a non-repeatable element, the processing module is further configured to: if it is determined that the first element is located in the deformable image library, then determine that the first element is a deformable element; if it is determined that the first element is not located in the deformable image library, then determine that the first element is a non-deformable element.
[0107] A ninth aspect provides an image display apparatus, the apparatus comprising a processing module and a display module, the processing module being configured to: determine a shrinkage size of the first image in response to a user's operation of shrinking a first image along a first direction, the first image comprising deformable elements and non-deformable elements, the first image comprising a target region and a non-target region, the target region comprising target pixels, the target pixels being pixels repeated by the deformable elements along the first direction, the shrinkage size of the target region along the first direction being equal to the shrinkage size, and the non-deformable elements being located outside the target region; the display module being configured to: display a second image, the second image comprising the non-target region.
[0108] In conjunction with the ninth aspect, in some implementations of the ninth aspect, the first image further includes a plurality of repeatable elements, and the target region includes at least one of the repeatable elements when the first direction is the same as the arrangement direction of the repeatable elements.
[0109] In conjunction with the ninth aspect, in some implementations of the ninth aspect, prior to displaying the second image, the processing module is further configured to: in response to a first operation by the user, determine a first dividing line, wherein pixels on the first dividing line include pixels repeated by the deformable element along the first direction.
[0110] In conjunction with the ninth aspect, in some implementations of the ninth aspect, the pixels on the first dividing line do not include the pixels on the indeformable element.
[0111] In conjunction with the ninth aspect, in some implementations of the ninth aspect, the pixels on the first dividing line do not include the pixels of the repeatable element.
[0112] In conjunction with the ninth aspect, in some implementations of the ninth aspect, the indeformable element includes a first element, wherein the first dividing line is set within a preset range of the first element.
[0113] In conjunction with the ninth aspect, in some implementations of the ninth aspect, the processing module is further configured to: in response to a second operation by the user, determine a second dividing line, wherein the second dividing line and the first dividing line are located on opposite sides of the first element.
[0114] In conjunction with the ninth aspect, in some implementations of the ninth aspect, the non-deformable element further includes a second element, the second element being spaced apart from the first element along the first direction, the first element and the second element being located inside the deformable element, and the processing module being further configured to: in response to a second operation by the user, determine a second dividing line, the second dividing line being set within a preset range of the second element.
[0115] In conjunction with the ninth aspect, in some implementations of the ninth aspect, the indeformable element includes a third element, the relative position of which on the first image is different from the relative position of which on the second image.
[0116] In a tenth aspect, an image display apparatus is provided, the apparatus including a processing module configured to: determine a shrinkage direction and a shrinkage size of a first image; determine, based on the shrinkage direction, an element type comprising deformable elements and non-deformable elements in the first image; determine a shrinkage dividing line based on the element type of the first image and the shrinkage direction; determine a target region of the first image based on the first image, the shrinkage direction, and the shrinkage size; and repeatedly delete pixels on the shrinkage dividing line to delete the target region.
[0117] In conjunction with the tenth aspect, in some implementations of the tenth aspect, the element type further includes repeatable elements, and the processing module is further configured to: if the repeatable elements are located on both sides of the shrinking dividing line, then delete the repeatable elements in the target area.
[0118] In conjunction with the tenth aspect, in some implementations of the tenth aspect, before repeatedly deleting pixels on the shrinking dividing line, the processing module is further configured to: remove the repeatable element from the first image; and fill the pixel value at the position corresponding to the repeatable element on the first image with the average pixel value within a preset range surrounding the repeatable element.
[0119] In conjunction with the tenth aspect, in some implementations of the tenth aspect, the processing module is further configured to: determine the total number of repeatable elements to be filled in the second image based on the shrinkage size, the maximum distance between repeatable elements in the first image, and the spacing between adjacent repeatable elements; and determine the filling position of the repeatable elements in the second image based on the total number of repeatable elements, the position of the first repeatable element, and the spacing between adjacent repeatable elements.
[0120] In conjunction with aspect ten, in some implementations of aspect ten, the contraction dividing line does not overlap with the non-deformable element.
[0121] In conjunction with the tenth aspect, in some implementations of the tenth aspect, the processing module is further configured to: perform binarization processing on the first image to determine the binarized image corresponding to the first image; perform contour detection and line segment detection on the binarized image to determine the hierarchical elements of the first image; and classify each hierarchical element according to the contraction direction to determine the element type of each hierarchical element.
[0122] In conjunction with the tenth aspect, in some implementations of the tenth aspect, the hierarchical elements include first-level elements, and the processing module is further configured to: determine the first element as a repeatable element if the shape similarity, area intersection-union ratio, and distance of the first element and the second element of the first-level element all satisfy preset conditions; and determine the first element as a non-repeatable element if any one of the shape similarity, area intersection-union ratio, and distance of the first element and the second element of the first-level element does not satisfy the preset conditions.
[0123] In conjunction with the tenth aspect, in some implementations of the tenth aspect, when it is determined that the first element is a non-repeatable element, the processing module is further configured to: if it is determined that the first element is located in the deformable image library, then determine that the first element is a deformable element; if it is determined that the first element is not located in the deformable image library, then determine that the first element is a non-deformable element.
[0124] Eleventhly, an image display apparatus is provided, the apparatus including a processing module and a display module, the processing module being configured to: determine a stretching dimension of the first image in response to a user's operation of stretching a first image along a first direction, the first image including repeatable elements; the display module being configured to: display a second image, the target area of the second image including the repeatable elements, the size of the target area along the first direction being equal to the stretching dimension.
[0125] In a twelfth aspect, an image display apparatus is provided, comprising a processing module and a display module, the processing module being configured to: determine a shrinkage size of the first image in response to a user's operation of shrinking a first image along a first direction, the first image including repeatable elements, the first image including a target region and a non-target region, the target region including at least one of the repeatable elements, the size of the target region along the first direction being equal to the shrinkage size; the display module being configured to: display a second image, the second image including the non-target region.
[0126] In a twelfth aspect, an electronic device is provided, comprising a memory and a processor, wherein the memory is used to store computer program code, and the processor is used to execute the computer program code stored in the memory to implement the method in the first aspect or any possible implementation of the first aspect, or to implement the method in the second aspect or any possible implementation of the second aspect, or to implement the method in the third aspect or any possible implementation of the third aspect, or to implement the method in the fourth aspect or any possible implementation of the fourth aspect, or to implement the method in the fifth aspect or any possible implementation of the fifth aspect, or to implement the method in the sixth aspect or any possible implementation of the sixth aspect.
[0127] In a thirteenth aspect, a computer-readable storage medium is provided, which stores a computer program or instructions that, when executed, implement the method of the first aspect or any possible implementation thereof, or implement the method of the second aspect or any possible implementation thereof, or implement the method of the third aspect or any possible implementation thereof, or implement the method of the fourth aspect or any possible implementation thereof, or implement the method of the fifth aspect or any possible implementation thereof, or implement the method of the sixth aspect or any possible implementation thereof.
[0128] In a fourteenth aspect, a chip is provided, wherein instructions are stored therein, which, when executed on a device, cause the chip to perform the method of the first aspect or any possible implementation thereof, or to perform the method of the second aspect or any possible implementation thereof, or to perform the method of the third aspect or any possible implementation thereof, or to implement the method of the fourth aspect or any possible implementation thereof, or to implement the method of the fifth aspect or any possible implementation thereof, or to implement the method of the sixth aspect or any possible implementation thereof.
[0129] In a fifteenth aspect, a computer program product is provided, which stores a computer program or instructions that, when executed, implement the method of the first aspect or any possible implementation thereof, or implement the method of the second aspect or any possible implementation thereof, or implement the method of the third aspect or any possible implementation thereof, or implement the method of the fourth aspect or any possible implementation thereof, or implement the method of the fifth aspect or any possible implementation thereof, or implement the method of the sixth aspect or any possible implementation thereof. Attached Figure Description
[0130] Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0131] Figure 2 This is a software structure block diagram of an electronic device provided in an embodiment of this application.
[0132] Figure 3 This is a schematic flowchart of an image stretching method provided in an embodiment of this application.
[0133] Figure 4 This is a schematic diagram of a graphical user interface of an electronic device provided in an embodiment of this application.
[0134] Figures 5 to 10 This is a schematic diagram of image stretching provided in an embodiment of this application.
[0135] Figures 11 to 16 This is a schematic diagram of the stretching dividing line provided in the embodiment of this application.
[0136] Figures 17 to 20 This is a schematic diagram of the graphical user interface of the electronic device provided in the embodiments of this application.
[0137] Figure 21 This is a schematic diagram of an image stretching or shrinking process provided in an embodiment of this application.
[0138] Figure 22 This is a schematic flowchart of another image stretching method provided in the embodiments of this application.
[0139] Figure 23 and Figure 24 This is a schematic flowchart of an image classification method provided in an embodiment of this application.
[0140] Figure 25 This is a schematic flowchart of another image stretching method provided in the embodiments of this application.
[0141] Figure 26 This is a schematic flowchart of an image shrinkage method provided in an embodiment of this application.
[0142] Figure 27 This is a schematic diagram of image shrinkage provided in an embodiment of this application.
[0143] Figure 28 This is a schematic diagram of a graphical user interface for another electronic device provided in an embodiment of this application.
[0144] Figure 29 and Figure 30This is a schematic flowchart of the image shrinkage method provided in the embodiments of this application.
[0145] Figure 31 This is a schematic diagram of an image display device provided in an embodiment of this application.
[0146] Figure 32 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0147] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "plural" or "multiple" refers to two or more than two.
[0148] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "a plurality of" means two or more.
[0149] The terminology used in the following embodiments is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to also include expressions such as “one or more,” unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, “at least one” and “one or more” refer to one, two, or more than two. The term “and / or” is used to describe the relationship between related objects, indicating that three relationships may exist; for example, A and / or B can indicate: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character “ / ” generally indicates that the preceding and following related objects are in an “or” relationship.
[0150] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "one embodiment," "some embodiments," "another embodiment," "other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0151] The image display method provided in this application can be applied to electronic devices such as mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), smart home devices, and large office screens. This application does not limit the specific type of electronic device; it can be controlled by touch or a mouse. When a user attempts to change the size and aspect ratio of an image by touching or dragging with a mouse, the system recognizes the direction and size of the drag and adaptively changes the image in real time to the target size, avoiding element deformation and distortion, and ensuring a visually appealing aesthetic.
[0152] For example, Figure 1A schematic diagram of the structure of electronic device 100 is shown. Electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0153] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0154] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0155] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0156] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0157] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0158] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.
[0159] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0160] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.
[0161] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, external memory, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0162] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0163] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.
[0164] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0165] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.
[0166] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0167] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0168] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0169] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0170] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0171] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimization of image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0172] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0173] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when electronic device 100 selects a frequency, the DSP can perform Fourier transforms on the frequency energy.
[0174] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. Thus, electronic device 100 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0175] An NPU (Neural Processing Unit) is a computational processor for neural networks (NNs). By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.
[0176] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0177] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0178] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0179] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0180] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.
[0181] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a telephone call or voice message, the receiver 170B can be brought close to the ear to listen to the voice.
[0182] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic device 100 may have at least one microphone 170C. In some embodiments, electronic device 100 may have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may also have three, four, or more microphones 170C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.
[0183] The 170D headphone jack is used to connect wired headphones. The 170D headphone jack can be a USB 130 interface or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.
[0184] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0185] Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can correspond to touch operations performed on different applications (such as taking photos, playing audio, etc.). Motor 191 can also correspond to different vibration feedback effects for touch operations performed on different areas of the display screen 194. Different application scenarios (such as time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also be customized.
[0186] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0187] The SIM card interface 195 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to make contact with and separate from the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 195 is also compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to realize functions such as calls and data communication. In some embodiments, the electronic device 100 uses an embedded SIM (eSIM) card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0188] It should be understood that the phone cards in the embodiments of this application include, but are not limited to, SIM cards, eSIM cards, universal subscriber identity modules (USIM), universal integrated circuit cards (UICC), etc.
[0189] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.
[0190] Figure 2This is a software structure block diagram of an electronic device 100 according to an embodiment of this application. The layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer. The application layer may include a series of application packages.
[0191] like Figure 2 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.
[0192] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0193] like Figure 2 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0194] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0195] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.
[0196] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0197] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0198] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0199] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0200] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0201] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0202] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0203] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0204] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0205] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0206] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0207] A 2D graphics engine is a graphics engine for 2D drawing.
[0208] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.
[0209] It should be understood that the technical solutions in the embodiments of this application can be used in systems such as Android, iOS, and HarmonyOS.
[0210] The technical solutions of this application can be applied to editing and creation scenarios that require image stretching or shrinking. For example, they can be applied to scenarios such as handwritten notes and presentation creation.
[0211] Among them, electronic devices can be televisions, large office screens, desktop computers, laptops, or portable electronic devices such as mobile phones, foldable screens, tablets, cameras, camcorders, and video recorders. They can also be smart home devices such as refrigerators, washing machines, robot vacuums, and any other electronic devices with image processing capabilities. They can also be electronic devices in 5G networks or in future evolved public land mobile networks (PLMNs).
[0212] Figure 3 This is a schematic flowchart illustrating an image stretching method provided in an embodiment of this application. Figure 3 As shown, the image stretching method 300 may include steps S310 to S330, and the image stretching method 300 may be applied to the electronic device 100.
[0213] S310, Obtain a first image, which may include deformable elements and non-deformable elements.
[0214] For example, the first image can be a sticker image that comes with the electronic device or a custom image imported by the user.
[0215] For example, such as Figure 4 As shown, Figure 4 A schematic diagram of a graphical user interface for an electronic device is shown. For example, when editing Note 1, a user can perform operations such as stretching or shrinking the loaded first image. The graphical interface of Note 1 may include a title bar A1, a toolbar A2, and a work area A3. The title bar A1 can be used to display the name of the current file, such as "Note 1". The toolbar A2 can be used to display function buttons that can be used for editing notes, such as a "Gallery" function button B1, a "Stickers" function button B2, and a "Zoom In" function button. The work area A3 can be used to display stickers or images acquired by the user.
[0216] In one example, in response to a user clicking the "Gallery" function button B1 in toolbar A2, multiple images from the gallery, including image 1, can be displayed on the electronic device's display interface; in response to a user selecting image 1, image 1 can be displayed on the electronic device's display interface.
[0217] In another example, in response to a user clicking the "Stickers" function button B2 in toolbar A2, multiple stickers, including sticker C1, can be displayed on the display interface of the electronic device; in response to a user selecting sticker C1, sticker C1 can be displayed on the display interface of the electronic device.
[0218] It should be understood that the first image may include deformable and non-deformable elements. Deformable elements are those whose size changes during image stretching or shrinking do not affect the displayed effect; examples of deformable elements include lines, rectangles, etc. Non-deformable elements are those whose size remains fixed during image stretching or shrinking and cannot be deformed or distorted; if the element deforms, it may affect the displayed effect; examples of non-deformable elements include special characters, symbols, fonts, patterns formed by certain arrangements and combinations, and patterns with special shapes.
[0219] For example, the first image may also include repeatable elements, which are elements that appear repeatedly in the first image. That is, elements that appear more than or equal to 2 times in the first image can be considered repeatable elements. For example, the first image may include multiple repeatable circles, lines, etc.
[0220] It should be noted that after acquiring the first image, it can be classified according to the image classification method provided in this application to determine the element types included in the first image. These element types can include repeatable elements, deformable elements, and non-deformable elements. The content of this image classification will be combined with the following... Figure 23 and Figure 24 Please provide a detailed explanation.
[0221] S320, stretch the first image along the first direction to determine the stretch size of the first image.
[0222] In some examples, the stretching dimension of the first image can be determined in response to a user's operation of stretching the first image along a first direction. For example, the stretching dimension can be determined based on the start and end positions of the first image. The first direction can be horizontal or vertical; that is, the first image can be stretched horizontally or vertically.
[0223] For example, such as Figure 5 As shown, the user can stretch the original image horizontally by a dimension of d1. The indeformable elements in the original image (such as a three-petal flower pattern) remain unchanged, and the relative positions of the indeformable elements in the stretched image are also unchanged from their relative positions in the original image. The deformable elements in the original image (such as straight lines) are stretched horizontally, and the total length of the horizontal stretch of the straight lines is d1.
[0224] In other examples, in response to a user clicking or long-pressing the first image, the display interface shows a first control, which includes options for image stretching size and / or image target size; in response to a user clicking the image stretching size and / or image target size options, the display interface shows a second control, which includes a checkbox for at least one of image horizontal stretching size, image vertical stretching size, and image target size; in response to a user entering a value in the checkbox, the electronic device can determine the stretching size of the first image.
[0225] It should be understood that during the stretching of the first image, the stretching size of the first image can be confirmed simultaneously, so that the stretched second image can be displayed simultaneously on the display interface of the electronic device.
[0226] S330, Display a second image. The target region of the second image includes target pixels, which are pixels that are repeated by deformable elements along a first direction. The size of the target region along the first direction is equal to the stretching size. The target region can be considered as the area added to the second image relative to the first image, and the non-deformable elements are located outside the target region.
[0227] It should be understood that during image stretching, deformable elements on the image are elongated, while non-deformable elements remain outside the target area and do not undergo deformation or distortion. The layout of the second image obtained through this method is consistent with that of the first image, avoiding issues such as layout chaos or disproportion.
[0228] In some examples, such as Figure 6 As shown in (a), the second image may include a target region, which may be a portion of the bottom of the second image. The second image is formed by stretching the first image downwards along a first direction. The target region on the second image may be a portion of the first image stretched downwards. The target region includes pixels of deformable elements (two rectangles) that repeat along the first direction, and non-deformable elements (the character REMNDER) located outside the target region.
[0229] In some examples, such as Figure 6 As shown in (b), the second image may include the target region (i.e. Figure 6The target region (the area between the dotted and dashed lines in (b)) can be located in the middle part of the second image. The target region can include target pixels, which can be repeating pixels of deformable elements (such as two rectangles) along the first direction, and non-deformable elements (such as the character REMNDER) are located outside the target region. That is to say, after stretching the first image using the stretching method of this application, the deformable elements in the first image are stretched, while the non-deformable elements in the first image maintain their original alignment without deformation or distortion. This allows the image layout to adapt to the aspect ratio of the image when stretching the first image, ensuring that the image layout is neat, harmonious, and aesthetically pleasing.
[0230] In other embodiments, the size of the target region along the first direction may not be equal to the stretching size, but rather proportional to it. For example, the first direction may not be a horizontal (lateral) or vertical (longitudinal) direction, but may form an angle with either the horizontal or vertical direction. In this case, the first direction can be decomposed into a first horizontal sub-direction and a second vertical sub-direction. The image stretching method provided in this application can be used to stretch the first sub-direction and the second sub-direction respectively, thereby transforming the oblique stretching into stretching in the horizontal sub-direction and stretching in the vertical sub-direction.
[0231] For example, before displaying the stretched second image, when performing a stretching operation on the first image, it is necessary to identify the stretching division line corresponding to the first image and stretch the first image based on the stretching division line.
[0232] like Figure 6 As shown in (b), the first image can be a sticker. The first image can include non-deformable elements (REMNDER) and deformable elements (two rectangles). Before stretching the first image, a stretching dividing line is determined. This stretching dividing line can be perpendicular to the stretching direction (i.e., the first direction, vertical). The portion of the first image above the stretching dividing line is the first part, and the portion below the stretching dividing line is the second part. After stretching the first image along the first direction to obtain the second image, the increased area of the second image relative to the first image can be the target area. This target area includes target pixels, which can be repeating pixels of the deformable elements along the first direction. In other words, when stretching downwards along the first direction, the newly added area can be filled by copying pixels from the stretching dividing line, increasing the length of the first image, but the overall layout of the resulting second image remains unchanged, resulting in a neat and harmonious layout.
[0233] For example, there can be multiple stretch divider lines, such as... Figure 7 As shown, when stretched laterally Figure 7When stretching the first image as shown, since the indeformable element REMNDER is centered and arranged along the first direction (horizontal), stretching the first image horizontally using conventional methods will cause the indeformable element REMNDER to deform and elongate, affecting aesthetics. When stretching the first image using the method of this application, stretching dividing lines (i.e., the first dividing line and the second dividing line) can be generated on both sides of the indeformable element. The first dividing line can be located to the left of the indeformable element REMNDER, and the second dividing line can be located to the right of the indeformable element REMNDER, dividing the first image into a first part, a second part, and a third part. When stretching the first image along the first direction (horizontal), the first part containing the indeformable element REMNDER will not deform. By copying pixels on the first dividing line to fill target area 1 and copying pixels on the second dividing line to fill target area 2, target area 1 and target area 2 form the aforementioned target area, increasing the width of the first image. However, the overall layout of the resulting second image remains unchanged, resulting in a neat and harmonious layout.
[0234] In some examples, where the first image includes repeatable elements, the method 300 may further include: displaying the repeatable elements in the target area if the first direction is the same as the arrangement direction of the repeatable elements.
[0235] For example, such as Figure 8 As shown, the first image can be Figure 4 The sticker C1 shown may include deformable elements (rounded rectangles and right rectangles), non-deformable elements (a list of characters "TO DO LIST" and "date _______"), and repeatable elements (circles and lines), with the repeatable elements arranged in the same direction as the first direction. During the stretching of the first image along the first direction, the non-deformable elements remain unchanged, maintaining their original alignment; the deformable elements change size and are stretched; the repeatable elements increase in number at equal intervals along the stretching direction, and the target area can display the repeatable elements.
[0236] For example, such as Figure 9As shown, the first image can be a sticker image for a password manager, used by users to record accounts and passwords. The first image can include deformable elements, non-deformable elements, and repeatable elements. The deformable elements include rectangles; the non-deformable elements include key icons, text password managers, accounts, passwords, characters, etc.; the repeatable elements include text accounts, passwords, same-sided rounded rectangles, horizontal line segments, vertical line segments, and dashed line segments. The repeatable elements are arranged in the same direction as the stretching direction (i.e., the first direction). Therefore, during the stretching of the first image along the first direction, the non-deformable elements remain unchanged, maintaining their original alignment; the deformable elements change size and are stretched; the repeatable elements increase in number at equal intervals along the stretching direction, and the target area can display the repeatable elements.
[0237] For example, such as Figure 10 (a) and Figure 10 As shown in (b), the first image can be an image composed of repeating elements. For example, the first image can be an aesthetically pleasing sticker image or artistic lines formed by a special arrangement of repeating elements. That is, the first image can only include repeating elements. The first image can be stretched along a first direction to form a second image. The target area (or newly added area) of the second image can display one or more sets of repeating elements. The repeating elements increase at equal intervals in the stretching direction. The number of repeating elements can be determined according to the stretching dimension and the size of the repeating elements.
[0238] It should be noted that during the image stretching process, the image can be stretched based on the stretching dividing line. This stretching dividing line can be generated by the electronic device based on preset rules, pre-configured in the background, or specified in real time by the user through gestures.
[0239] In some examples, the electronic device can determine the stretching division lines of the first image based on preset rules. These preset rules may include, for example, the following: starting from the middle of the first image, ignoring repeatable elements, and bypassing non-deformable elements on the first image; when passing through deformable elements, generally adjusting to the center line of the deformable element; if there are multiple non-deformable elements in the first image, multiple stretching division lines can be set, with the stretching division lines set within a preset range of the non-deformable elements. Furthermore, the pixels on the stretching division lines include the aforementioned target pixels, that is, the pixels on the stretching division lines include the pixels of the deformable elements that repeat along the first direction.
[0240] For example, such as Figure 11 As shown, the first image can be Figure 4The sticker C1 in the illustrated notes can be classified using the classification method provided in this application to determine the types of elements contained in sticker C1. Sticker C1 may include deformable elements (rounded rectangles and right-angled rectangles), non-deformable elements (character lists TO DO LIST and dates), and repeatable elements (circles and lines). When determining the stretchable dividing lines (including horizontal and vertical dividing lines), all types of elements on sticker C1 need to be considered comprehensively. For both horizontal and vertical dividing lines, non-deformable elements (lists TO DO LIST and dates) should be avoided, and repeatable elements should be ignored; at the same time, the midlines of rounded rectangles and right-angled rectangles can be selected to form stretchable dividing lines in different directions.
[0241] In other examples, the first image can be an image or sticker that comes with the electronic device, for example... Figure 4 In the note shown, sticker C1, for an image pre-stored by the electronic device, indicates that the stretching divider lines can be pre-configured in the background. That is, when the electronic device stores an image, it also simultaneously stores the positions of the horizontal and vertical stretching divider lines. For example, the electronic device's configuration file stores a sequence of coordinates for multiple points that make up the stretching divider lines.
[0242] For example, such as Figure 12 As shown, taking the rounded right arrow image as an example, the rounded right arrow image can be pre-stored in the electronic device. Simultaneously, the coordinate sequence values of the horizontal and vertical dividing lines can also be stored in the electronic device. During the horizontal stretching of the rounded right arrow image, pixels on the horizontal dividing lines can be copied to fill the target area or add a new area, increasing the horizontal length of the rounded right arrow image without deforming the rounded corners. Similarly, during the vertical stretching of the rounded right arrow image, pixels on the vertical dividing lines can be copied to fill the target area or add a new area, increasing the vertical length of the rounded right arrow image without deforming the rounded corners.
[0243] In some other examples, before displaying the second image, the method may further include: in response to a user's action of drawing a stretching dividing line, determining and displaying the stretching dividing line, wherein the pixels on the stretching dividing line include target pixels, i.e., the pixels on the stretching dividing line include pixels that are repeated by the deformable element along a first direction. It should be understood that a user can draw a stretching dividing line on the first image based on a gesture such as a touch swipe or a mouse click, read the coordinate information on the stretching dividing line, and stretch the image based on the stretching dividing line when stretching the image.
[0244] For example, pixels on the stretching dividing line may not include pixels on non-deformable elements. Similarly, pixels on the stretching dividing line may not include pixels on non-deformable elements or pixels on repeatable elements. This ensures that when stretching the first image based on the stretching dividing line, the deformable and repeatable elements on the first image do not deform, thus avoiding affecting the image layout of the stretched second image.
[0245] In one example, the stretchable dividing line may include a first dividing line. For instance, the first dividing line is determined in response to a first user action, which may be an action of drawing a dividing line. The first dividing line may be set close to a first element, which is an indeformable element on the first image, i.e., the first dividing line may be set within a preset range of the first element.
[0246] For example, such as Figure 13 As shown, in response to a user drawing a first dividing line on a first image, the position of the first dividing line on the first image can be displayed on the electronic device. After the first dividing line is determined, stretching the first image along a first direction (horizontal) can copy the pixels on the first dividing line to fill the target area, forming a second image.
[0247] In another example, the stretchable dividing line may include a first dividing line and a second dividing line, which are located on opposite sides of a first element, which is an indeformable element on a first image. For example, the first dividing line is determined in response to a first user action; the second dividing line is determined in response to a second user action; the first and second dividing lines may be located on opposite sides of the first element.
[0248] For example, such as Figure 14 As shown, the user can draw dividing lines 1 and 2 on both sides of the indeformable element of the first image. When the first image is stretched along the first direction (horizontal), the area on both sides of the indeformable element can be filled based on the pixels on dividing lines 1 and 2, so that the second image can be displayed on the electronic device.
[0249] For example, such as Figure 15 As shown, a user can draw multiple dividing lines on a first image, such as dividing line 1, dividing line 2, dividing line 3, and dividing line 4, to separate multiple non-deformable elements on the first image. When the first image is stretched along a first direction (horizontal), the areas on both sides of the multiple non-deformable elements can be filled based on the pixels on dividing line 1, dividing line 2, dividing line 3, and dividing line 4, so that a second image stretched horizontally can be displayed on an electronic device.
[0250] In yet another example, the non-deformable elements on the first image include a first element and a second element, the second element being spaced apart from the first element along the first direction, the first element and the second element being located inside the deformable element, the method further comprising: in response to a first operation by a user, determining a first dividing line, the first dividing line being close to the first element, i.e., the first dividing line being set within a preset range of the first element; and in response to a second operation by a user, determining a second dividing line, the second dividing line being close to the second element, i.e., the second dividing line being set within a preset range of the second element.
[0251] For example, such as Figure 16 As shown, the horizontal dividing lines on the first image may include two lines, one of which can be set close to the first element (e.g., review target), and the other line can be set close to the second element (e.g., evaluation result). The vertical dividing lines on the first image may include two lines, which can be located on either side of the first element (e.g., analyzing causes) or the second element (e.g. summarizing experience).
[0252] It should be understood that in some embodiments, the positions of the indeformable elements on the first image may remain unchanged or change. For example, the position of the first element may remain unchanged, while the position of the second element may change from the first position to the second position. For example, ... Figure 16 As shown, when the first image is stretched horizontally, the relative positions of the characters REPLAY, Review Goals, and Analyze Reasons remain unchanged, while the relative positions of the characters Date, Evaluation Results, and Summary of Experience change, all shifting to the right. When the first image is stretched vertically, the relative positions of the characters REPLAY, Date, Review Goals, and Evaluation Results remain unchanged, while the relative positions of the characters Analyze Reasons and Summary of Experience change, all shifting downwards.
[0253] In some examples, the target region also includes background pixels, the pixel values of which are filled based on the pixel values along the stretched dividing lines. For example, such as... Figure 16 As shown, the background of the right-angled rectangle is a shadow-filled area, while the background of the rounded rectangle is a white-filled area. The background of the rounded rectangle partially covers the right-angled rectangle. After image stretching, the pixel values of the background pixels in the target area are filled according to the pixel values on the stretching dividing lines, thus making the stretched image consistent with the background of the first image.
[0254] In some examples, before displaying the second image, the method 300 further includes: displaying the first image and a first region, the first region being the area between the boundary of the first image and the boundary of the second image, the display color of the first region being of the same color family as the background color of the first image.
[0255] For example, such as Figure 17 As shown, in response to a user clicking on the first image, a drag box is displayed at the border of the first image. Dragging the drag box allows the first image to be stretched or shortened horizontally, vertically, or proportionally enlarged or reduced. Considering the varying performance of electronic devices, in some examples, in response to the user dragging the right edge of the drag box along a first direction (horizontally), an intermediate image can be displayed on the electronic device. This intermediate image includes the first image and a first region. The first region is the area between the boundary of the first image and the boundary of the second image, and the display color of the first region belongs to the same color family as the background color of the first image. For example, the first region can be filled with the background color of the first image with 30% transparency. Furthermore, the first region can be filled using the above method, ultimately displaying the stretched second image. The second image is horizontally stretched relative to the first image, but the non-deformable elements in the second image remain undeformed, resulting in a neat and aesthetically pleasing layout.
[0256] In some examples, in response to a user clicking on the first image, a drag box is displayed within a preset area of the outer border (outer contour) of the first image. Dragging the drag box allows the first image to be scaled up or down proportionally. For example... Figure 18 As shown, in response to the user dragging the four corner points of the drag box outwards ( Figure 18 The second image is obtained by scaling up the first image by displaying any corner point of the black dots shown in the image.
[0257] In some examples, in response to a user clicking on the first image, a draggable box is displayed within a preset area of the outer border (outer contour) of the first image. Dragging the draggable box allows the first image to be stretched or shortened horizontally. For example... Figure 19 As shown, in response to the user dragging the left and right midpoints of the drag box along a first direction (horizontal), Figure 19 The second image is obtained by horizontally stretching the first image, with any one of the black dots shown in the image as the midpoint.
[0258] In some examples, in response to a user clicking on the first image, a draggable box is displayed within a preset range of the outer border (outer contour) of the first image. Dragging the draggable box allows the first image to be stretched or shortened vertically. For example... Figure 20 As shown, in response to the user dragging the upper and lower midpoints of the drag box along a first direction (vertical), Figure 20 The second image is obtained by vertically stretching the first image, with the midpoint of any of the black dots shown in the image as an example.
[0259] It should be understood that when a user changes the size and aspect ratio of the first image by touching or dragging with a mouse, the electronic device can recognize the direction and size of the user's drag and adapt the image in real time to make it the target size, avoiding element deformation and distortion, and ensuring visual aesthetics.
[0260] For example, such as Figure 21 As shown, during the stretching or shrinking of the image, the elements on the image will not be deformed or distorted, and the overall design and layout of the image will not change. During the transformation from image 1 to image 6, image stretching or shrinking operations can be performed, but the size of the stretched / shrunken image is still larger than the size of the original image (i.e., image 1). Specifically: Based on image 1, by ① dragging the four corner points of the bounding box outwards, the image can be proportionally enlarged to obtain image 2, which is larger than image 1; based on image 2, by ② dragging the left and right midpoints of the bounding box outwards, the image can be horizontally stretched to obtain image 3, which is larger than both image 2 and image 1; based on image 3, by ③ dragging the top and bottom midpoints of the bounding box outwards, the image can be vertically stretched to obtain image 4, which is larger than all three images (image 3, image 2, and image 1); based on image 4, by ④ dragging the left and right midpoints of the bounding box inwards, the image can be horizontally shrunk to obtain image 5, which is smaller than image 4 but larger than image 1; based on image 5, by ⑤ dragging the top and bottom midpoints of the bounding box inwards, the image can be vertically shrunk to obtain image 6, which is smaller than image 5 but larger than image 1.
[0261] It should be noted that the image stretching method provided in this application embodiment can achieve proportional enlargement, horizontal stretching, and vertical stretching of images, so that the stretched image can maintain its original layout and alignment without causing element distortion, ensuring that the element layout is consistent with the original. Figure 1 Furthermore, for repeatable elements in the image, they can be adaptively added according to the arrangement pattern of the repeatable elements, so that the image layout can adapt to changes in the image's aspect ratio.
[0262] Figure 22 This is a schematic flowchart illustrating an image stretching method provided in an embodiment of this application. The image stretching method 500 may include steps S510 to S550.
[0263] S510, determine the stretching direction and stretching dimension of the first image.
[0264] For example, when a user stretches the first image, the electronic device can detect the stretching direction and the stretching size of the first image.
[0265] The details of this step can be found in the relevant description in S320, and will not be repeated here.
[0266] S520, determine the element types included in the first image based on the stretching direction.
[0267] For example, after the electronic device acquires the first image, it can perform hierarchical classification processing on the elements included in the first image based on the stretching direction to determine the element types included in the first image. The element types can include non-deformable elements and deformable elements. In some examples, the first image can also include repeatable elements, and the element type can also include repeatable elements. The relevant content of the first image can be found in S310, and will not be repeated here.
[0268] In some examples, elements can be categorized through manual annotation. For instance, various attributes of elements in the first image can be pre-annotated, mainly including: the coordinates of the contour points around the first image, the element type (divided into deformable elements, non-deformable elements, and repeatable elements), and the contour level. The contour level can be understood as the element hierarchy.
[0269] For example, such as Figure 8 In the first image shown, the outermost right-angled rectangle belongs to the first contour level (or first element level); the text inside the right-angled rectangle (i.e., the list "TO DO LIST" and the date "_____") and the rounded rectangle belong to the second contour level (or second element level); the innermost black circle and line belong to the third contour level (or third element level). When the first image is stretched horizontally, the right-angled rectangle is a deformable element, the list "TO DO LIST" and the date "_____" are non-deformable elements, the rounded rectangle is a deformable element, the black circle is a repeatable element, and the line is a deformable element. When the first image is stretched vertically, the right-angled rectangle is a deformable element, the list "TO DOLIST" and the date "_____" are non-deformable elements, and the black circle and line are repeatable elements.
[0270] For example, such as Figure 9In the first image shown, the outermost right-angled rectangle belongs to the first contour level (or first element level); the key pattern, text password manager, characters, etc., the rounded rectangles on the same side, and the dashed line segments belong to the second contour level (or second element level); the innermost account, password, horizontal line segments, and vertical line segments belong to the third contour level (or third element level). When the stretching direction of the first image is horizontal, the key pattern, text password manager, characters, etc., account, and password are non-deformable elements, while the rounded rectangles on the same side, the dashed line segments, and the horizontal line segments are deformable elements. When the stretching direction of the first image is vertical, the right-angled rectangle is a deformable element, the key pattern, text password manager, characters, etc. are non-deformable elements, and the whole formed by the rounded rectangles on the same side and the dashed line segments are repeatable elements.
[0271] In other examples, when determining the element types included in the first image, the image classification method 600 provided in this application can be used. This classification method 600 may include steps S610 to S640, the details of which will be discussed below. Figure 23 and Figure 24 Please provide an explanation.
[0272] S530, determine the stretching division line based on the element type and stretching direction of the first image.
[0273] In this step, the stretching division line can be determined based on the element type and stretching direction of the first image obtained in S520.
[0274] It should be understood that the stretch dividing line can be generated by the electronic device based on preset rules, or it can be pre-configured in the background, or it can be specified by the user in real time through gestures.
[0275] For example, starting from the middle of the first image, repeatable elements are ignored, and the process bypasses the non-deformable elements in the first image. When passing through deformable elements, the process is generally adjusted to the center line of the deformable element. If there are multiple non-deformable elements in the first image, multiple stretching dividing lines can be set, and the stretching dividing lines are set within a preset range of the non-deformable elements. Furthermore, the pixels on the stretching dividing lines include the pixels of the deformable elements that are repeated along the stretching direction.
[0276] This step can be found in the description of stretching the dividing line in S330, and will not be repeated here.
[0277] S540, determine the target area based on the first image, the stretching direction, and the stretching dimension.
[0278] The target region may be located on the second image, and its size along the stretching direction is equal to the stretching size of the first image. It should be understood that the specific details regarding the target region can be found in the relevant description of the target region in S330, and will not be repeated here.
[0279] S550 fills the target area based on the pixels on the stretching dividing line.
[0280] In this step, the pixel values on the dividing line can be repeatedly stretched to fill the target area, thus obtaining the stretched second image.
[0281] In some examples, the method 500 may further include: if the repeatable element is located on both sides of the stretch dividing line, then the repeatable element also needs to be added to fill the target area.
[0282] It should be understood that the specific details of this step will be provided in conjunction with the appendix. Figure 25 Please provide a detailed explanation.
[0283] Figure 23 This is a schematic flowchart illustrating an image classification method provided in an embodiment of this application. The image classification method 600 may include steps S610 to S640.
[0284] S610, acquire the first image.
[0285] The details of this step can be found in the relevant description in S310, and will not be repeated here.
[0286] S620, perform binarization processing on the first image to determine the binarized image.
[0287] In this step, the first image can be binarized to determine a binarized image, which is generally an image with only two colors (usually black and white). The specific process of binarization can be found in existing technologies.
[0288] S630 performs contour detection and line segment detection on the binarized image to determine the hierarchical elements of the first image.
[0289] In this step, contour detection and line segment detection can be performed on the binarized image to obtain the hierarchical elements of the first image. That is, the first image can be hierarchically divided, for example, as... Figure 8 The first image shown has an outermost right-angled rectangle belonging to the first outline level (or the first element level, the bottommost element level); the text inside the right-angled rectangle (i.e., the list TO DO LIST and the date _____) and the rounded rectangle belong to the second outline level (or the second element level, the middle element level); and the innermost black circle and straight line belong to the third outline level (or the third element level, the topmost element level).
[0290] S640, according to the stretching direction, classify the elements of each level and determine the element type of each level.
[0291] It should be understood that each level of the first image may include multiple different types of elements, such as repeatable elements, deformable elements, and non-deformable elements. Therefore, it is necessary to classify the elements included in each level of the first image and determine the element type of each level.
[0292] For example, such as Figure 24 As shown, step S640 may specifically include:
[0293] S641, Input the first element of the first level element. This first element can be any element in the first level element.
[0294] S642, calculate the shape similarity between the first element and other elements, calculate the area intersection-union ratio between the first element and other elements, and calculate the distance between the average color vector within the first element and the average color vector of other elements.
[0295] The specific calculation methods for shape similarity, area intersection-union ratio, and distance of average color vectors can be found in existing technologies and will not be described in detail here.
[0296] S643, if the shape similarity, area intersection-union ratio, and distance of the average color vector of the first element all meet the preset thresholds, then the first element is determined to be a repeatable element. Otherwise, the first element is determined to be a non-repeatable element.
[0297] It should be understood that shape similarity can be used to characterize the shape similarity relationship between the first element and other elements (such as the second element), area intersection-union ratio can be used to characterize the area size relationship between the first element and other elements (such as the second element), and the distance of the average color vector can be used to characterize the color similarity relationship between the first element and other elements (such as the second element).
[0298] If the shape similarity between the first element and other elements (such as the second element) is greater than the first threshold, then the shape of the first element and other elements can be considered to be approximately the same; if the area intersection-union ratio of the first element and other elements (such as the second element) is greater than the second threshold, then the area of the first element and other elements can be considered to be approximately equal; if the distance between the average color vector of the first element and other elements (such as the second element) is less than the third threshold, then the color of the first element and other elements can be considered to be approximately the same.
[0299] Generally, if the first element and the second element have approximately the same shape, area, and color, then the first element and the second element can be considered as identical repeatable elements. Otherwise, the first element is determined to be a non-repeating element, meaning that the first element differs from other elements in shape, area, or color.
[0300] It should be understood that in the embodiments of this application, the shape similarity, area intersection-union ratio, and average color vector distance are mainly used as parameters to determine the shape, area, and color relationship between the first element and the second element. However, this application is not limited to this. That is, in some other embodiments, other parameters that characterize the shape, area, and color similarity can be used to determine whether two elements are the same.
[0301] Furthermore, after identifying the repeatable elements on the first image, the repeatable elements can be further grouped according to equal rows and equal intervals or equal columns and equal intervals.
[0302] S644, if the first element is determined to be a non-repeatable element, then it is further determined whether the first element is located in the deformable image library. If the first element is located in the deformable image library, then the first element is determined to be a deformable element; otherwise, the first element is determined to be a non-deformable element.
[0303] It should be understood that repeatable and non-repeatable elements on the first image can be determined through S643. Furthermore, based on the deformable image library, it can be determined whether the first element belongs to the deformable element. If the first element is located in the deformable image library, it means that the first element belongs to the deformable element; otherwise, the first element is confirmed to be a non-deformable element.
[0304] For example, the deformable graphics library may include multiple deformable image templates. That is, the first element can be matched with the deformable image templates in the deformable graphics library. If a match is found, the first element is a deformable element; if a match is not found, the first element is a non-deformable element.
[0305] Figure 25 This is a schematic flowchart of another image stretching method provided in an embodiment of this application. The image stretching method 700 may include steps 701 to 714.
[0306] S701, obtain the first image, the element types included in the first image, the stretching size of the first image, and the stretching direction.
[0307] S702, determine n stretching division lines (n≥1) based on the first image, the element types included in the first image, and the stretching direction of the first image.
[0308] S703, determine if a stretching dividing line exists in the stretching direction. If it exists, continue to S704; otherwise, exit the process.
[0309] S704, determine whether repeatable elements are located on both sides of the stretch divider.
[0310] If the repeatable element is not located on both sides of the stretch dividing line, execute S705 to S707; if the repeatable element is located on both sides of the stretch dividing line, execute S706 to S710.
[0311] When repeatable elements are not located on either side of the stretch divider, the following steps can be performed:
[0312] S705, determine the target area based on the first image and the stretching dimensions.
[0313] S706: Copy the pixels on the stretching dividing line and fill the target area.
[0314] In this step, the target width to be filled for each dividing line can be calculated by dividing the total fill width by the number of dividing lines. Then, the pixels on the dividing lines are copied and filled according to the target width.
[0315] S707, Display a second image that includes the target area.
[0316] It should be understood that when repeatable elements are not located on both sides of the stretching dividing line, pixel filling of the target area of the second image can be achieved by repeatedly copying pixels on the stretching dividing line.
[0317] When repeatable elements are located on both sides of the stretchable dividing line, the following steps can be performed:
[0318] S708, Remove repeatable elements from the first image.
[0319] It should be understood that this step primarily involves extracting repeatable elements from the first image. These repeatable elements are the lowest-level repeating elements distributed on both sides of the segmentation line. For example, such as... Figure 8 As shown, the bottommost repeating elements are the innermost black circle and the line segment; that is, the repeating elements are the black circle and the line segment. For example, as... Figure 9 As shown, the bottommost repeating element is the second element level, which is the rounded rectangle on the same side and the content inside the rectangle. In other words, what is repeated is the rounded rectangle on the same side and the content inside the rectangle.
[0320] S709, use the average pixel value within a preset range surrounding the repeatable element to fill the pixel value at the position corresponding to the repeatable element on the first image.
[0321] It should be understood that after the repeatable element is removed from the first image, there will be holes in the first image that need to be filled. In some examples, the average pixel value within a preset range around the repeatable element can be used to fill the holes and repair the background of the first image.
[0322] S710 determines the target area based on the first image and the stretching dimensions.
[0323] S711, copy the pixels on the stretching dividing line and fill the target area.
[0324] S712, determine the number and position of all repeatable elements based on the stretching dimension, the maximum distance between repeatable elements, the spacing between adjacent repeatable elements, and the position of the first repeatable element.
[0325] In this step, firstly, the total number of repeatable elements to be filled on the stretched image can be determined based on the stretch size, the maximum distance between repeatable elements (i.e., the distance between the first and last repeatable elements), and the spacing between adjacent repeatable elements; then, starting from the position of the first repeatable element, the filling is performed sequentially according to the spacing between repeatable elements to determine the position of all repeatable elements.
[0326] In other words, repeatable elements can be increased at equal intervals in the stretching direction, and repeatable elements can be filled in the corresponding positions of the target area and other areas of the second image.
[0327] S713, fill the target area and other areas of the second image with repeatable elements.
[0328] S714, Display a second image that includes the target area.
[0329] It should be understood that when repeatable elements are located on both sides of the stretching dividing line, all repeatable elements need to be removed from the first image first, and the background holes of the first image need to be repaired; then, the pixels on the stretching dividing line are repeatedly copied to fill the target area of the second image; finally, based on the total number of repeatable elements on the second image and the spacing between the repeatable elements, starting from the first repeatable element, the repeatable elements are filled in sequence, and the target area of the second image will also be filled with corresponding repeatable elements.
[0330] It should be noted that any parts of the above steps not explained in detail can be found by referring to [the relevant documentation / reference]. Figure 3 , Figures 22 to 24 The content in the document will not be repeated here.
[0331] The image stretching method provided in this application embodiment can display stretched images on electronic devices in real time without requiring complex calculations, resulting in fast and efficient image processing. Furthermore, it can achieve proportional enlargement, horizontal stretching, and vertical stretching of images, ensuring that the stretched image maintains its original layout and alignment without causing distortion or deformation of elements, thus guaranteeing the element layout matches the original. Figure 1Furthermore, for repeatable elements in an image, they can be adaptively added according to the arrangement pattern of the repeatable elements, so that the image layout can adapt to changes in the image's aspect ratio.
[0332] Figure 26 This is a schematic flowchart illustrating an image shrinkage method provided in an embodiment of this application. Figure 26 As shown, the image shrinking method 400 may include steps S410 to S430, and the image shrinking method 400 can be applied to electronic devices.
[0333] S410, Obtain a first image, which may include deformable elements and non-deformable elements.
[0334] The first image may include a target region and a non-target region. The target region may be a contracted region on the first image. The target region includes target pixels, which are pixels that repeat along a first direction, where the first direction is the direction of image contraction. The non-deformable element is located outside the target region.
[0335] In some examples, such as Figure 27 As shown in (a), the target region can be a portion of the bottom of the first image, and the non-target region is the area of the first image other than the target region. The first image is compressed upward along a first direction to form a second image. The target region of the first image can be the portion of the first image shortened relative to the second image. The target region includes pixels of deformable elements (two rectangles) that repeat along the first direction, and non-deformable elements (the character REMNDER) located outside the target region.
[0336] In other examples, such as Figure 27 As shown in (b), the target region can be located in the middle part of the first image, and the non-target region is the region of the first image other than the target region, that is, the non-target region includes the first part and the second part. For example, when performing a shrinkage operation on the first image along the first direction, it is necessary to identify the first dividing line corresponding to the first image and shrink the first image based on the first dividing line, that is, repeatedly delete the pixels on the first dividing line, so that the target region of the first image is deleted, and the resulting second image does not include the target region, that is, the second image includes the non-target region.
[0337] It should be understood that other parts of the first image can be referred to in the relevant description in S310, and will not be repeated here.
[0338] S420, Perform a shrinkage operation on the first image along the first direction to determine the shrinkage size of the first image.
[0339] The shrinkage size of the first image can be equal to the shrinkage size of the target region on the first image along the first direction. In other words, the second image can be obtained by deleting the target region on the first image.
[0340] It should be understood that the contraction operation in this step is the reverse of the stretching operation in S320. The content of this step can be similarly referred to in the description of S320, and will not be repeated here.
[0341] S430, Display a second image. The second image includes the non-target area from the first image.
[0342] It should be understood that the second image is the image obtained after shrinking the first image. The size of the second image is smaller than that of the first image. The second image is the image after deleting the target region from the first image, meaning that the second image includes the non-target region of the first image. In other words, by repeatedly deleting deformable elements on the first image along the first direction (shrinkage direction), the purpose of shortening the first image can be achieved.
[0343] In some examples, the first image further includes multiple repeatable elements, and the method 400 may further include: when the first direction is the same as the arrangement direction of the repeatable elements, the target region includes at least one repeatable element. That is, at least one repeatable element can be deleted from the first image along the first direction, i.e., at least one repeatable element included in the target region is deleted, thereby reducing the number of repeatable elements on the second image.
[0344] Understandably, when shrinking the first image, the number of repeatable elements can be reduced, while the number of deformable and non-deformable elements remains unchanged, the shape of non-deformable elements remains unchanged, and the space occupied by deformable elements can be reduced. During image shrinking, element overlap is not allowed; that is, if the distance between two elements is less than a preset range, further image shrinking is not supported.
[0345] For example, in response to a user clicking on the first image, a drag box will be displayed at the border of the first image. By dragging the drag box, the first image can be shortened horizontally, shortened vertically, or reduced proportionally. Figure 28 As shown, in response to a user clicking on the first image, a draggable box will be displayed within a preset range of the outer border (outer contour) of the first image. Dragging the draggable box allows the first image to be shortened vertically. In response to the user dragging the upper and lower midpoints of the draggable box along a first direction (vertical),... Figure 28The second image is displayed at any midpoint of the black dots shown in the diagram. The second image is obtained by vertically shortening the first image. Furthermore, when the minimum shrinkage size is reached, the display interface of the electronic device can pop up a prompt box. For example, the prompt box may display a message such as "Please note that the image shrinkage has reached the minimum shrinkage size," indicating to the user that the currently displayed second image is the image with the smallest shrinkage size corresponding to the first image and cannot be further shrunk.
[0346] It should be understood that the minimum shrinkage size can be determined based on the following: the number of repeatable elements in the second image reaches a minimum, the distance between elements in the second image is less than a preset distance, and the minimum shrinkage size cannot be greater than the size of the deformable element, etc.
[0347] It should also be understood that when a user changes the size and aspect ratio of the first image by touching or dragging with a mouse, the electronic device can recognize the direction and size of the user's drag and adapt the image in real time to make it the target size, avoiding element deformation and distortion, and ensuring visual aesthetics.
[0348] It should be noted that the image shrinking method provided in this application embodiment can achieve proportional reduction, horizontal shrinking, and vertical shrinking of images, so that the shrunk image can maintain its original layout and alignment, without causing distortion of elements, and ensuring that the element layout is consistent with the original. Figure 1 Furthermore, for repeatable elements in an image, their size can be adaptively reduced according to the arrangement pattern of the repeatable elements, allowing the image layout to adapt to changes in the image's aspect ratio.
[0349] Figure 29 This is a schematic flowchart of another image shrinking method provided in an embodiment of this application. The image shrinking method 800 may include steps S810 to S850.
[0350] S810, determine the shrinkage direction and shrinkage size of the first image.
[0351] The details for this step can be found above. Figure 28 The descriptions of shrinkage direction and shrinkage size in the text will not be repeated here.
[0352] S820, determine the element type of the first image based on the shrinkage direction.
[0353] The details of this step can be found in the relevant description in S520, and will not be repeated here.
[0354] S830, determine the shrinkage dividing line based on the element type and shrinkage direction of the first image.
[0355] In this step, the shrinkage dividing line can be determined based on the element type and shrinkage direction of the first image obtained in S810.
[0356] It should be understood that the shrinking dividing line can be generated by the electronic device based on preset rules, or it can be pre-configured in the background, or it can be specified by the user in real time through gestures.
[0357] For example, starting from the middle of the first image, repeatable elements are ignored, and the process bypasses the non-deformable elements in the first image. When passing through deformable elements, the process is generally adjusted to the center line of the deformable element. If there are multiple non-deformable elements in the first image, multiple contraction dividing lines can be set, and these lines are set within a preset range of the non-deformable elements. Furthermore, the pixels on the contraction dividing lines include the pixels of the deformable elements that are repeated along the contraction direction.
[0358] This step can be found in the description of the dividing line in S330, and will not be repeated here.
[0359] S840 determines the target area based on the first image, the shrinkage direction, and the shrinkage size.
[0360] The target region can be located on the first image (i.e., the original image), and the size of the target region along the shrinkage direction is equal to the shrinkage size of the first image. It should be understood that the specific details regarding the target region can be found in the relevant description of the target region in S410, and will not be repeated here.
[0361] S880 deletes the target region based on the pixels on the shrinking dividing line.
[0362] In this step, the pixel values on the shrinking dividing line are repeatedly deleted to achieve the purpose of deleting the target area, thereby obtaining the shrunken second image.
[0363] In some examples, the method 800 may further include: deleting the repeatable element on the target region if the repeatable element is located on both sides of the shrinkage dividing line.
[0364] It should be understood that the specific details of this step will be provided in conjunction with the appendix. Figure 29 Please provide a detailed explanation.
[0365] Figure 30 This is a schematic flowchart of another image shrinkage method provided in the embodiments of this application.
[0366] It should be noted that, compared to the image stretching method 700 described above, the image shrinking method 900 mainly changes the stretching process into a shrinking process, thus modifying... Figure 25 S706 and S713 in the series. Figure 24The process of stretching the image shown mainly involves copying pixel values along the segmentation lines and adding repeatable pixels to the target area. Figure 30 In the process of shrinking an image, the main steps are to delete pixel values along the segmentation lines and to remove duplicate pixels in the target region. The following mainly explains the differences between the two methods; for details not covered, please refer to the above. Figure 25 and Figure 26 Related descriptions.
[0367] The image shrinkage method 900 may include S901 to S914.
[0368] S901, obtain the first image, the element types included in the first image, the shrinkage size of the first image, and the shrinkage direction.
[0369] It should be noted that the shrinkage size should be greater than or equal to the minimum shrinkage size mentioned above.
[0370] It should be understood that when shrinking the first image, the number of repeatable elements on the first image can be reduced, the number of deformable and non-deformable elements remains unchanged, the shape of the non-deformable elements remains unchanged, and the space occupied by the deformable elements can be reduced. During the image shrinking process, element overlap is not allowed; that is, when the distance between two elements is less than a preset range, further image shrinking is not supported.
[0371] S902, determine n contraction dividing lines (n≥1) based on the first image, the element types included in the first image, and the contraction direction of the first image.
[0372] S903, determine if a contraction dividing line exists in the contraction direction. If it exists, continue to execute S904.
[0373] S904 determines whether repeatable elements are located on both sides of the contraction dividing line.
[0374] If the repeatable element is not located on either side of the contraction dividing line, then execute S905 to S909; if the repeatable element is located on either side of the contraction dividing line, then execute S906 to S910.
[0375] When the repeatable element is not located on either side of the contraction line, the following steps can be performed:
[0376] S905, determine the target region based on the first image and the shrinkage size. This target region can be referenced. Figure 26 The relevant description in the document.
[0377] S906, Repeatedly delete pixels on the shrinking dividing line to delete the target region of the first image.
[0378] S907, Display the second image. The size of the second image is smaller than the size of the first image.
[0379] In other words, when repeatable elements are not located on both sides of the stretching dividing line, the target region can be deleted by repeatedly deleting pixels on the stretching dividing line, so that the second image obtained does not include the target region.
[0380] When repeatable elements are located on both sides of the contraction line, the following steps can be performed:
[0381] S908, Remove repeatable elements from the first image.
[0382] S909, use the average pixel value within a preset range around the repeating element to fill the pixel value at the position corresponding to the repeating element on the first image.
[0383] S910, determine the target area based on the first image and the shrinkage size.
[0384] S911, Repeatedly delete pixels on the shrinking dividing line to delete the target region of the first image.
[0385] S912, based on the shrinkage size, the maximum distance between repeatable elements, the spacing between adjacent repeatable elements, and the position of the first repeatable element, determine the number and position of all repeatable elements.
[0386] In this step, firstly, the total number of repeating elements to be filled on the shrunken image can be determined based on the shrinkage size, the maximum distance between repeating elements (i.e., the distance between the first and last repeating elements), and the spacing between adjacent repeating elements. Then, starting from the position of the first repeating element, the filling is performed sequentially according to the spacing between repeating elements to determine the positions of all repeating elements. It should be understood that the number of repeating elements on the second image is the number of repeating elements on the first image minus the number of reduced repeating elements.
[0387] S913, fill the second image with repeatable elements.
[0388] It should be understood that the total number of repeatable elements that need to be filled in the shrunk image (i.e., the second image) is less than the total number of repeatable elements in the unshrunk image (i.e., the first image). In other words, the reduced number of repeatable elements is the same as the number of repeatable elements in the target region of the first image.
[0389] S914, Display the second image. The size of the second image is smaller than the size of the first image.
[0390] In other words, when repeatable elements are located on both sides of the shrinking dividing line, all repeatable elements need to be removed from the first image first, and the background holes of the first image need to be repaired; then, the target area of the first image is deleted by repeatedly deleting pixels on the shrinking dividing line; finally, based on the total number of repeatable elements and the spacing between repeatable elements on the second image, the repeatable elements are filled in sequentially, starting from the first repeatable element. That is to say, the repeatable elements of the target area of the first image have been deleted.
[0391] The image shrinking method provided in this application embodiment can display the shrunk image on an electronic device in real time without requiring highly complex calculations, resulting in fast and efficient image processing. Furthermore, it can achieve proportional enlargement, horizontal shrinking, and vertical shrinking of images, ensuring that the shrunk image maintains its original layout and alignment without causing distortion or deformation of elements, thus guaranteeing the element layout matches the original. Figure 1 Furthermore, for repeatable elements in an image, they can be adaptively added according to the arrangement pattern of the repeatable elements, so that the image layout can adapt to changes in the image's aspect ratio.
[0392] The above combination Figures 3 to 30 The image display method provided in this application is described in detail. The image display method may include the image stretching method and the image shrinking method described above.
[0393] Figure 31 This application provides another illustrated device 1000. This device 1000 may possess the functions of the electronic device in the above-described method embodiments and can be used to execute the steps performed by the electronic device in the above-described method embodiments. This function can be implemented in hardware, or in software, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above-described functions.
[0394] In one possible implementation, the device 1000 displaying the image may include an acquisition module 1010 and a processing module 1020, which are coupled to each other.
[0395] The acquisition module 1010 can be used to support electronic devices in acquiring user input, such as acquiring the user's touch operation on the display screen of the electronic device, as mentioned above.
[0396] The processing module 1020 is used to support the electronic device in performing the processing actions in the above method embodiments, such as determining the stretching dividing line according to the element type and stretching direction of the first image.
[0397] Optionally, the image processing apparatus 1000 may further include a storage module 1030 for storing the program code and data of the display processing apparatus 1000.
[0398] Optionally, the image processing apparatus 1000 may further include a display module for displaying images before and after stretching, or for displaying images before and after shrinking.
[0399] Figure 32 An electronic device 2000 is provided as an embodiment of this application. For example... Figure 32 As shown, the electronic device 2000 includes at least one processor 2010 and a transceiver 2020. The processor 2010 is coupled to a memory and is used to execute instructions stored in the memory to control the transceiver 2020 to transmit and / or receive signals.
[0400] Optionally, the electronic device 2000 also includes a memory 2030 for storing instructions.
[0401] In some embodiments, the processor 2010 and the memory 2030 can be combined into a single processing device, with the processor 2010 executing program code stored in the memory 2030 to implement the aforementioned functions. In specific implementations, the memory 2030 can be integrated into the processor 2010 or independent of the processor 2010.
[0402] In some embodiments, transceiver 2020 may include a receiver (or receiver unit) and a transmitter (or transmitter unit).
[0403] The transceiver 2020 may further include antennas, and the number of antennas may be one or more. The transceiver 2020 may be a communication interface or interface circuitry.
[0404] When the electronic device 2000 is a chip, the chip includes a transceiver module and a processing module. The transceiver module can be an input / output circuit or a communication interface; the processing module can be a processor, microprocessor, or integrated circuit integrated on the chip.
[0405] This embodiment also provides a computer-readable storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the above-described method steps to implement the image stretching / shrinking method in the above embodiment.
[0406] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the image stretching / shrinking method described in the above embodiment.
[0407] Furthermore, embodiments of this application also provide an apparatus, which may specifically be a chip, component, or module. This apparatus may include a connected processor and a memory. The memory stores computer execution instructions. When the apparatus is running, the processor can execute the computer execution instructions stored in the memory to cause the chip to perform the image stretching / shrinking methods described in the above method embodiments.
[0408] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.
[0409] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software 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 beyond the scope of this application.
[0410] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0411] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0412] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0413] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0414] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0415] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for displaying an image, characterized in that, include: In response to a user's operation of stretching a first image along a first direction, the stretching dimension of the first image is determined, the first image including deformable elements and non-deformable elements; The second image is displayed. The target region of the second image includes target pixels, which are pixels that are repeated by a deformable element along the first direction. The size of the target region along the first direction is equal to the stretching size. The non-deformable element is located outside the target region.
2. The method according to claim 1, characterized in that, The first image further includes repeatable elements, and the method further includes: When the first direction is the same as the arrangement direction of the repeatable element, the repeatable element is displayed in the target area.
3. The method according to claim 2, characterized in that, Before displaying the second image, the method further includes: In response to the user's first action, a first dividing line is determined, wherein the pixels on the first dividing line include the target pixel.
4. The method according to claim 3, characterized in that, The pixels on the first dividing line do not include the pixels of the non-deformable element.
5. The method according to claim 3 or 4, characterized in that, The pixels on the first dividing line do not include the pixels of the repeatable element.
6. The method according to any one of claims 3 to 5, characterized in that, The non-deformable element includes a first element, and the first dividing line is set within a preset range of the first element.
7. The method according to claim 6, characterized in that, The method further includes: In response to a second user action, a second dividing line is determined, which, along with the first dividing line, is located on either side of the first element.
8. The method according to claim 6, characterized in that, The non-deformable element further includes a second element, which is arranged at intervals from the first element along the first direction, and the first element and the second element are located inside the deformable element. The method further includes: In response to the user's second action, a second dividing line is determined, which is set within a preset range of the second element.
9. The method according to any one of claims 3 to 8, characterized in that, The target area also includes background pixels, and the pixel values on the background pixels are filled according to the pixel values on the first dividing line.
10. The method according to any one of claims 1 to 9, characterized in that, The non-deformable element includes a third element, the relative position of which on the first image is different from the relative position of which on the second image.
11. The method according to any one of claims 1 to 10, characterized in that, Before displaying the second image, the method further includes: The intermediate image is displayed, which includes the first image and a first region. The first region is the area between the boundary of the first image and the boundary of the second image. The display color of the first region belongs to the same color system as the background color of the first image.
12. A method for displaying an image, characterized in that, include: Determine the stretching direction and stretching dimension of the first image; Based on the stretching direction, the element types included in the first image are determined, and the element types include deformable elements and non-deformable elements; Determine the stretching dividing line based on the element type and the stretching direction; Based on the first image, the stretching direction, and the stretching dimension, the target area of the second image is determined, and the second image is the stretched image; The target region is filled based on the pixels along the stretching dividing line.
13. The method according to claim 12, characterized in that, The element type also includes repeatable elements, and the method further includes: If the repeatable element is located on both sides of the stretch dividing line, then the repeatable element is filled in the target area.
14. The method according to claim 13, characterized in that, Before filling the target region with the repeatable element, the method further includes: Remove the repeatable elements from the first image; The pixel values at the positions corresponding to the repeatable elements on the first image are filled using the average pixel value within a preset range surrounding the repeatable elements.
15. The method according to claim 13 or 14, characterized in that, The step of filling the target region with the repeatable element includes: Based on the stretching dimension, the maximum distance between repeatable elements on the first image, and the spacing between adjacent repeatable elements, determine the total number of repeatable elements that need to be filled on the second image. The filling position of the repeating elements on the second image is determined based on the total number of repeating elements, the position of the first repeating element, and the spacing between adjacent repeating elements.
16. The method according to any one of claims 12 to 15, characterized in that, Determining the element types included in the first image based on the stretching direction includes: The first image is binarized to determine the corresponding binarized image. Contour detection and line segment detection are performed on the binarized image to determine the hierarchical elements of the first image; Based on the stretching direction, each level of elements is classified to determine the element type of each level of elements.
17. The method according to claim 16, characterized in that, The hierarchical elements include first-level elements, and determining the element type of each level includes: If the shape similarity, area intersection-union ratio, and distance of the average color vector of the first element and the second element of the first level all meet the preset conditions, then the first element is determined to be a repeatable element. If any one of the following conditions—shape similarity, area intersection-union ratio, and distance between the first element and the second element of the first level element—does not satisfy the preset conditions, then the first element is determined to be a non-repeatable element.
18. The method according to claim 17, characterized in that, If the first element is determined to be a non-repeating element, determining the element type of each level of elements includes: If it is determined that the first element is located in the deformable image library, then the first element is determined to be a deformable element; If it is determined that the first element is not located in the deformable image library, then the first element is determined to be an undeformable element.
19. The method according to any one of claims 12 to 18, characterized in that, The stretching dividing line does not overlap with the non-deformable element.
20. A device for displaying images, characterized in that, Includes modules for implementing the method of any one of claims 1 to 19.
21. An electronic device, characterized in that, It includes a processor and a memory, the memory being used to store program instructions, and the processor being used to invoke the program instructions to perform the method of any one of claims 1 to 19.
22. A computer-readable storage medium, characterized in that, It stores a computer program thereon, which, when executed by a computer, enables the implementation of the method according to any one of claims 1 to 19.
23. A computer program product, characterized in that, It includes computer program code that, when run on a computer, causes the method of any one of claims 1 to 19 to be performed.