Image display method and device and electronic equipment
By distinguishing image element types and using segmentation lines to process, the problem of image deformation and proportional inconsistency is solved, and the visual aesthetic effect when size changes is achieved.
Patent Information
- Application Number
- CN202510229672.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2025-08-26
AI Technical Summary
When the prior art changes the size and aspect ratio of image materials, it is easy to cause image elements to be deformed and proportional inconsistent, making it difficult to meet the visual aesthetic needs of users.
By distinguishing deformable elements from immutable elements in the image display method, using stretching or shrinking segmentation line processing, the position and size of the immutable elements remain unchanged, and only the size of the deformable elements is changed, and a new image is generated to adapt to the size changes.
It realizes that the image maintains the original layout and alignment when the size changes, and does not cause elements to be deformed or distorted, ensuring the visual aesthetics.
Smart Images

Figure CN120543368A_ABST
Abstract
Description
[0001] This application is a divisional application. The application number of the original application is 202411069516.1, and the original application date is August 5, 2024. The entire content of the original application is incorporated into this application by reference. Technical Field
[0002] The present application relates to the field of image processing technology, and more specifically, to a method, device and electronic device for image display. Background Art
[0003] In various scenarios, such as handwritten notes and presentations, users often need to change the size and aspect ratio of image assets to suit their personalized content. However, conventional image scaling methods currently result in distorted image elements, creating disproportionate and unsightly proportions that are difficult for users to accept. Summary of the Invention
[0004] The present application provides a method, device and electronic device for image display, which can realize adaptive change of image layout with the size of the image, avoid deformation and distortion of the image, and ensure visual aesthetic perception.
[0005] In a first aspect, a method for image display is provided, the method comprising: determining a stretched size of the first image in response to a user's operation of stretching the first image along a first direction, the first image comprising deformable elements and non-deformable elements; displaying a second image, wherein a target area of the second image comprises target pixels, the target pixels being pixels of the deformable elements repeated along the first direction, a size of the target area along the first direction being equal to the stretched size, and the non-deformable elements being located outside the target area.
[0006] The first image is the image before stretching, the second image is the image after stretching, and the size of the second image is larger than that of the first image. The first image may include deformable elements and non-deformable elements. Deformable elements can be understood as elements whose size changes will not affect the display effect of the elements during image stretching or image shrinking. Deformable elements may include, for example, straight lines and rectangles. Non-deformable elements can be understood as elements whose size is fixed and cannot be deformed or distorted during image stretching or image shrinking. If the elements are deformed, it may affect the display effect of the elements. Non-deformable elements may include, for example: special characters, symbols, fonts, patterns formed by certain arrangements and combinations, patterns of special shapes, etc.
[0007] The target pixel being a pixel of the deformable element repeated along the first direction may be understood as follows: along the first direction, the pixel value of the target pixel is the same as the pixel value of the deformable element.
[0008] In an embodiment of the present application, the electronic device can generate and display a second image based on the user's operation of stretching the first image, where the second image includes a target area (i.e., a newly added area), and the target pixels included in the target area are pixels of the deformable element repeated along the stretching direction, and the non-deformable elements are located outside the target area. That is, when the first image includes deformable elements and non-deformable elements, when the first image is stretched, the size of the deformable elements on the first image changes and can be elongated, while the size of the non-deformable elements on the first image does not change and maintains the original alignment. In this way, 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, and will not cause deformation and distortion of the elements, thereby ensuring visual aesthetics.
[0009] In combination with the first aspect, in certain implementations of the first aspect, the first image further includes a repeatable element, and the method further includes: displaying the repeatable element in the target area when the first direction is the same as an arrangement direction of the repeatable element.
[0010] It should be understood that the repeatable element is an element that appears repeatedly in the first image, that is, an element that appears in the first image more than or equal to 2 times can be considered a repeatable element. For example, the first image can include multiple repeatable circles, straight lines, etc.
[0011] In an embodiment of the present 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 of the repeatable elements, so that the image layout can adaptively change with the image aspect ratio.
[0012] In combination with the first aspect, in certain implementations of the first aspect, before displaying the second image, the method further includes: determining a first dividing line in response to a first operation of the user, where pixels on the first dividing line include the target pixel.
[0013] In an embodiment of the present application, the user can draw a first dividing line on the first image, so that the first image can be stretched according to the first dividing line, that is, by repeatedly filling the pixels on the first dividing line in the target area, the pixel filling of the target area is achieved to obtain the second image.
[0014] In combination with the first aspect, in some implementations of the first aspect, the pixels on the first dividing line do not include pixels of the non-deformable element.
[0015] In an embodiment of the present application, the pixels on the first dividing line do not include pixels of non-deformable elements. That is, when the first image is stretched 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, thereby ensuring the visual aesthetic perception.
[0016] In combination with the first aspect, in some implementations of the first aspect, the pixels on the first dividing line do not include pixels of the repeatable element.
[0017] In an embodiment of the present application, the pixels on the first dividing line do not include pixels of repeatable elements. That is, when the first image is stretched based on the first dividing line, the repeatable elements on the first image will not be distorted, thereby avoiding affecting the image layout of the stretched second image and ensuring the visual aesthetic perception.
[0018] In combination with the first aspect, in some implementations of the first aspect, the non-deformable element includes a first element, and the first dividing line is set within a preset range of the first element.
[0019] In an embodiment of the present application, the first dividing line can avoid the non-deformable element and be set within a preset range of the non-deformable element, so that when the pixels on the first dividing line are repeatedly filled in the target area, the non-deformable element will not be distorted or deformed, and will not affect the image layout of the stretched second image, thereby ensuring the visual aesthetic perception.
[0020] In combination with the first aspect, in some implementations of the first aspect, the method further includes: determining a second dividing line in response to a second operation of the user, where the second dividing line and the first dividing line are located on both sides of the first element.
[0021] In an embodiment of the present application, the user can set dividing lines on both sides of the non-deformable first element, so that when the first image is stretched, the first element will not be distorted, and will not affect the image layout of the stretched second image, thereby ensuring the visual aesthetic perception.
[0022] In combination with the first aspect, in certain implementations of the first aspect, the non-deformable element also includes a second element, the second element is arranged at intervals with the first element along the first direction, and the first element and the second element are located inside the deformable element. The method also includes: in response to a second operation of the user, determining a second dividing line, and the second dividing line is set within a preset range of the second element.
[0023] In an embodiment of the present 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 will not affect the image layout of the stretched second image, thereby ensuring the visual aesthetic perception.
[0024] In combination with the first aspect, in some implementations of the first aspect, the target area further includes background pixels, and pixel values on the background pixels are filled according to pixel values on the first segmentation line.
[0025] In an embodiment of the present application, when operating the background color of the first image, the background pixels of the target area can be filled according to the pixel values on the stretched dividing line (such as the first dividing line), so that the stretched second image maintains the original color, ensuring the visual aesthetic perception.
[0026] In combination with the first aspect, in some implementations of the first aspect, the non-deformable element includes a third element, and a relative position of the third element on the first image is different from a relative position of the third element on the second image.
[0027] In an embodiment of the present application, during the process of stretching the first image, the position of the non-deformable element on the first image may change, for example, from a first position to a 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 element on the first image will not be distorted or deformed, while ensuring the original layout design of the image and the visual aesthetic perception.
[0028] In combination with the first aspect, in certain 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 area, the first area being an area between a boundary of the first image and a boundary of the second image, and the display color of the first area and the background color of the first image belonging to the same color system.
[0029] In the embodiments of the present application, taking into account the different performance of electronic devices, in some examples, before displaying the second image, an intermediate image can be displayed on the electronic device. 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. 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 be used to fill the first region and finally display the stretched second image. The non-deformable elements in the stretched second image are not deformed, and the layout is neat and beautiful.
[0030] In a second aspect, a method for image display is provided, the method comprising: determining a stretching direction and a stretching size of a first image; determining the element type included in the first image according to the stretching direction, the element type comprising deformable elements and non-deformable elements; determining a stretching dividing line according to the element type and the stretching direction of the first image; determining a target area of a second image according to the first image, the stretching direction and the stretching size, the second image being the stretched image; and filling the target area according to the pixels on the stretching dividing line.
[0031] In an embodiment of the present application, when stretching a first image, the element type included in the first image is first determined based on the stretching direction; then the stretching dividing line can be determined based on the element type and stretching direction of the first image; finally, the target area (or newly added area) of the second image can be filled with 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, will not cause deformation and distortion of the elements, and ensure the visual aesthetic perception.
[0032] In combination with the second aspect, in certain implementations of the second aspect, the element type further includes a repeatable element, and the method further includes: if the repeatable element is located on both sides of the stretch dividing line, filling the target area with the repeatable element.
[0033] In an embodiment of the present application, if the first image includes repeatable elements and the repeatable elements are located on both sides of the stretch dividing line, the repeatable elements can be filled in the target area (or the newly added area). In other words, the repeatable elements in the image can be adaptively added according to the arrangement pattern of the repeatable elements, so that the image layout can adapt to the changes in the image aspect ratio.
[0034] In combination with the second aspect, in certain implementations of the second aspect, before filling the repeatable element on the target area, the method also 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 using the pixel mean within a preset range around the repeatable element.
[0035] In an embodiment of the present application, for the repeatable elements on the first image, the repeatable elements can be first 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 is filled using the pixel mean within a preset range outside the repeatable element, so as to obtain the first image after removing the repeatable elements, and then the pixel filling of the newly added area or the target area can be achieved by repeatedly copying and stretching the pixels on the dividing line.
[0036] In combination with the second aspect, in certain implementations of the second aspect, filling the repeatable elements on the target area includes: determining the total number of repeatable elements that need to be filled on the second image based on the stretched size, the maximum distance of the repeatable elements on the first image, and the spacing between adjacent repeatable elements; determining the filling position of the repeatable elements on 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.
[0037] In an embodiment of the present application, when repeatable elements are located on both sides of the stretch dividing line, it is first necessary to remove all repeatable elements from the first image and repair the background holes of the first image; then, by repeatedly copying the pixels on the stretch dividing line, the pixel filling of the target area of the second image is achieved; finally, the total number of repeatable elements that need to be filled in the second image is determined based on the stretching size, the maximum distance of the repeatable elements on the first image, and the spacing between adjacent repeatable elements; starting from the first repeatable element, the repeatable elements are filled in sequence 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.
[0038] In combination with the second aspect, in certain implementations of the second aspect, the stretching dividing line does not overlap with the non-deformable element.
[0039] In an embodiment of the present application, the pixels on the stretching dividing line do not include pixels of non-deformable elements. That is, when the first image is stretched 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, thereby ensuring the visual aesthetic perception.
[0040] In combination with the second aspect, in certain implementations of the second aspect, determining the element type included in the first image based on the stretching direction includes: binarizing 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 the elements at each level based on the stretching direction to determine the element type of the elements at each level.
[0041] In an embodiment of the present application, after acquiring the first image, the first image can be hierarchically classified according to the stretching direction of the first image to determine the element type of each level element. Based on the hierarchical classification results, the original alignment of the non-deformable elements can be maintained, the size of the deformable elements can be changed, and the repeatable elements can be increased at equal intervals in the stretching direction.
[0042] In combination with the second aspect, in certain implementations of the second aspect, the hierarchical elements include first-level elements, and determining the element type of the elements of each level includes: if the shape similarity, area intersection ratio and average color vector distance between the first element of the first-level element and the second element of the first-level element all meet preset conditions, then the first element is determined to be a repeatable element; if any one of the shape similarity, area intersection ratio and average color vector distance between the first element of the first-level element and the second element of the first-level element does not meet the preset conditions, then the first element is determined to be a non-repeatable element.
[0043] 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 and 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 to be an identical repeatable element.
[0044] In an embodiment of the present application, when classifying elements at each level, it is possible to determine whether there are repeatable elements based on the above-mentioned shape similarity, area intersection ratio, and distance of the average color vector. Therefore, 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 repeatable elements can be increased at equal intervals in the stretching direction.
[0045] In combination with the second aspect, in certain 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 a deformable image library, determining that the first element is a deformable element; if it is determined that the first element is not located in the deformable image library, determining that the first element is a non-deformable element.
[0046] In this embodiment of the present application, if the first element is determined to be non-repeatable, the first element can be further matched against a deformable image library. If the first element is found in the deformable image library, the first element is determined to be a deformable element; otherwise, the first element is determined to be non-deformable. 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 repeatable elements can be increased at equal intervals along the stretching direction.
[0047] In a third aspect, a method for image display is provided, the method comprising: determining a shrunk 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 area and a non-target area, the target area comprising target pixels, the target pixels being pixels of the deformable elements repeated along the first direction, the shortened size of the target area along the first direction being equal to the shrunk size, and the non-deformable elements being located outside the target area; and displaying a second image, the second image comprising the non-target area.
[0048] The first image is the image before shrinkage, the second image is the image after shrinkage, and the size of the second image is smaller than that of the first image. The first image may include deformable elements and non-deformable elements. Deformable elements can be understood as elements whose size changes will not affect the display effect of the elements during image stretching or image shrinkage. Deformable elements may include, for example, straight lines and rectangles. Non-deformable elements can be understood as elements whose size is fixed and cannot be deformed or distorted during image stretching or image shrinkage. If the elements are deformed, it may affect the display effect of the elements. Non-deformable elements may include, for example: special characters, symbols, fonts, patterns formed by certain arrangements and combinations, patterns of special shapes, etc.
[0049] In an embodiment of the present application, 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 target pixels included in the target area are pixels of the deformable element repeated along the stretching direction, and the non-deformable elements are located outside the target area, that is, located in the non-target area. The shrunk second image only includes the non-target area, that is, the target area is deleted and the non-target area is retained. That is to say, when the first image includes deformable elements and non-deformable elements, when the first image is shrunk, the size of the deformable elements on the first image changes and can be shortened, and the size of the non-deformable elements on the first image does not change and maintains the original alignment. In this way, 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, and will not cause deformation and distortion of the elements, thereby ensuring visual aesthetics.
[0050] In combination with the third aspect, in certain 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 area includes at least one of the repeatable elements.
[0051] It should be understood that the repeatable element is an element that appears repeatedly in the first image, that is, an element that appears in the first image more than or equal to 2 times can be considered a repeatable element. For example, the first image can include multiple repeatable circles, straight lines, etc.
[0052] In an embodiment of the present application, when the first image includes repeatable elements, when the first image is shrunk, the repeatable elements in the target area are deleted and can be adaptively reduced according to the arrangement rule of the repeatable elements, so that the image layout can adaptively change with the image aspect ratio.
[0053] In combination with the third aspect, in certain implementations of the third aspect, before displaying the second image, the method further includes: determining a first dividing line in response to a first operation of the user, the pixels on the first dividing line including pixels of the deformable element repeated along the first direction.
[0054] In an embodiment of the present application, the user can draw a first dividing line on the first image, so that the first image can be shrunk according to the first dividing line, that is, the pixels on the first dividing line are repeatedly deleted to achieve the purpose of deleting the target area, and the obtained second image does not include the target area.
[0055] In combination with the third aspect, in some implementations of the third aspect, the pixels on the first dividing line do not include pixels on the non-deformable element.
[0056] In an embodiment of the present application, the pixels on the first dividing line do not include 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 will not affect the image layout of the shrunk second image, thereby ensuring the visual aesthetic perception.
[0057] In combination with the third aspect, in certain implementations of the third aspect, the pixels on the first dividing line do not include pixels of the repeatable element.
[0058] In an embodiment of the present application, the pixels on the first dividing line do not include 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, thereby avoiding affecting the image layout of the shrunk second image and ensuring the visual aesthetic perception.
[0059] In combination with the third aspect, in certain implementations of the third aspect, the non-deformable element includes a first element, and the first dividing line is set within a preset range of the first element.
[0060] In an embodiment of the present application, 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 deleted in the target area, the non-deformable elements will not be distorted or deformed, and will not affect the image layout of the shrunk second image, thereby ensuring the visual aesthetic perception.
[0061] In combination with the third aspect, in some implementations of the third aspect, the method further includes: determining a second dividing line in response to a second operation of the user, where the second dividing line and the first dividing line are located on both sides of the first element.
[0062] In an embodiment of the present application, the user can set dividing lines on both sides of the non-deformable first element, so that when the first image is shrunk, the first element will not be distorted, and will not affect the image layout of the shrunk second image, thereby ensuring the visual aesthetic perception.
[0063] In combination with the third aspect, in certain implementations of the third aspect, the non-deformable element also includes a second element, the second element is arranged at intervals with the first element along the first direction, and the first element and the second element are located inside the deformable element. The method also includes: in response to a second operation of the user, determining a second dividing line, and the second dividing line is set within a preset range of the second element.
[0064] In an embodiment of the present 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 will not affect the image layout of the shrunk second image, thereby ensuring the visual aesthetic perception.
[0065] In combination with the third aspect, in some implementations of the third aspect, the non-deformable element includes a third element, and a relative position of the third element on the first image is different from a relative position of the third element on the second image.
[0066] In an embodiment of the present application, during the process of shrinking the first image, the position of the non-deformable element on the first image may change, for example, from a first position to a 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 element on the first image will not be distorted or deformed, while ensuring the original layout design of the image and the visual aesthetic perception.
[0067] In a fourth aspect, a method for image display is provided, the method comprising: determining a shrinkage direction and a shrinkage size of a first image; determining an element type included in the first image based on the shrinkage direction, the element type comprising a deformable element and a non-deformable element; determining a shrinkage dividing line based on the element type and the shrinkage direction of the first image; determining a target area 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 area.
[0068] In an embodiment of the present application, when shrinking the first image, the element type included in the first image is first determined based on the shrinking direction; then the shrinking dividing line can be determined based on the element type and shrinking direction of the first image; finally, the pixels on the shrinking dividing line can be repeatedly deleted to achieve the purpose of deleting the target area of the first image; thereby, the image layout can be adaptively changed with the size of the image, so that the shrunken image can maintain the original layout and alignment, will not cause deformation and distortion of the elements, and ensure the visual aesthetic perception.
[0069] In combination with the fourth aspect, in certain implementations of the fourth aspect, the element type further includes a repeatable element, and the method further includes: if the repeatable element is located on both sides of the shrinkage dividing line, deleting the repeatable element in the target area.
[0070] In an embodiment of the present application, if the first image includes repeatable elements and the repeatable elements are located on both sides of the stretch dividing line, the repeatable elements within the target area can be deleted. In other words, the repeatable elements in the image can be adaptively reduced based on the arrangement of the repeatable elements, so that the image layout can adapt to changes in the image aspect ratio.
[0071] In combination with the fourth aspect, in certain implementations of the fourth aspect, before repeatedly deleting pixels on the shrinkage dividing line, the method also includes: removing the repeatable element from the first image; and filling the pixel values at the position corresponding to the repeatable element on the first image using the pixel mean within a preset range outside the repeatable element.
[0072] In an embodiment of the present application, for the repeatable elements on the first image, the repeatable elements can be first removed from the first image, and then the background holes of the first image can be repaired. For example, the pixel mean within a preset range outside the repeatable elements is used to fill the pixel values at the positions corresponding to the repeatable elements on the first image, so as to obtain the first image after removing the repeatable elements, and then the target area can be deleted by repeatedly deleting the pixels on the stretched dividing line.
[0073] In combination with the fourth aspect, in certain implementations of the fourth aspect, the method further includes: determining the total number of repeatable elements that need to be filled on the second image based on the shrinkage size, the maximum distance of the repeatable elements on the first image, and the spacing between adjacent repeatable elements; and determining the filling position of the repeatable elements on 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.
[0074] In an embodiment of the present application, when repeatable elements are located on both sides of the shrinkage dividing line, it is first necessary to remove all repeatable elements from the first image and repair the background holes of the first image; then, the target area is deleted by repeatedly deleting the pixels on the shrinkage dividing line; finally, the total number of repeatable elements that need to be filled in the second image is determined based on the shrinkage size, the maximum distance of the repeatable elements on the first image, and the spacing between adjacent repeatable elements; starting from the first repeatable element, the repeatable elements are filled in sequence according to the total number of repeatable elements and the spacing between adjacent repeatable elements.
[0075] In combination with the fourth aspect, in certain implementations of the fourth aspect, the shrinkage dividing line does not overlap with the non-deformable element.
[0076] In an embodiment of the present application, the pixels on the shrinkage dividing line do not include pixels on the non-deformable elements. That is, when the first image is stretched based on the shrinkage 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 shrunk second image, thereby ensuring the visual aesthetic perception.
[0077] In combination with the fourth aspect, in certain implementations of the fourth aspect, determining the element type included in the first image based on the shrinkage direction includes: binarizing 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 the elements at each level based on the shrinkage direction to determine the element type of the elements at each level.
[0078] In an embodiment of the present application, after acquiring the first image, the first image can be hierarchically classified according to the shrinkage direction of the first image to determine the element type of each level element. Based on the hierarchical classification results, the original alignment of the non-deformable elements can be maintained, the size of the deformable elements can be changed, and the repeatable elements can be reduced at equal intervals in the shrinkage direction.
[0079] In combination with the fourth aspect, in certain implementations of the fourth aspect, the hierarchical elements include first-level elements, and determining the element type of the elements of each level includes: if the shape similarity, area intersection ratio and average color vector distance between the first element of the first-level element and the second element of the first-level element all meet preset conditions, then the first element is determined to be a repeatable element; if any one of the shape similarity, area intersection ratio and average color vector distance between the first element of the first-level element and the second element of the first-level element does not meet the preset conditions, then the first element is determined to be a non-repeatable element.
[0080] In one possible implementation, if the degree of shape similarity between the first element and other elements (such as the second element) is greater than a first threshold, and the area intersection 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 fourth threshold, then the first element and other elements (such as the second element) can be considered to be the same repeatable elements.
[0081] In an embodiment of the present application, when classifying elements at each level, it is possible to determine whether there are repeatable elements based on the above-mentioned shape similarity, area intersection ratio, and distance of the average color vector. Therefore, 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 repeatable elements can be reduced at equal intervals in the shrinking direction.
[0082] In combination with the fourth aspect, in certain 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 a deformable image library, determining that the first element is a deformable element; if it is determined that the first element is not located in the deformable image library, determining that the first element is a non-deformable element.
[0083] In this embodiment of the present application, if the first element is determined to be non-repeatable, the first element can be further matched against a deformable image library. If the first element is found in the deformable image library, the first element is determined to be a deformable element; otherwise, the first element is determined to be non-deformable. 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 spacing of repeatable elements can be reduced evenly in the shrinking direction.
[0084] In a fifth aspect, a method for image display is provided, the method comprising: determining a stretched size of the first image in response to a user's operation of stretching a first image along a first direction, the first image including a repeatable element; displaying a second image, the target area of the second image including the repeatable element, the size of the target area along the first direction being equal to the stretched size.
[0085] In an embodiment of the present application, the first image can be an aesthetically pleasing sticker image or artistic line formed by a special arrangement and combination 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., a newly added area). The target area can present repeatable elements at equal intervals, so that when the first image is stretched, it can be adaptively increased according to the arrangement rule of the repeatable elements, avoiding manual copying of repeatable elements, which is more efficient and convenient.
[0086] In a sixth aspect, a method for image display is provided, the method comprising: determining the shrunken 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 area and a non-target area, the target area including at least one of the repeatable elements, and the size of the target area along the first direction being equal to the shrunken size; and displaying a second image, the second image including the non-target area.
[0087] In an embodiment of the present application, the first image can be an aesthetically pleasing sticker image or artistic line formed by a special arrangement and combination 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; wherein the first image includes a target area and a non-target area, and the second image only includes a non-target area, which is equivalent to deleting the repeatable elements in the target area, so that when the first image is shrunk, it can be adaptively reduced according to the arrangement rule of the repeatable elements, avoiding manual deletion of repeatable elements, which is more efficient and convenient.
[0088] For detailed explanations and descriptions of the beneficial effects of the following technical solutions, please refer to the relevant contents of the first to sixth aspects, which will not be repeated below.
[0089] In the seventh aspect, a device for image display is provided, which includes a processing module and a display module. The processing module is used to: determine the stretched size of the first image in response to a user's operation of stretching the first image along a first direction, wherein the first image includes deformable elements and non-deformable elements; the display module is used to: display a second image, wherein a target area of the second image includes target pixels, which are pixels of the deformable elements repeated along the first direction, and the size of the target area along the first direction is equal to the stretched size, and the non-deformable elements are located outside the target area.
[0090] In combination with the seventh aspect, in certain implementations of the seventh aspect, the first image further includes a repeatable element, and the display module is further used to: display the repeatable element in the target area when the first direction is the same as the arrangement direction of the repeatable element.
[0091] In combination with the seventh aspect, in certain implementations of the seventh aspect, before displaying the second image, the processing module is further used to: determine a first dividing line in response to a first operation of the user, and the pixels on the first dividing line include the target pixel.
[0092] In combination with the seventh aspect, in some implementations of the seventh aspect, the pixels on the first dividing line do not include pixels on the non-deformable element.
[0093] In combination with the seventh aspect, in certain implementations of the seventh aspect, the pixels on the first dividing line do not include pixels of the repeatable element.
[0094] In combination with the seventh aspect, in some implementations of the seventh aspect, the non-deformable element includes a first element, and the first dividing line is set within a preset range of the first element.
[0095] In combination with the seventh aspect, in some implementations of the seventh aspect, the processing module is further used to: determine a second dividing line in response to a second operation of the user, where the second dividing line and the first dividing line are located on both sides of the first element.
[0096] In combination with the seventh aspect, in certain implementations of the seventh aspect, the non-deformable element also includes a second element, the second element is arranged at intervals with the first element along the first direction, the first element and the second element are located inside the deformable element, and the processing module is also used to: determine a second dividing line in response to a second operation of the user, and the second dividing line is set within a preset range of the second element.
[0097] In combination with the seventh aspect, in certain implementations of the seventh aspect, the target area further includes background pixels, and the pixel values on the background pixels are filled according to the pixel values on the first dividing line.
[0098] In combination with the seventh aspect, in some implementations of the seventh aspect, the non-deformable element includes a third element, and a relative position of the third element on the first image is different from a relative position of the third element on the second image.
[0099] In combination with the seventh aspect, in certain implementations of the seventh aspect, before displaying the second image, the display module is also used to: display an intermediate image, the intermediate image including the first image and a first area, the first area being an area between the boundary of the first image and the boundary of the second image, and the display color of the first area and the background color of the first image belong to the same color system.
[0100] In an eighth aspect, a device for image display is provided, which includes a processing module, and the processing module is used to: determine the stretching direction and stretching size of a first image; determine the element type included in the first image according to the stretching direction, and the element type includes deformable elements and non-deformable elements; determine a stretching dividing line according to the element type and the stretching direction of the first image; determine a target area of a second image according to the first image, the stretching direction and the stretching size, and the second image is a stretched image; fill the target area according to the pixels on the stretching dividing line.
[0101] In combination with the eighth aspect, in certain implementations of the eighth aspect, the element type further includes a repeatable element, and the processing module is further used to: if the repeatable element is located on both sides of the stretch dividing line, fill the target area with the repeatable element.
[0102] In combination with the eighth aspect, in certain implementations of the eighth aspect, before filling the repeatable element on the target area, the processing module is also used to: remove the repeatable element from the first image; and use the pixel mean within a preset range around the repeatable element to fill the pixel value at the position corresponding to the repeatable element on the first image.
[0103] In combination with the eighth aspect, in certain implementations of the eighth aspect, the processing module is further used to: determine the total number of repeatable elements that need to be filled on the second image based on the stretched size, the maximum distance of the repeatable elements on the first image, and the spacing between adjacent repeatable elements; determine the filling position of the repeatable elements on 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.
[0104] In combination with the eighth aspect, in certain implementations of the eighth aspect, the stretching dividing line does not overlap with the non-deformable element.
[0105] In combination with the eighth aspect, in certain implementations of the eighth aspect, the processing module is further used 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 perform element classification on each hierarchical element according to the stretching direction to determine the element type of each hierarchical element.
[0106] In combination with the eighth aspect, in certain implementations of the eighth aspect, the hierarchical elements include first-level elements, and the processing module is further used to: if the shape similarity, area intersection ratio and average color vector distance between the first element of the first-level element and the second element of the first-level element all meet preset conditions, then determine that the first element is a repeatable element; if any one of the shape similarity, area intersection ratio and average color vector distance between the first element of the first-level element and the second element of the first-level element does not meet the preset conditions, then determine that the first element is a non-repeatable element.
[0107] In combination with the eighth aspect, in certain implementations of the eighth aspect, when it is determined that the first element is a non-repeatable element, the processing module is further used to: if it is determined that the first element is located in a deformable image library, 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, determine that the first element is a non-deformable element.
[0108] In a ninth aspect, a device for image display is provided, which includes a processing module and a display module, wherein the processing module is used to: determine the contraction size of the first image in response to a user's operation of contracting the first image along a first direction, wherein the first image includes a deformable element and a non-deformable element, and the first image includes a target area and a non-target area, and the target area includes target pixels, which are pixels of the deformable element repeated along the first direction, and the shortened size of the target area along the first direction is equal to the contraction size, and the non-deformable element is located outside the target area; and the display module is used to: display a second image, wherein the second image includes the non-target area.
[0109] In combination with the ninth aspect, in certain implementations of the ninth 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 area includes at least one of the repeatable elements.
[0110] In combination with the ninth aspect, in certain implementations of the ninth aspect, before displaying the second image, the processing module is further used to: determine a first dividing line in response to a first operation of the user, and the pixels on the first dividing line include pixels of the deformable element repeated along the first direction.
[0111] In combination with the ninth aspect, in certain implementations of the ninth aspect, the pixels on the first dividing line do not include pixels on the non-deformable element.
[0112] In combination with the ninth aspect, in certain implementations of the ninth aspect, the pixels on the first dividing line do not include pixels of the repeatable element.
[0113] In combination with the ninth aspect, in certain implementations of the ninth aspect, the non-deformable element includes a first element, and the first dividing line is set within a preset range of the first element.
[0114] In combination with the ninth aspect, in certain implementations of the ninth aspect, the processing module is further used to: determine a second dividing line in response to a second operation of the user, where the second dividing line and the first dividing line are located on both sides of the first element.
[0115] In combination with the ninth aspect, in certain implementations of the ninth aspect, the non-deformable element further includes a second element, the second element is arranged at intervals with the first element along the first direction, the first element and the second element are located inside the deformable element, and the processing module is further used to: determine a second dividing line in response to a second operation of the user, and the second dividing line is set within a preset range of the second element.
[0116] In combination with the ninth aspect, in certain implementations of the ninth aspect, the non-deformable element includes a third element, and a relative position of the third element on the first image is different from a relative position of the third element on the second image.
[0117] In a tenth aspect, a device for image display is provided, which includes a processing module, wherein the processing module is used to: determine the shrinkage direction and shrinkage size of a first image; determine the element type included in the first image based on the shrinkage direction, the element type including deformable elements and non-deformable elements; determine a shrinkage dividing line based on the element type and the shrinkage direction of the first image; determine a target area 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 area.
[0118] In combination with the tenth aspect, in certain implementations of the tenth aspect, the element type further includes a repeatable element, and the processing module is further used to: if the repeatable element is located on both sides of the shrinkage dividing line, delete the repeatable element in the target area.
[0119] In combination with the tenth aspect, in certain implementations of the tenth aspect, before repeatedly deleting pixels on the shrinkage dividing line, the processing module is also used to: remove the repeatable element from the first image; and use the pixel mean within a preset range outside the repeatable element to fill the pixel value at the position corresponding to the repeatable element on the first image.
[0120] In combination with the tenth aspect, in certain implementations of the tenth aspect, the processing module is further used to: determine the total number of repeatable elements that need to be filled on the second image based on the shrinkage size, the maximum distance of the repeatable elements on the first image, and the spacing between adjacent repeatable elements; determine the filling position of the repeatable elements on 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.
[0121] In combination with the tenth aspect, in certain implementations of the tenth aspect, the shrinkage dividing line does not overlap with the non-deformable element.
[0122] In combination with the tenth aspect, in certain implementations of the tenth aspect, the processing module is further used 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 shrinkage direction to determine the element type of each hierarchical element.
[0123] In combination with the tenth aspect, in certain implementations of the tenth aspect, the hierarchical elements include first-level elements, and the processing module is further used to: if the shape similarity, area intersection ratio and average color vector distance between the first element of the first-level element and the second element of the first-level element all meet preset conditions, then determine that the first element is a repeatable element; if any one of the shape similarity, area intersection ratio and average color vector distance between the first element of the first-level element and the second element of the first-level element does not meet the preset conditions, then determine that the first element is a non-repeatable element.
[0124] In combination with the tenth aspect, in certain implementations of the tenth aspect, when it is determined that the first element is a non-repeatable element, the processing module is further used to: if it is determined that the first element is located in a deformable image library, 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, determine that the first element is a non-deformable element.
[0125] In the eleventh aspect, a device for image display is provided, which includes a processing module and a display module. The processing module is used to: determine the stretched size of the first image in response to the user's operation of stretching the first image along a first direction, and the first image includes a repeatable element; the display module is used to: display a second image, the target area of the second image includes the repeatable element, and the size of the target area along the first direction is equal to the stretched size.
[0126] In a twelfth aspect, a device for image display is provided, which includes a processing module and a display module, the processing module being used to: determine the shrunk size of the first image in response to a user's operation of shrinking the first image along a first direction, the first image including repeatable elements, the first image including a target area and a non-target area, the target area including at least one of the repeatable elements, and the size of the target area along the first direction being equal to the shrunk size; the display module being used to: display a second image, the second image including the non-target area.
[0127] In the twelfth aspect, an electronic device is provided, which includes 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 implement the method in the second aspect or any possible implementation of the second aspect, or implement the method in the third aspect or any possible implementation of the third aspect, or implement the method in the fourth aspect or any possible implementation of the fourth aspect, or implement the method in the fifth aspect or any possible implementation of the fifth aspect, or implement the method in the sixth aspect or any possible implementation of the sixth aspect.
[0128] In the thirteenth aspect, a computer-readable storage medium is provided, in which a computer program or instruction is stored. When the computer program or instruction is executed, the method in the first aspect or any possible implementation of the first aspect is implemented, or the method in the second aspect or any possible implementation of the second aspect is implemented, or the method in the third aspect or any possible implementation of the third aspect is implemented, or the method in the fourth aspect or any possible implementation of the fourth aspect is implemented, or the method in the fifth aspect or any possible implementation of the fifth aspect is implemented, or the method in the sixth aspect or any possible implementation of the sixth aspect is implemented.
[0129] In the fourteenth aspect, a chip is provided, in which instructions are stored. When the chip is run on a device, the chip executes the method in the first aspect or any possible implementation of the first aspect, or executes the method in the second aspect or any possible implementation of the second aspect, or executes the method in the third aspect or any possible implementation of the third aspect, or implements the method in the fourth aspect or any possible implementation of the fourth aspect, or implements the method in the fifth aspect or any possible implementation of the fifth aspect, or implements the method in the sixth aspect or any possible implementation of the sixth aspect.
[0130] In the fifteenth aspect, a computer program product is provided, in which a computer program or instruction is stored. When the computer program or instruction is executed, the method in the first aspect or any possible implementation of the first aspect is implemented, or the method in the second aspect or any possible implementation of the second aspect is implemented, or the method in the third aspect or any possible implementation of the third aspect is implemented, or the method in the fourth aspect or any possible implementation of the fourth aspect is implemented, or the method in the fifth aspect or any possible implementation of the fifth aspect is implemented, or the method in the sixth aspect or any possible implementation of the sixth aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0131] Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0132] Figure 2 This is a software structure block diagram of an electronic device provided in an embodiment of the present application.
[0133] Figure 3 This is a schematic flow chart of an image stretching method provided in an embodiment of the present application.
[0134] Figure 4 This is a schematic diagram of a graphical user interface of an electronic device provided in an embodiment of the present application.
[0135] Figures 5 to 10 Schematic diagram of image stretching provided in an embodiment of the present application.
[0136] Figures 11 to 16 This is a schematic diagram of a stretching dividing line provided in an embodiment of the present application.
[0137] Figures 17 to 20 This is a schematic diagram of a graphical user interface of an electronic device provided in an embodiment of the present application.
[0138] Figure 21 This is a schematic diagram of an image stretching or shrinking process provided in an embodiment of the present application.
[0139] Figure 22 This is a schematic flowchart of another image stretching method provided in an embodiment of the present application.
[0140] Figure 23 and Figure 24 This is a schematic flowchart of an image classification method provided in an embodiment of the present application.
[0141] Figure 25 This is a schematic flowchart of another image stretching method provided in an embodiment of the present application.
[0142] Figure 26 This is a schematic flowchart of an image shrinking method provided in an embodiment of the present application.
[0143] Figure 27 This is a schematic diagram of image shrinkage provided in an embodiment of the present application.
[0144] Figure 28 This is a schematic diagram of a graphical user interface of another electronic device provided in an embodiment of the present application.
[0145] Figure 29 and Figure 30It is a schematic flow chart of the image shrinkage method provided in an embodiment of the present application.
[0146] Figure 31 This is a schematic diagram of a device for displaying images provided in an embodiment of the present application.
[0147] Figure 32 This is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0148] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "plurality" or "multiple" refers to two or more than two.
[0149] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0150] The terms used in the following embodiments are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification of this application and the appended claims, the singular expressions "a", "an", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one, two or more. The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship.
[0151] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "one embodiment," "some embodiments," "another embodiment," and "other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically stated. The terms "including," "comprising," "having," and variations thereof mean "including but not limited to," unless otherwise specifically stated.
[0152] The image display method provided in the embodiments of the present application can be applied to electronic devices such as mobile phones, tablet computers, 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. The embodiments of the present application do not impose any restrictions on the specific types of electronic devices, and can be controlled by touch or by a mouse. When a user attempts to change the size and aspect ratio of an image by touching or dragging the mouse, the system recognizes the direction and size of the user's drag and adaptively changes the image in real time to the target size, avoiding deformation and distortion of elements and ensuring visual aesthetics.
[0153] For example, Figure 1: The figure shows a schematic structural diagram of an electronic device 100. The 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, an antenna 1, an 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, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identification module (SIM) card interface 195. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light 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.
[0154] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0155] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.
[0156] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0157] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.
[0158] In some embodiments, the processor 110 may include one or more interfaces. The 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.
[0159] The USB interface 130 is an interface that complies with USB standards and may be a Mini USB interface, a Micro USB interface, a USB Type-C interface, or the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100, or to transfer data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio. This interface can also be used to connect other electronic devices, such as augmented reality devices.
[0160] It is understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is merely an illustrative illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods from the above embodiments, or a combination of multiple interface connection methods.
[0161] The charging management module 140 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive 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 provide power to the electronic device via the power management module 141.
[0162] The power management module 141 is used to connect 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, and provides power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0163] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0164] 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 a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.
[0165] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0166] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate 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 being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.) or displays an image or video through the display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
[0167] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. 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 the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0168] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through 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 technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0169] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0170] Display screen 194 is used to display images, videos, and the like. Display screen 194 includes a display panel. The display panel can 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 MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED). In some embodiments, electronic device 100 may include one or N display screens 194, where N is a positive integer greater than one.
[0171] The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
[0172] The ISP processes data fed back by camera 193. For example, when taking a photo, 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, which is then passed to the ISP for processing and converted into a visible image. The ISP can also perform algorithmic optimization on image noise, brightness, and skin tone. It can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be located within camera 193.
[0173] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. 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, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0174] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0175] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. This allows electronic device 100 to play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, and MPEG4.
[0176] The NPU is a neural network (NN) computing processor. Drawing on the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it rapidly processes input information and can continuously self-learn. The NPU can enable intelligent cognitive applications in electronic device 100, such as image recognition, face recognition, speech recognition, and text comprehension.
[0177] The external memory 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 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.
[0178] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an App required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0179] The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0180] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be provided in the processor 110, or some functional modules of the audio module 170 can be provided in the processor 110.
[0181] The speaker 170A, also called a "speaker", is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or listen to hands-free calls through the speaker 170A.
[0182] The receiver 170B, also called a "handset", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or a voice message, the user can place the receiver 170B close to the ear to hear the voice.
[0183] Microphone 170C, also known as "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the source of sound, realize directional recording function, etc.
[0184] The headphone jack 170D is used to connect a wired headphone and can be the USB interface 130 or a 3.5mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0185] The buttons 190 include a power button, a volume button, and the like. The buttons 190 may be mechanical buttons or touch buttons. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100.
[0186] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0187] The indicator 192 may be an indicator light, which may be used to indicate the charging status, power level changes, messages, missed calls, notifications, etc.
[0188] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to or disconnected from the electronic device 100 by inserting it into or removing it from the SIM card interface 195. The electronic device 100 can support 1 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, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. 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.
[0189] It should be understood that the phone card in the embodiments of the present application includes but is not limited to a SIM card, an eSIM card, a universal subscriber identity module (USIM), a universal integrated circuit card (UICC), and the like.
[0190] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present application, the Android system with a layered architecture is used as an example to illustrate the software structure of the electronic device 100.
[0191] Figure 2This is a block diagram of the software structure of the electronic device 100 according to an embodiment of the present application. The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers: 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.
[0192] like Figure 2 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.
[0193] The application framework layer provides an application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0194] like Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0195] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, take screenshots, etc.
[0196] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0197] The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images.
[0198] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including answering, hanging up, etc.).
[0199] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0200] The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include text messages in the status bar, beeps, vibrations on electronic devices, and flashing indicator lights.
[0201] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for scheduling and management of the Android system.
[0202] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.
[0203] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.
[0204] The system library can include multiple functional modules, such as a surface manager, media libraries, a 3D graphics processing library (such as OpenGL ES), and a 2D graphics engine (such as SGL).
[0205] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.
[0206] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0207] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0208] A 2D graphics engine is a drawing engine for 2D drawings.
[0209] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and sensor driver.
[0210] It should be understood that the technical solutions in the embodiments of the present application can be used in Android, IOS, Hongmeng and other systems.
[0211] The technical solution of the embodiment of the present application can be applied to editing and creation scenarios that require image stretching or shrinking. For example, it can be applied to scenarios such as handwritten notes and presentation making.
[0212] Among them, the electronic device can be a television, a large office screen, a desktop computer, a laptop computer, or a portable electronic device such as a mobile phone, a folding screen, a tablet computer, a camera, a video camera, a video recorder, or a smart home device such as a refrigerator, a washing machine, a sweeper, or any other electronic device with image processing capabilities. It can also be an electronic device in a 5G network or an electronic device in a future evolved public land mobile communication network (PLMN), etc.
[0213] Figure 3 This is a schematic flow chart of an image stretching method provided in an embodiment of the present application. Figure 3 As shown, the image stretching method 300 may include S310 to S330 , and the image stretching method 300 may be applied to the electronic device 100 .
[0214] S310: Acquire a first image, where the first image may include deformable elements and non-deformable elements.
[0215] Exemplarily, the first image may be a sticker image provided by the electronic device, or a custom image imported by the user.
[0216] For example, Figure 4 As shown, Figure 4 A schematic diagram of a graphical user interface of an electronic device is shown. For example, when a user is editing Note 1, they 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, for example, "Note 1." The toolbar A2 can be used to display function buttons that can be used to edit notes, such as the "Gallery" function button B1, the "Stickers" function button B2, the "Zoom In" function button, etc. The work area A3 can be used to display stickers or images acquired by the user.
[0217] In one example, in response to the user clicking the "Gallery" function button B1 in the toolbar A2, multiple images in the gallery can be displayed on the display interface of the electronic device, and the multiple images include image 1; in response to the user selecting image 1, image 1 can be displayed on the display interface of the electronic device.
[0218] In another example, in response to the user clicking the "sticker" function button B2 in the toolbar A2, multiple stickers can be displayed on the display interface of the electronic device, and the multiple stickers include sticker C1; in response to the user selecting sticker C1, sticker C1 can be displayed on the display interface of the electronic device.
[0219] It should be understood that the first image may include deformable elements and non-deformable elements. Deformable elements can be understood as elements whose size changes during image stretching or image contraction do not affect the displayed effect of the elements; deformable elements may include, for example, straight lines and rectangles. Non-deformable elements can be understood as elements whose size is fixed during image stretching or image contraction and cannot be deformed or distorted. If the elements are deformed, the displayed effect of the elements may be affected; non-deformable elements may include, for example: special characters, symbols, fonts, patterns formed by certain arrangements and combinations, patterns of special shapes, etc.
[0220] Exemplarily, the first image may further include a repeatable element, which is an element that appears repeatedly in the first image. That is, an element that appears twice or more in the first image may be considered a repeatable element. For example, the first image may include multiple repeatable circles, straight lines, etc.
[0221] It should be noted that after acquiring the first image, the first image can be classified according to the image classification method provided in this application to determine the element type included in the first image. The element type can include repeatable elements, deformable elements and non-deformable elements. The content of the image classification will be combined with the following Figure 23 and Figure 24 Provide specific instructions.
[0222] S320: Perform a stretching operation on the first image along a first direction to determine a stretching size of the first image.
[0223] In some examples, in response to a user stretching a first image along a first direction, a stretched size of the first image can be determined. For example, the stretched size can be determined based on a starting position and an ending position of the first image. The first direction can be horizontal or vertical, meaning the first image can be stretched horizontally or vertically.
[0224] For example, Figure 5 As shown, the user can stretch the original image horizontally, and the horizontal stretching size is d1. In addition, the non-deformable elements in the original image (such as the three-petal flower pattern) do not change, and the relative positions of the non-deformable elements in the image after horizontal stretching do not change from the 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 stretching of the straight lines is d1.
[0225] In other examples, in response to a user clicking or long pressing the first image, the display interface will display a first control, which includes options for image stretching size and / or image target size; in response to the user clicking on options for image stretching size and / or image target size, the display interface will display a second control, which includes an option box for at least one of image horizontal stretching size, image vertical stretching size, and image target size; in response to the user filling in a numerical value in the option box, the electronic device can determine the stretching size of the first image.
[0226] It should be understood that during the process of stretching the first image, the stretched size of the first image can be simultaneously confirmed, so that the stretched second image can be synchronously displayed on the display interface of the electronic device.
[0227] S330: Display a second image. A target area of the second image includes target pixels, which are pixels where the deformable element repeats along the first direction. The size of the target area along the first direction is equal to the stretching size. The target area can be considered as an area of the second image added relative to the first image, and the non-deformable element is located outside the target area.
[0228] It should be understood that during the image stretching process, the deformable elements on the image are elongated, while the non-deformable elements are positioned outside the target area, without deformation or distortion. The layout of the second image obtained by this method remains consistent with the first image, and there will be no layout confusion or disproportion.
[0229] In some examples, such as Figure 6 As shown in (a), the second image may include a target area, and the target area may be located in a partial area at the bottom end of the second image. The first image is stretched downward along the first direction to form the second image. The target area on the second image may be the downwardly stretched portion of the first image. The target area includes pixels of the deformable element (two rectangles) repeated along the first direction, and the non-deformable element (the character REMNDER) is located outside the target area.
[0230] In some examples, such as Figure 6 As shown in (b), the second image may include the target area (i.e. Figure 6The target area may be located in the middle portion of the second image, and the target area may include target pixels, which may be repeated pixels of a deformable element (such as two rectangles) along a first direction, and the non-deformable element (such as the character REMNDER) is located outside the target area. In other words, after stretching the first image using the stretching method of the present application, the deformable elements in the first image are elongated, while the non-deformable elements in the first image maintain their original alignment without deformation or distortion. This allows the image layout to adaptively change with the image aspect ratio when the first image is stretched, ensuring a neat, coordinated, and aesthetically pleasing image layout.
[0231] In other embodiments, the size of the target area along the first direction may not be equal to the stretched size, but may instead be in a certain ratio. For example, the first direction may not be horizontal (transverse) or vertical (longitudinal), but may instead be at a certain angle to the horizontal or vertical direction. In this case, the first direction may be decomposed into a first horizontal sub-direction and a second vertical sub-direction. The first and second sub-directions may be stretched using the image stretching methods provided in this application, respectively, thereby converting oblique stretching into stretching in the horizontal and vertical sub-directions.
[0232] For example, before displaying the stretched second image, when stretching the first image, it is necessary to confirm the stretching dividing line corresponding to the first image, and stretch the first image based on the stretching dividing line.
[0233] like Figure 6 As shown in (b) in the figure, the first image can be a sticker. The first image can include a non-deformable element (REMNDER) and a deformable element (two rectangles). Before stretching the first image, a stretching dividing line of the first image is determined. The stretching dividing line can be perpendicular to the stretching direction (i.e., the first direction, longitudinal direction). The portion of the first image above the stretching dividing line is the first portion, and the portion below the stretching dividing line is the second portion. After the first image is stretched along the first direction to obtain the second image, the area added to the second image relative to the first image can be the target area. The target area includes target pixels, which can be repeated pixels of the deformable element along the first direction. In other words, when stretching downward along the first direction, the newly added area can be filled by copying the pixels on the stretching dividing line, so that the length of the first image is increased, but the overall layout of the second image formed does not change, and the layout is neat and coordinated.
[0234] For example, there may be multiple stretching dividing lines, such as Figure 7 As shown, when horizontal stretching Figure 7When the first image is shown in the figure, since the non-deformable element REMNDER is centered and arranged along the first direction (horizontally), when the first image is stretched horizontally, the non-deformable element REMNDER will be deformed and elongated in a conventional manner, affecting the appearance. When the first image is stretched using the method of the present application, stretching dividing lines (i.e., a first dividing line and a second dividing line) can be generated on both sides of the non-deformable element. The first dividing line can be located on the left side of the non-deformable element REMNDER, and the second dividing line can be located on the right side of the non-deformable element REMNDER, so that the first image can be divided into a first part, a second part, and a third part. When the first image is stretched along the first direction (horizontally), the first part where the non-deformable element REMNDER is located will not be deformed. By copying the pixels on the first dividing line to fill the target area 1 and copying the pixels on the second dividing line to fill the target area 2, the target area 1 and the target area 2 form the above-mentioned target area, so that the width of the first image is increased, but the overall layout of the second image formed does not change, and the layout is neat and coordinated.
[0235] In some examples, when the first image includes a repeatable element, the method 300 may further include: displaying the repeatable element in the target area when the first direction is the same as an arrangement direction of the repeatable element.
[0236] For example, Figure 8 As shown, the first image can be Figure 4 In the illustrated sticker C1, the first image may include deformable elements (rounded rectangles and rectangular rectangles), non-deformable elements (a list of characters "TO DO LIST" and a date "_______"), and repeatable elements (a circle and a line). The repeatable elements are arranged in the same direction as the first direction. When the first image is stretched along the first direction, the non-deformable elements remain unchanged, maintaining their original alignment; the deformable elements change size and become elongated; and the repeatable elements increase in equal intervals along the stretching direction, allowing the repeatable elements to be displayed in the target area.
[0237] For example, Figure 9As shown, the first image can be a sticker image of a password manager, used by users to record their account numbers and passwords. The first image can include deformable elements, non-deformable elements, and repeatable elements, wherein the deformable elements include rectangles; the non-deformable elements include a key icon, the text password manager, account number, password, characters...; and the repeatable elements include the text account number, password, a rounded rectangle on the same side, a horizontal line segment, a vertical line segment, and a dashed line segment. The arrangement direction of the repeatable elements is the same as the stretching direction (i.e., the first direction). Therefore, when the first image is stretched along the first direction, the non-deformable elements do not change and maintain their original alignment; the size of the deformable elements changes and they are stretched; the repeatable elements increase at equal intervals in the stretching direction, and the target area can display the repeatable elements.
[0238] For example, Figure 10 (a) and Figure 10 As shown in (b) of FIG, the first image can be an image composed of repeatable elements. For example, the first image can be an aesthetically pleasing sticker image or line art formed by a special arrangement and combination of repeatable elements. In other words, the first image can include only repeatable 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 groups of repeatable elements. The repeatable elements increase at equal intervals in the stretching direction. The number of repeatable elements can be determined based on the stretching size and the size of the repeatable elements.
[0239] It should be noted that during the image stretching process, the image may be stretched based on a stretching dividing line, which may 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.
[0240] In some examples, the electronic device may determine a stretching dividing line for the first image based on preset rules. The preset rules may include, for example, the following: starting from the center of the first image, ignoring repeatable elements, and bypassing non-deformable elements in the first image; when passing through a deformable element, generally adjusting to the centerline of the deformable element; if there are multiple non-deformable elements in the first image, multiple stretching dividing lines may 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 line include the target pixels, that is, the pixels on the stretching dividing line include pixels where the deformable element repeats along the first direction.
[0241] For example, Figure 11 As shown, the first image can be Figure 4For the sticker C1 in the note shown, the type of elements contained in the sticker C1 can be determined based on the classification method provided in the embodiment of the present application. The sticker C1 may include deformable elements (rounded rectangles and right-angled rectangles), non-deformable elements (character list TO DO LIST and date _______) and repeatable elements (circles and straight lines). When determining the stretch dividing line (including horizontal dividing lines and vertical dividing lines), it is necessary to comprehensively consider the various elements on the sticker C1. For horizontal dividing lines or vertical dividing lines, non-deformable elements (list TO DO LIST and date _______) should be avoided, and repeatable elements should be ignored; at the same time, the center lines of the rounded rectangles and right-angled rectangles can also be selected to form stretch dividing lines in different directions.
[0242] In other examples, the first image may be an image or sticker that comes with the electronic device, such as Figure 4 For sticker C1 in the note shown, the stretch dividing line for an image pre-stored on the electronic device can be pre-configured in the background. That is, when the electronic device stores the image, it also stores the positions of the horizontal and vertical stretch dividing lines for that image. For example, the electronic device's configuration file stores the coordinate sequence of the multiple points that make up the stretch dividing line.
[0243] For example, Figure 12 As shown, taking the first image as a rounded right arrow image as an example, the rounded right arrow image can be pre-stored in the electronic device, and the coordinate sequence values of the horizontal dividing line and the coordinate sequence values of the vertical dividing line can also be stored in the electronic device. In the process of horizontally stretching the rounded right arrow image, the pixels on the horizontal dividing line can be copied to fill the target area or the newly added area, so that the horizontal length of the rounded right arrow image increases, but the rounded corner part of the rounded right arrow image does not deform. In the process of vertically stretching the rounded right arrow image, the pixels on the vertical dividing line can be copied to fill the target area or the newly added area, so that the vertical length of the rounded right arrow image increases, but the rounded corner part of the rounded right arrow image does not deform.
[0244] In yet other examples, before displaying the second image, the method may further include: in response to a user's operation of drawing a stretch dividing line, determining and displaying a stretch dividing line, wherein the pixels on the stretch dividing line include the target pixels, i.e., the pixels on the stretch dividing line include pixels of the deformable element repeated along the first direction. It should be understood that the user can draw a stretch dividing line on the first image based on a touch gesture or a mouse click, read the coordinate information on the stretch dividing line, and when stretching the image, perform image stretching based on the stretch dividing line.
[0245] Exemplarily, the pixels on the stretched dividing line may not include pixels on non-deformable elements. Exemplarily, the pixels on the stretched dividing line may not include pixels on non-deformable elements or repeatable elements. This ensures that when the first image is stretched based on the stretched dividing line, the deformable and repeatable elements in the first image do not deform, thereby avoiding affecting the image layout of the stretched second image.
[0246] In one example, the stretching dividing line may include a first dividing line. For example, the first dividing line is determined in response to a first operation of the user, where the first operation may be an operation of drawing a dividing line. The first dividing line may be set close to a first element, which is a non-deformable element on the first image, that is, the first dividing line may be set within a preset range of the first element.
[0247] For example, 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, the first image is stretched along a first direction (horizontally), and the pixels on the first dividing line can be copied and filled in the target area to form a second image.
[0248] In another example, the stretching dividing line may include a first dividing line and a second dividing line, where the second dividing line and the first dividing line are respectively located on either side of a first element, where the first element is a non-deformable element on the first image. For example, in response to a first user operation, the first dividing line is determined; in response to a second user operation, the second dividing line is determined; and the first dividing line and the second dividing line may be respectively located on either side of the first element.
[0249] For example, Figure 14 As shown, the user can draw a dividing line 1 and a dividing line 2 on both sides of the non-deformable element of the first image respectively. When the first image is stretched along the first direction (horizontally), the areas on both sides of the non-deformable element can be filled based on the pixels on the dividing line 1 and the dividing line 2, so that the second image can be displayed on the electronic device.
[0250] For example, Figure 15 As shown, the user can draw multiple dividing lines on the first image, for example, 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 the first direction (horizontally), 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 the second image after horizontal stretching can be displayed on the electronic device.
[0251] In another example, the non-deformable elements on the first image include a first element and a second element, the second element is arranged at intervals with the first element along the first direction, and the first element and the second element are located inside the deformable element, and the method further includes: in response to a first operation of the user, determining a first dividing line, the first dividing line is close to the first element, that is, the first dividing line is set within a preset range of the first element; in response to a second operation of the user, determining a second dividing line, the second dividing line is close to the second element, that is, the second dividing line is set within a preset range of the second element.
[0252] For example, Figure 16 As shown, the first image may include two horizontal dividing lines, one of which may be located near the first element (e.g., review goal), and the other may be located near the second element (e.g., evaluation result). The first image may include two vertical dividing lines, each of which may be located on either side of the first element (e.g., analysis of cause) or the second element (e.g., summary of experience).
[0253] It should be understood that in some embodiments, the position of the non-deformable element on the first image may remain unchanged or may change, for example, the position of the first element does not change, and the position of the second element changes from the first position to the second position. Figure 16 As shown in the figure, when the first image is stretched horizontally, the relative positions of the characters "REPLAY," "Review Objectives," and "Analyze Reasons" remain unchanged, while the relative positions of the characters "Date _______," "Evaluation Results," and "Summary of Experience" change, all moving to the right. When the first image is stretched vertically, the relative positions of the characters "REPLAY," "Date _______," "Review Objectives," and "Evaluation Results" remain unchanged, while the relative positions of the characters "Analyze Reasons" and "Summary of Experience" change, all moving downward.
[0254] In some examples, the target area also includes background pixels, and the pixel values on the background pixels are filled according to the pixel values on the stretched segmentation line. Figure 16 As shown, the background of the rectangular image is filled with shaded areas, while the background of the rounded image is filled with white areas. The rounded image background partially covers the rectangular image. After image stretching, the background pixels in the target area are filled with pixel values based on the pixel values on the stretching dividing line, so that the stretched image matches the background of the first image.
[0255] In some examples, before displaying the second image, the method 300 further includes: displaying the first image and a first area, where the first area is an area between a boundary of the first image and a boundary of the second image, and a display color of the first area belongs to the same color system as a background color of the first image.
[0256] For example, Figure 17 As shown, in response to the user clicking on the first image, a drag box will be displayed at the border position of the first image. By dragging the drag box, the first image can be stretched or shortened horizontally, stretched or shortened vertically, enlarged or reduced proportionally, etc. Taking into account the different performance of electronic devices, in some examples, in response to the user dragging the right line of the drag box along the first direction (horizontally), an intermediate image can be displayed on the electronic device. The intermediate image includes the first image and a first area. The first area is the area between the boundary of the first image and the boundary of the second image, and the display color of the first area belongs to the same color system as the background color of the first image. For example, the first area can be filled with the background color of the first image with a transparency of 30%. Furthermore, the above method can be used to fill the first area, and finally display the stretched second image. The second image is stretched horizontally relative to the first image, but the non-deformable elements in the second image are not deformed, and the layout is neat and beautiful.
[0257] In some examples, in response to a user clicking on the first image, a drag box is displayed within a preset range of the outer frame (outer contour) of the first image, and the first image can be proportionally enlarged or reduced by dragging the drag box. Figure 18 As shown, in response to the user dragging the four corner points ( Figure 18 Any corner point of the black dots shown in the figure displays a second image, where the second image is an image obtained by enlarging the first image in equal proportion.
[0258] In some examples, in response to the user clicking on the first image, a drag box is displayed within a preset range of the outer frame (outer contour) of the first image, and the first image can be horizontally stretched or shortened by dragging the drag box. Figure 19 As shown, in response to the user dragging the left and right midpoints ( Figure 19 Any midpoint among the black dots shown in the figure) displays a second image, where the second image is an image obtained by horizontally stretching the first image.
[0259] In some examples, in response to a user clicking on the first image, a drag box is displayed within a preset range of the outer frame (outer contour) of the first image, and the first image can be vertically stretched or shortened by dragging the drag box. Figure 20 As shown, in response to the user dragging the upper and lower midpoints ( Figure 20 Any midpoint among the black dots shown in ) displays a second image, where the second image is an image obtained by longitudinally stretching the first image.
[0260] It should be understood that when the user changes the size and aspect ratio of the first image by touching or dragging the mouse, the electronic device can identify the direction and size of the user's dragging, and adaptively change the image in real time to make it the target size, avoiding deformation and distortion of elements and ensuring visual aesthetics.
[0261] For example, Figure 21 As shown, during the image stretching or shrinking process, the elements on the image will not be deformed or distorted, and the overall image design layout remains unchanged. During the change process of Image 1 to Image 6, the image can be stretched or shrunk, but the size of the stretched / shrunk image will still be larger than the original image (i.e., Image 1). Specifically: based on image 1, by ① dragging the four corner points of the bounding box outward, the image can be proportionally enlarged to obtain image 2, and the size of image 2 is larger than that of image 1; based on image 2, by ② dragging the left and right midpoints of the bounding box outward, the image can be horizontally stretched to obtain image 2, and the size of image 3 is larger than that of image 2 and image 1; based on image 3, by ③ dragging the upper and lower midpoints of the bounding box outward, the image can be vertically stretched to obtain image 4, and the size of image 4 is larger than that of image 3, image 2, and image 1; based on image 4, by ④ dragging the left and right midpoints of the bounding box inward, the image can be horizontally shrunk to obtain image 5, and the size of image 5 is smaller than that of image 4 but larger than that of image 1; based on image 5, by ⑤ dragging the upper and lower midpoints of the bounding box inward, the image can be vertically shrunk to obtain image 6, and the size of image 6 is smaller than that of image 5 but larger than that of image 1.
[0262] It should be noted that the image stretching method provided in the embodiment of the present application can achieve proportional magnification, horizontal stretching and vertical stretching of the image, so that the stretched image can maintain the original layout and alignment without causing distortion of elements, ensuring that the element layout is consistent with the original. Figure 1 In addition, for repeatable elements in the image, they can be adaptively added according to the arrangement rules of the repeatable elements, so that the image layout can adapt to the changes in the image aspect ratio.
[0263] Figure 22 FIG5 is a schematic flow chart of an image stretching method provided by an embodiment of the present application. The image stretching method 500 may include S510 to S550.
[0264] S510: Determine a stretching direction and a stretching size of the first image.
[0265] Exemplarily, when the user stretches the first image, the electronic device may detect the stretching direction and stretching size of the first image.
[0266] The content of this step can refer to the relevant description in S320 and will not be repeated here.
[0267] S520: Determine the element type included in the first image according to the stretching direction.
[0268] Exemplarily, after the electronic device acquires the first image, it may perform hierarchical classification processing on the elements included in the first image based on the stretching direction to determine the element type included in the first image. The element type may include non-deformable elements and deformable elements. In some examples, the first image may also include repeatable elements, and the element type may also include repeatable elements. For details about the first image, please refer to S310 and will not be repeated here.
[0269] In some examples, elements can be classified through manual annotation. For example, various attributes of elements in the first image can be pre-annotated, mainly including the coordinates of the surrounding contour points of 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 level.
[0270] For example, Figure 8 In the first image shown, the outermost rectangular rectangle belongs to the first contour level (or the first element level); the font (i.e., "TO DO LIST" and "DATE _____") and the rounded rectangle within the rectangular rectangle belong to the second contour level (or the second element level); and the innermost black circle and straight line belong to the third contour level (or the third element level). When the first image is stretched horizontally, the rectangular rectangle is a deformable element, the "TO DO LIST" and "DATE _____" are non-deformable elements, the rounded rectangle is a deformable element, the black circle is a repeatable element, and the straight line is a deformable element. When the first image is stretched vertically, the rectangular rectangle is a deformable element, the "TO DO LIST" and "DATE _____" are non-deformable elements, and the black circle and straight line are repeatable elements.
[0271] For example, Figure 9In the first image shown, the outermost rectangular rectangle belongs to the first contour level (or first element level); the key pattern, text password manager, characters, etc., the rounded rectangle on the same side, and the dashed line segment belong to the second contour level (or second element level); the innermost account number, password, horizontal line segment, and vertical line segment belong to the third contour level (or third element level). When the first image is stretched horizontally, the key pattern, text password manager, characters, etc., the account number, and password are non-deformable elements, while the rounded rectangle on the same side, the dashed line segment, and the horizontal line segment are deformable elements. When the first image is stretched vertically, the rectangular rectangle is a deformable element, the key pattern, text password manager, characters, etc. are non-deformable elements, and the whole formed by the rounded rectangle on the same side and the dashed line segment are repeatable elements.
[0272] In other examples, when determining the element type included in the first image, the image classification method 600 provided in this application may be used. The classification method 600 may include S610 to S640. The specific content will be combined with the following Figure 23 and Figure 24 Provide explanation.
[0273] S530: Determine a stretching segmentation line according to the element type and stretching direction of the first image.
[0274] In this step, the stretching segmentation line may be determined according to the element type and stretching direction of the first image obtained in S520.
[0275] It should be understood that the stretching dividing line may be generated by the electronic device based on a preset rule, may be pre-configured in the background, or may be specified by the user in real time through gestures.
[0276] For example, starting from the center of the first image, the repeatable elements are ignored, and the non-deformable elements in the first image are bypassed. When passing through the deformable elements, the line is generally adjusted to the center line of the deformable elements. 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 the preset range of the non-deformable elements. In addition, the pixels on the stretching dividing lines include the pixels of the deformable elements that repeat along the stretching direction.
[0277] The content of this step can refer to the relevant description about stretching the dividing line in S330, which will not be repeated here.
[0278] S540: Determine a target area according to the first image, the stretching direction, and the stretching size.
[0279] The target area may be located on the second image, and the size of the target area along the stretching direction is equal to the stretching size of the first image. It should be understood that the specific content of the target area can refer to the relevant description of the target area in S330, which will not be repeated here.
[0280] S550: Fill the target area according to the pixels on the stretched segmentation line.
[0281] In this step, the pixel values on the segmentation line may be repeatedly stretched to fill the target area, thereby obtaining a stretched second image.
[0282] In some examples, the method 500 may further include: if the repeatable element is located on both sides of the stretching dividing line, the target area also needs to be filled with the repeating element.
[0283] It should be understood that the specific content of this step will be combined with the attached Figure 25 Provide detailed explanation.
[0284] Figure 23 FIG6 is a schematic flow chart of an image classification method provided by an embodiment of the present application. The image classification method 600 may include S610 to S640.
[0285] S610: Acquire a first image.
[0286] The content of this step can refer to the relevant description in S310 and will not be repeated here.
[0287] S620: Binarize the first image to determine a binarized image.
[0288] In this step, the first image may be binarized to determine a binarized image, which is generally an image with only two colors (usually black and white). The specific process of the binarization process can be referred to in the prior art.
[0289] S630: Perform contour detection and line segment detection on the binary image to determine hierarchical elements of the first image.
[0290] In this step, the contour detection and line segment detection can be performed on the binary image to obtain the hierarchical elements of the first image. That is, the first image can be hierarchical, for example, Figure 8 In the first image shown, the outermost rectangular rectangle belongs to the first contour level (or the first element level, the bottommost element level); the font (i.e., TO DO LIST and DATE _____) and the rounded rectangle inside the rectangular rectangle belong to the second contour level (or the second element level, the middle element level); and the innermost black circle and straight line belong to the third contour level (or the third element level, the topmost element level).
[0291] S640: Classify the elements at each level according to the stretching direction and determine the element type of the elements at each level.
[0292] It should be understood that each level of elements in 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 elements in the first image and determine the element type of each level of elements.
[0293] For example, Figure 24 As shown, step S640 may specifically include:
[0294] S641: Input a first element of the first-level elements. The first element may be any element in the first-level elements.
[0295] S642 , calculating the shape similarity between the first element and other elements, calculating the area intersection-over-union ratio between the first element and other elements, and calculating the distance between the average color vector in the first element and the average color vector of other elements.
[0296] The specific calculation methods of the shape similarity, the area intersection-to-union ratio, and the distance of the average color vector can be referred to in the prior art and will not be described in detail here.
[0297] S643: If the shape similarity, area intersection-over-union ratio, and average color vector distance between the first element and other elements all meet a preset threshold, the first element is determined to be a repeatable element. Otherwise, the first element is determined to be a non-repeatable element.
[0298] It should be understood that the degree of shape similarity can be used to characterize the shape similarity relationship between the first element and other elements (such as the second element), the area intersection 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).
[0299] If the degree of shape similarity between the first element and other elements (such as the second element) is greater than the first threshold, the shapes of the first element and other elements can be considered to be approximately the same; if the area intersection and union ratio of the first element and other elements (such as the second element) is greater than the second threshold, the areas 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, the colors of the first element and other elements can be considered to be approximately the same.
[0300] Generally, if the first element and the second element have approximately the same shape, approximately the same area, and approximately the same color, then they are considered to be identical repeatable elements. Otherwise, the first element is considered to be a non-repeatable element, meaning that the first element and the other elements have different shapes, areas, or colors.
[0301] It should be understood that in the embodiments of the present application, the shape similarity, area intersection-to-union ratio, and average color vector distance are mainly used as parameters to determine the relationship between the shape, area, and color of the first element and the second element, but the present application is not limited to this. That is to say, in other embodiments, other parameters that characterize the similarity of shape, area, and color can be used to determine whether two elements are the same.
[0302] Furthermore, after determining the repeatable elements on the first image, the repeatable elements may be further grouped according to equal rows and equal intervals or equal columns and equal intervals.
[0303] S644: If it is determined that the first element is a non-repeatable element, further determine whether the first element is located in the deformable image library. If the first element is located in the deformable image library, determine that the first element is a deformable element; otherwise, determine that the first element is a non-deformable element.
[0304] It should be understood that through S643, the repeatable elements and non-repeatable elements on the first image can be determined. Further, based on the deformable image library, it can be determined whether the first element is a deformable element. If the first element is in the deformable image library, it means that the first element is a deformable element; otherwise, the first element is confirmed to be a non-deformable element.
[0305] Exemplarily, the deformable graphics library may include multiple deformable image templates, that is, the first element may be matched with a deformable image template in the deformable graphics library. If a match is found, it indicates that the first element is a deformable element; if a match is found, it indicates that the first element is a non-deformable element.
[0306] Figure 25 FIG. 7 is a schematic flow chart of another image stretching method provided by an embodiment of the present application. The image stretching method 700 may include S701 to S714.
[0307] S701: Acquire a first image, element types included in the first image, and a stretching size and stretching direction of the first image.
[0308] S702 : Determine n stretching segmentation lines (n≥1) according to the first image, the element types included in the first image, and the stretching direction of the first image.
[0309] S703, determine whether there is a stretching dividing line in the stretching direction. If so, continue to S704; if not, exit the process.
[0310] S704: Determine whether the repeatable element is located on both sides of the stretch dividing line.
[0311] If the repeatable element is not located on both sides of the stretch dividing line, then S705 to S707 are executed; if the repeatable element is located on both sides of the stretch dividing line, then S706 to S710 are executed.
[0312] When the repeatable element is not on both sides of the extrusion dividing line, you can perform the following steps:
[0313] S705: Determine a target area according to the first image and the stretching size.
[0314] S706: Copy and stretch the pixels on the dividing line to fill the target area.
[0315] In this step, the target width of each segmentation line to be filled can be calculated by dividing the total filling width by the number of segmentation lines, and the pixels on the segmentation line are copied to fill the target width.
[0316] S707: Display a second image, where the second image includes the target area.
[0317] It should be understood that when the repeatable elements are not located on both sides of the stretch dividing line, the pixels in the target area of the second image can be filled by repeatedly copying the pixels on the stretch dividing line.
[0318] When a repeatable element is on both sides of the extrusion split line, you can perform the following steps:
[0319] S708: Remove the repeatable elements from the first image.
[0320] It should be understood that this step is mainly to extract the repeatable elements from the first image. The repeatable elements are the bottom-level repeating elements distributed on both sides of the dividing line. For example, Figure 8 As shown in FIG, the bottom layer of repeated elements is the innermost black circle and straight line segment, that is, the repeated elements are the black circle and straight line segment; for example, Figure 9 As shown, the bottom-most repeated element is the second element level, that is, the rounded rectangular box on the same side and the content inside the box, that is, the rounded rectangular box on the same side and the content inside the box are repeated.
[0321] S709 , using the average value of pixels within a preset range around the repeatable element to fill the pixel values at the position corresponding to the repeating element on the first image.
[0322] It should be understood that after the repeatable element is removed from the first image, a hole will exist in the first image, which needs to be filled. In some examples, the hole can be filled using the average value of pixels within a preset range around the repeatable element to repair the background of the first image.
[0323] S710: Determine a target area according to the first image and the stretching size.
[0324] S711, copying and stretching the pixels on the dividing line to fill the target area.
[0325] S712 , determining the number and positions of all repeatable elements according to the stretching size, the maximum distance of the repeatable elements, the spacing between adjacent repeatable elements, and the position of the first repeatable element.
[0326] In this step, first, the total number of repeatable elements that need to be filled on the stretched image can be determined based on the stretching size, the maximum distance between repeatable elements (i.e., the distance between the first repeatable element and the last repeatable element) and the spacing between adjacent repeatable elements; then, starting from the position of the first repeatable element, fill in the elements in sequence according to the spacing between the repeatable elements to determine the positions of all repeatable elements.
[0327] That is, the repeatable elements may be increased at equal intervals in the stretching direction, and corresponding positions of the target area and other areas of the second image may be filled with repeatable elements.
[0328] S713: Fill the target area and other areas of the second image with repeatable elements.
[0329] S714: Display a second image, where the second image includes the target area.
[0330] It should be understood that when repeatable elements are located on both sides of the stretch dividing line, it is first necessary to remove all repeatable elements from the first image and repair the background holes of the first image; then, by repeatedly copying the pixels on the stretch dividing line, the pixels of the target area of the second image are filled; 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.
[0331] It should be noted that the places not described in detail in the above steps can be referred to Figure 3 、 Figures 22 to 24 The contents in will not be repeated.
[0332] The image stretching method provided by the embodiment of the present application can display the stretched image in real time on the electronic device without high-complexity calculations, and the image processing speed is fast and efficient. In addition, the image can be magnified proportionally, stretched horizontally and stretched vertically, so that the stretched image can maintain the original layout and alignment without causing distortion of elements, ensuring that the element layout is consistent with the original. Figure 1In addition, for repeatable elements in the image, they can be adaptively added according to the arrangement rules of the repeatable elements, so that the image layout can be adaptively changed with the image aspect ratio.
[0333] Figure 26 This is a schematic flow chart of an image shrinking method provided by an embodiment of the present application. Figure 26 As shown, the image shrinking method 400 may include S410 to S430, and the image shrinking method 400 may be applied to electronic devices.
[0334] S410: Acquire a first image, where the first image may include deformable elements and non-deformable elements.
[0335] In which, the first image may include a target area and a non-target area, the target area may be a contraction area on the first image, the target area includes target pixels, the target pixels are pixels of the deformable element repeated along the first direction, and the first direction is the direction of image contraction; the non-deformable element is located outside the target area.
[0336] In some examples, such as Figure 27 As shown in (a) of FIG. , the target area may be located in a portion of the bottom of the first image, and the non-target area is the area of the first image excluding the target area. The first image is compressed upward along a first direction to form a second image. The target area of the first image may be a portion of the first image that is shortened relative to the second image. The target area includes pixels of the deformable element (two rectangles) that repeat along the first direction, and the non-deformable element (the character REMNDER) is located outside the target area.
[0337] In other examples, such as Figure 27 As shown in (b), the target area can be located in the middle part of the first image, and the non-target area is the area of the first image excluding the target area, that is, the non-target area includes the first part and the second part. For example, when shrinking 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 area of the first image is deleted, and the resulting second image does not include the target area, that is, the second image includes the non-target area.
[0338] It should be understood that for other contents of the first image, reference may be made to the relevant description in S310 , which will not be repeated here.
[0339] S420: Perform a shrink operation on the first image along a first direction to determine a shrunken size of the first image.
[0340] The shrunk size of the first image may be equal to the size of the target area on the first image shortened along the first direction. That is, the second image may be obtained by deleting the target area on the first image.
[0341] It should be understood that the shrinking operation in this step is the opposite operation process to the stretching operation in S320. The content of this step can be similarly referred to the description of S320, and will not be repeated here.
[0342] S430: Display a second image, wherein the second image includes a non-target area on the first image.
[0343] It should be understood that the second image is the image obtained by 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 the target area is deleted from the first image. That is, the second image includes the non-target area in the first image. In other words, by repeatedly deleting the deformable elements in the first image along the first direction (the shrinking direction), the purpose of shortening the first image can be achieved.
[0344] In some examples, the first image further includes a plurality of 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 area includes at least one repeatable element. In other words, at least one repeatable element may be deleted from the first image along the first direction, i.e., the at least one repeatable element included in the target area is deleted, so that the number of repeatable elements in the second image is reduced.
[0345] It will be appreciated that when shrinking the first image, the number of repeatable elements within the first image may decrease, 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 may decrease. During the image shrinking process, overlapping elements cannot occur. In other words, further shrinking of the image is not supported if the distance between two elements is less than a preset range.
[0346] For example, in response to the user clicking on the first image, a drag box will be displayed at the border of the first image, and the first image can be shortened horizontally, shortened vertically, or reduced in proportion by dragging the drag box. Figure 28 As shown, in response to the user clicking on the first image, a drag box is displayed within a preset range of the outer frame (outer contour) of the first image, and the first image can be shortened vertically by dragging the drag box. In response to the user dragging the upper and lower midpoints ( Figure 28The second image is displayed by selecting any midpoint among the black dots shown in the figure. The second image is obtained by vertically shortening the first image. Furthermore, when the minimum contraction size is reached, a prompt box may pop up on the display interface of the electronic device. For example, a prompt such as "Please note that the image has reached the minimum contraction size" may appear in the prompt box, notifying the user that the currently displayed second image is the minimum contraction size corresponding to the first image and cannot be further contracted.
[0347] 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 value, the distance between elements in the second image is less than a preset distance, the minimum shrinkage size cannot be larger than the size of the deformable element, etc.
[0348] It should also be understood that when the user changes the size and aspect ratio of the first image by touching or dragging the mouse, the electronic device can identify the direction and size of the user's dragging, and adaptively change the image in real time to make it the target size, avoiding deformation and distortion of elements and ensuring visual aesthetics.
[0349] It should be noted that the image shrinking method provided in the embodiment of the present application can realize proportional reduction, horizontal shrinkage and vertical shrinkage of the image, so that the shrunken image can maintain the original layout and alignment without causing distortion of elements, ensuring that the element layout is consistent with the original. Figure 1 In addition, for repeatable elements in the image, they can be adaptively reduced according to the arrangement rules of the repeatable elements, so that the image layout can adaptively change with the image aspect ratio.
[0350] Figure 29 FIG. 8 is a schematic flow chart of another method for image shrinkage provided by an embodiment of the present application. The method 800 for image shrinkage may include steps S810 to S850.
[0351] S810: Determine a shrinking direction and shrinking size of the first image.
[0352] The content of this step can refer to the above Figure 28 The description of the shrinking direction and shrinking size will not be repeated here.
[0353] S820: Determine the element type of the first image according to the shrinking direction.
[0354] The content of this step can refer to the relevant description in S520 and will not be repeated here.
[0355] S830: Determine a shrinkage dividing line according to the element type and shrinkage direction of the first image.
[0356] In this step, the shrinkage dividing line may be determined according to the element type and shrinkage direction of the first image obtained in S810.
[0357] It should be understood that the shrinking dividing line may be generated by the electronic device based on a preset rule, may be pre-configured in the background, or may be specified in real time by the user through a gesture.
[0358] For example, starting from the center of the first image, the repeatable elements are ignored, and the non-deformable elements in the first image are bypassed. When passing through the deformable elements, the centerline of the deformable elements is generally adjusted. If there are multiple non-deformable elements in the first image, multiple shrinking dividing lines can be set, and the shrinking dividing lines are set within the preset range of the non-deformable elements. In addition, the pixels on the shrinking dividing lines include the pixels of the deformable elements that repeat along the shrinking direction.
[0359] The content of this step can refer to the relevant description about the dividing line in S330, which will not be repeated here.
[0360] S840: Determine a target area according to the first image, the shrinking direction, and the shrinking size.
[0361] The target area may be located on the first image (i.e., the original image), and the size of the target area along the shrinking direction is equal to the shrinking size of the first image. It should be understood that the specific content of the target area can be referred to the relevant description of the target area in S410, and will not be repeated here.
[0362] S880: Delete the target area according to the pixels on the shrinking dividing line.
[0363] In this step, the pixel values on the shrinkage dividing line are repeatedly deleted to achieve the purpose of deleting the target area, thereby obtaining a shrunken second image.
[0364] In some examples, the method 800 may further include: if the repeatable element is located on both sides of the shrinking dividing line, deleting the repeatable element on the target area.
[0365] It should be understood that the specific content of this step will be combined with the attached Figure 29 Provide detailed explanation.
[0366] Figure 30 This is a schematic flowchart of another image shrinkage method provided in an embodiment of the present application.
[0367] It should be noted that the image shrinking method 900 is different from the above-mentioned image stretching method 700 in that the stretching process is changed to a shrinking process and the Figure 25 S706 and S713 in. Figure 24The process of stretching the image shown in the figure mainly involves copying the pixel values on the segmentation line and adding repeatable pixels in the target area. Figure 30 The shrinking process in the image mainly deletes the pixel values on the segmentation line and deletes the repeatable pixels in the target area. The following mainly explains the differences between the two. For details not described in detail, please refer to the above Figure 25 and Figure 26 Related description.
[0368] The image shrinking method 900 may include steps S901 to S914 .
[0369] S901: Acquire a first image, element types included in the first image, and a shrinking size and shrinking direction of the first image.
[0370] It should be noted that the shrinkage size should be greater than or equal to the above-mentioned minimum shrinkage size.
[0371] It should be understood that when shrinking a first image, the number of repeatable elements within the first image may decrease, 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 may decrease. During the image shrinking process, overlapping elements cannot occur. In other words, further shrinking of the image is not supported if the distance between two elements is less than a preset range.
[0372] S902 : Determine n shrinkage dividing lines (n≥1) according to the first image, the element types included in the first image, and the shrinkage direction of the first image.
[0373] S903: Determine whether there is a shrinkage dividing line in the shrinkage direction. If yes, proceed to S904.
[0374] S904: Determine whether the repeatable element is located on both sides of the shrinking dividing line.
[0375] If the repeatable element is not located on both sides of the shrinking dividing line, then S905 to S909 are executed; if the repeatable element is located on both sides of the shrinking dividing line, then S906 to S910 are executed.
[0376] When a repeatable element is not on either side of a shrink divider, you can perform the following steps:
[0377] S905, determine the target area based on the first image and the contraction size. The target area can refer to Figure 26 Related description in .
[0378] S906 , repeatedly deleting pixels on the shrinkage dividing line to delete the target area of the first image.
[0379] S907: Display a second image. The size of the second image is smaller than that of the first image.
[0380] That is, when the repeatable elements are not located on both sides of the stretching dividing line, the target area can be deleted by repeatedly deleting pixels on the stretching dividing line, so that the obtained second image does not include the target area.
[0381] When a repeatable element is on both sides of a shrinking divider, you can perform the following steps:
[0382] S908: Remove the repeatable elements from the first image.
[0383] S909: Use the average value of pixels 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.
[0384] S910: Determine a target area according to the first image and the contraction size.
[0385] S911 , repeatedly deleting pixels on the shrinkage dividing line to delete the target area of the first image.
[0386] S912 , determining the number and positions of all repeatable elements according to the shrinkage size, the maximum distance of repeatable elements, the spacing between adjacent repeatable elements, and the position of the first repeatable element.
[0387] In this step, the total number of repeatable elements to be filled in the shrunk image can be determined based on the shrunk 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 with the position of the first repeatable element, filling is performed sequentially based on the spacing between repeatable elements to determine the positions of all repeatable elements. It should be understood that the number of repeatable elements in the second image is the number of repeatable elements in the first image minus the number of repeatable elements that have been reduced.
[0388] S913: Fill the second image with repeatable elements.
[0389] It should be understood that the total number of repeatable elements that need to be filled in the image after shrinkage (i.e., the second image) is less than the total number of repeatable elements in the image before shrinkage (i.e., the first image). In other words, the reduced repeatable elements are the repeatable elements in the target area of the first image.
[0390] S914: Display a second image. The size of the second image is smaller than that of the first image.
[0391] That is to say, when repeatable elements are located on both sides of the shrinking dividing line, it is first necessary to remove all repeatable elements from the first image and repair the background holes of the first image; then, the target area of the first image is deleted by repeatedly deleting the pixels on the shrinking dividing line; finally, based on the total number of repeatable elements on the second image and the spacing between the repeatable elements, the repeatable elements are filled in sequence starting from the first repeatable element, that is, the repeatable elements in the target area of the first image have been deleted.
[0392] The image shrinking method provided by the embodiment of the present application can display the shrunken image in real time on the electronic device without the need for highly complex calculations, and the image processing speed is fast and efficient. In addition, the image can be enlarged in proportion, shrunk horizontally and shrunk vertically, so that the shrunken image can maintain the original layout and alignment without causing distortion of elements, ensuring that the element layout is consistent with the original. Figure 1 In addition, for repeatable elements in the image, they can be adaptively added according to the arrangement rules of the repeatable elements, so that the image layout can be adaptively changed with the image aspect ratio.
[0393] Combination of the above Figures 3 to 30 The image display method provided by the present application is introduced in detail. The image display method may include the above-mentioned image stretching method and image shrinking method.
[0394] Figure 31 Another image display device 1000 provided in an embodiment of the present application. This device 1000 may have the functionality of the electronic device in the aforementioned method embodiment and may be used to execute the steps performed by the functionality of the electronic device in the aforementioned method embodiment. This functionality may be implemented in hardware, or in software or hardware executing corresponding software implementations. The hardware or software may include one or more modules corresponding to the aforementioned functionality.
[0395] In a possible implementation, the image display apparatus 1000 may include an acquisition module 1010 and a processing module 1020 , and the acquisition module 1010 and the processing module 1020 are coupled to each other.
[0396] The acquisition module 1010 can be used to support the electronic device in acquiring user input, such as acquiring the user's touch operation on the display screen of the electronic device.
[0397] The processing module 1020 is used to support the electronic device in executing the processing actions in the above method embodiment, such as determining a stretching segmentation line according to the element type and stretching direction of the first image.
[0398] Optionally, the image processing apparatus 1000 may further include a storage module 1030 for storing program codes and data of the display processing apparatus 1000 .
[0399] Optionally, the image processing apparatus 1000 may further include a display module, and the display module is used to display the image before and after stretching, or to display the image before and after shrinking.
[0400] Figure 32 An electronic device 2000 is provided in an embodiment of the present application. 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 configured to execute instructions stored in the memory to control the transceiver 2020 to send and / or receive signals.
[0401] Optionally, the electronic device 2000 further includes a memory 2030 for storing instructions.
[0402] In some embodiments, the processor 2010 and memory 2030 may be combined into a processing device, and the processor 2010 is configured to execute program codes stored in the memory 2030 to implement the above functions. In specific implementations, the memory 2030 may also be integrated into the processor 2010 or independent of the processor 2010.
[0403] In some embodiments, the transceiver 2020 may include a receiver (or receiver) and a transmitter (or transmitter).
[0404] The transceiver 2020 may further include an antenna, and the number of antennas may be one or more. The transceiver 2020 may be a communication interface or an interface circuit.
[0405] When the electronic device 2000 is a chip, the chip includes a transceiver module and a processing module. The transceiver module may be an input / output circuit or a communication interface; the processing module may be a processor, microprocessor, or integrated circuit integrated on the chip.
[0406] This embodiment further provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the image stretching / contraction method in the above-mentioned embodiment.
[0407] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement the image stretching / shrinking method in the above-mentioned embodiment.
[0408] In addition, embodiments of the present application further provide a device, which may be a chip, component, or module, and may include a processor and memory connected thereto. The memory is configured to store computer-executable instructions. When the device is in operation, the processor executes the computer-executable instructions stored in the memory, causing the chip to perform the image stretching / shrinking methods described in the aforementioned method embodiments.
[0409] Among them, the electronic device, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0410] Those skilled in the art will appreciate that the units and algorithm steps of each example 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 performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel 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.
[0411] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0412] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0413] The units described as separate components may or may not be physically separate, and 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 these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0414] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0415] If the functions are implemented in the form of 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 the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0416] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A method for image display, characterized in that: include: In response to a user operation of stretching a first image along a first direction, determining a stretched size of the first image, the first image including a deformable element and a non-deformable element, the deformable element and the non-deformable element being determined based on the first direction; A second image is displayed according to the stretched size, wherein a target area of the second image includes target pixels, the target pixels are pixels of the deformable element repeated along the first direction, and the non-deformable element is located outside the target area.
2. The method according to claim 1, characterized in that The first image further includes a repeatable element, and the method further includes: In a case where the first direction is the same as an arrangement direction of the repeatable elements, the repeatable elements are 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 a first operation of a user, a first dividing line is determined, where 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 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 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 comprises: In response to a second operation of the user, a second dividing line is determined, where the second dividing line and the first dividing line are located on both sides of the first element, or the second dividing line and the first dividing line form dividing lines in different directions.
8. The method according to claim 6, characterized in that The non-deformable element further includes a second element, the second element and the first element are spaced apart along the first direction, and the first element and the second element are located inside the deformable element. The method further comprises: In response to a second operation of the user, a second dividing line is determined, and the second dividing line 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 segmentation line.
10. The method according to any one of claims 1 to 9, characterized in that The non-deformable elements include a third element, and a relative position of the third element on the first image is different from a relative position of the third element 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: An intermediate image is displayed, where the intermediate image includes the first image and a first area, where the first area is between a boundary of the first image and a boundary of the second image, and a display color of the first area and a background color of the first image belong to the same color system.
12. A method for image display, characterized in that: include: determining a stretching direction and a stretching size of the first image; determining, according to the stretching direction, an element type included in the first image, where the element type includes a deformable element and a non-deformable element; Determining a stretching segmentation line according to the element type and the stretching direction; determining a target area of a second image according to the first image, the stretching direction, and the stretching size, where the second image is a stretched image; The target area is filled according to the pixels on the stretched segmentation line.
13. The method according to claim 12, characterized in that The element type also includes a repeatable element, and the method further includes: If the repeatable elements are located on both sides of the stretching dividing line, the target area is filled with the repeatable elements.
14. The method according to claim 13, characterized in that Before filling the target area with the repeatable element, the method further includes: removing the repeatable element from the first image; The pixel values at the position corresponding to the repeatable element on the first image are filled using the average value of the pixels within a preset range around the repeatable element.
15. The method according to claim 13 or 14, characterized in that Filling the target area with the repeatable element comprises: determining a total number of repeatable elements that need to be filled on the second image according to the stretched size, a maximum distance between repeatable elements on the first image, and a spacing between adjacent repeatable elements; The filling position of the repeatable elements on the second image is determined according to the total number of the repeatable elements, the position of the first repeatable element and the spacing between the adjacent repeatable elements.
16. The method according to any one of claims 12 to 15, characterized in that The determining, according to the stretching direction, the element type included in the first image includes: performing binarization processing on the first image to determine a binarized image corresponding to the first image; Performing contour detection and line segment detection on the binary image to determine hierarchical elements of the first image; According to the stretching direction, the elements of each level are classified to determine the element type of the elements of each level.
17. The method according to claim 16, characterized in that The hierarchical elements include first-level elements, and determining the element type of the elements of each level includes: If the shape similarity, area intersection-over-union ratio, and average color vector distance between the first element of the first-level elements and the second element of the first-level elements all meet preset conditions, then the first element is determined to be a repeatable element; If any one of the shape similarity, area intersection-over-union ratio, and average color vector distance between the first element of the first level element and the second element of the first level element does not meet the preset condition, the first element is determined to be a non-repeatable element.
18. The method according to claim 17, characterized in that In the case where 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 determining that the first element is a deformable element; If it is determined that the first element is not located in the deformable image library, the first element is determined to be a non-deformable 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. The method according to any one of claims 1 to 19, characterized in that The displaying of the second image according to the stretched size includes: The second image is displayed, wherein a size of a target area of the second image along the first direction is equal to the stretching size.
21. A device for displaying an image, characterized in that: The method comprises modules for implementing the method according to any one of claims 1 to 20.
22. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store program instructions, and the processor is used to call the program instructions to execute the method according to any one of claims 1 to 20.
23. A computer-readable storage medium, characterized in that A computer program is stored thereon, and when the computer program is executed by a computer, the method according to any one of claims 1 to 20 is implemented.
24. A computer program product, characterized in that The invention comprises a computer program code, which causes the method according to any one of claims 1 to 20 to be performed when the computer program code is run on a computer.
Citation Information
Patent Citations
Information processing method and electronic equipment
CN104461439A
Background picture generation method and device suitable for different aspect ratios, medium and equipment
CN114281230A
Stretchable display panel, display driving method thereof and display device
CN114927068A
Interface layout method and device
CN116382825A
Background picture display method and device, electronic equipment and storage medium
CN117472254A