Picture size zooming method and device, electronic equipment and readable medium
By traversing and referring to the color information of the picture with Hilbert curves, the pixel color of the zoomed picture is quickly determined, which solves the problems of large resource consumption and poor quality in the prior art, and achieves an efficient and natural picture scaling effect.
Patent Information
- Application Number
- CN202411729591.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-11-29
AI Technical Summary
Existing image scaling algorithms are difficult to generate high-quality scaling images when resource constraints are limited, and some algorithms such as bilinear interpolation and bicubital interpolation consume large computing resources, making it difficult to implement real-time applications.
Use the preset Hilbert curve to traverse the pixel points in the picture, expand the pixel points in the pending picture through the traversal order of the Hilbert curve, and combine the traversal order and color information of the reference picture to quickly determine the zoomed picture. Pixel color.
In the case of less computing resources, high-quality zoomed images are generated, avoiding jagged and mosaic effects, and achieving natural image scaling.
Smart Images

Figure CN119228636A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of picture processing, and in particular to a picture size scaling method, a picture size scaling device, an electronic device and a computer-readable medium. Background Art
[0002] In the prior art, when it is necessary to scale the size of an image, it is usually necessary to use algorithms such as a nearest neighbor algorithm, a bilinear interpolation algorithm, a bicubic interpolation algorithm, etc. to analyze information of pixels and other pixels around the pixels, and calculate the pixel values of the pixels in the scaled image, thereby completing the scaling of the image.
[0003] Among them, some algorithms, such as the nearest neighbor algorithm, although they take up relatively few computing resources, are prone to jagged patterns and mosaic effects in the scaled images, resulting in poor image scaling. Some algorithms, such as the bilinear interpolation algorithm and the bicubic interpolation algorithm, although they can generate images of good quality, usually require large computing resources and are difficult to use in real-time applications or when resources are limited. Summary of the invention
[0004] The embodiment of the present invention provides a method, device, electronic device and computer-readable storage medium for scaling the image size, so as to obtain a high-quality scaled image while using fewer computing resources.
[0005] The embodiment of the present invention discloses a method for scaling a picture size, comprising: Obtain a picture to be processed; the picture to be processed includes a number of pixels; Using a preset Hilbert curve to traverse the pixel points in the image to be processed; Expand the pixel points in the image to be processed based on the traversal order of the Hilbert curve for the pixel points in the image to be processed to obtain a pixel sequence to be processed; the pixel sequence to be processed includes at least one pixel point arranged in the traversal order of the Hilbert curve; The Hilbert curve is traversed through the pixel points in the reference image of a preset target size; Based on the traversal order of the Hilbert curve for the pixels in the reference picture and the colors of the pixels in the pixel sequence to be processed, the colors of the pixels in the reference picture are determined to obtain a target picture.
[0006] Optionally, the step of using a preset Hilbert curve to traverse the pixel points in the image to be processed includes: generating a Hilbert curve template including a Hilbert curve; Matching the Hilbert curve template with the image to be processed so that the Hilbert curve passes through the pixel points in the image to be processed; Any end of the Hilbert curve is taken as a starting point, and the extension mode of the Hilbert curve is taken as a traversal order to traverse the pixel points in the image to be processed.
[0007] Optionally, the step of expanding the pixel points in the image to be processed based on the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain the pixel sequence to be processed includes: According to the traversal order of the Hilbert curve for the pixel points in the image to be processed, the pixel points in the image to be processed are arranged in a one-dimensional straight line direction to obtain a pixel sequence to be processed.
[0008] Optionally, the step of taking any end of the Hilbert curve as a starting point and taking an extension mode of the Hilbert curve as a traversal order to traverse the pixel points in the image to be processed includes: Taking any end of the Hilbert curve as a starting point, taking the extension mode of the Hilbert curve as a traversal order, traversing the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, and taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as a connection starting point; Along the extension of the Hilbert curve, find the next boundary of the image to be processed that intersects with the Hilbert curve, and use the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point; Establishing a connection relationship between the connection starting point and the connection end point; Repeat the steps of taking the connection end point as the starting point, taking the extension mode of the Hilbert curve as the traversal order, traversing the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection starting point, searching for the next boundary of the image to be processed that intersects with the Hilbert curve along the extension mode of the Hilbert curve, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point, and establishing a connection relationship between the connection starting point and the connection end point until the traversal of the pixel points in the image to be processed is completed; Optionally, the step of arranging the pixel points in the image to be processed in a one-dimensional straight line direction according to the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain a pixel sequence to be processed includes: According to the traversal order of the Hilbert curve on the pixel points in the image to be processed and the connection relationship between the connection starting point and the connection end point, the pixel points in the image to be processed are arranged in a one-dimensional straight line direction to obtain a pixel sequence to be processed.
[0009] Optionally, the step of determining the color of the pixel points in the reference picture based on the traversal order of the Hilbert curve for the pixel points in the reference picture and the color of the pixel points in the pixel sequence to be processed to obtain the target picture includes: Based on the number of pixels in the reference picture, generating a reference pixel sequence; Determining the color of the pixel in the reference pixel sequence based on the color of the pixel in the to-be-processed pixel sequence; Based on the traversal order of the Hilbert curve on the pixel points in the reference picture, the reference pixel point sequence is folded according to the Hilbert curve to obtain the target picture.
[0010] Optionally, the step of determining the color of the pixel points in the reference pixel point sequence based on the color of the pixel points in the to-be-processed pixel point sequence comprises: Adjusting the length of the reference pixel sequence and / or the to-be-processed pixel sequence to obtain a target reference pixel sequence and a target to-be-processed pixel sequence of the same length; The colors of the pixels in the target reference pixel sequence are determined based on the colors of the pixels in the target to-be-processed pixel sequence.
[0011] Optionally, the step of determining the color of the pixel points in the target reference pixel point sequence based on the color of the pixel points in the target to-be-processed pixel point sequence comprises: Aligning the target reference pixel sequence and the target to-be-processed pixel sequence head to tail; For any pixel in the target reference pixel sequence, the color of the pixel in the target to-be-processed pixel sequence that is closest to the pixel in the target reference pixel sequence is used as the color of the pixel in the target reference pixel sequence.
[0012] Optionally, the step of folding the reference pixel sequence according to the Hilbert curve based on the traversal order of the pixels in the reference picture to obtain the target picture includes: Based on the traversal order of the Hilbert curve on the pixels in the reference picture and the shape of the Hilbert curve, the positions of the pixels in the reference pixel sequence in the target picture are determined in sequence to obtain the target picture.
[0013] The embodiment of the present invention further provides a device for scaling a picture size, comprising: An image acquisition module is used to acquire an image to be processed; the image to be processed includes a number of pixels; A first traversal module, used for traversing the pixel points in the image to be processed by using a preset Hilbert curve; A module for acquiring a pixel sequence to be processed, configured to expand the pixel points in the image to be processed based on the traversal order of the Hilbert curve for the pixel points in the image to be processed, so as to obtain a pixel sequence to be processed; the pixel sequence to be processed includes at least one pixel point arranged in the traversal order of the Hilbert curve; A second traversal module, used for traversing the Hilbert curve through the pixel points in the reference picture of a preset target size; The target image determination module is used to determine the color of the pixel points in the reference image based on the traversal order of the Hilbert curve on the pixel points in the reference image and the color of the pixel points in the pixel sequence to be processed, so as to obtain the target image.
[0014] Optionally, the first traversal module includes: A template generation submodule, used for generating a Hilbert curve template including a Hilbert curve; A matching template block, used for matching the Hilbert curve template with the image to be processed so that the Hilbert curve passes through the pixel points in the image to be processed; The first traversal submodule is used to take any end of the Hilbert curve as a starting point and the extension mode of the Hilbert curve as a traversal order to traverse the pixel points in the image to be processed.
[0015] Optionally, the module for acquiring a pixel sequence to be processed includes: The submodule for obtaining a pixel sequence to be processed is used to arrange the pixel points in the image to be processed in a one-dimensional straight line direction according to the traversal order of the Hilbert curve on the pixel points in the image to be processed, so as to obtain a pixel sequence to be processed.
[0016] Optionally, the first traversal submodule includes: a connection starting point search unit, configured to use any end of the Hilbert curve as a starting point, use the extension mode of the Hilbert curve as a traversal order, traverse the pixel points in the image to be processed, until the Hilbert curve intersects with the boundary of the image to be processed, and use the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as a connection starting point; A connection end point search unit, used to search for the next boundary of the image to be processed that intersects with the Hilbert curve along the extension of the Hilbert curve, and use the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point; A connection relationship establishing unit, used to establish a connection relationship between the connection starting point and the connection end point; A repeated search unit is used to repeatedly execute the steps of taking the connection end point as the starting point, taking the extension method of the Hilbert curve as the traversal order, traversing the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection starting point, searching for the next boundary of the image to be processed that intersects with the Hilbert curve along the extension method of the Hilbert curve, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point, and establishing a connection relationship between the connection starting point and the connection end point, until the traversal of the pixel points in the image to be processed is completed.
[0017] Optionally, the module for acquiring a pixel sequence to be processed includes: The submodule for obtaining the pixel sequence to be processed is used to arrange the pixel points in the image to be processed in a one-dimensional straight line direction according to the traversal order of the Hilbert curve on the pixel points in the image to be processed and the connection relationship between the connection starting point and the connection end point to obtain the pixel sequence to be processed.
[0018] Optionally, the target image determination module includes: A reference pixel sequence generation submodule, used to generate a reference pixel sequence based on the number of pixels in the reference picture; A pixel color determination submodule, used to determine the color of the pixel in the reference pixel sequence based on the color of the pixel in the to-be-processed pixel sequence; The target picture determination submodule is used to fold the reference pixel point sequence according to the Hilbert curve based on the traversal order of the pixel points in the reference picture to obtain the target picture.
[0019] Optionally, the pixel color determination submodule includes: a length adjustment unit, used for adjusting the length of the reference pixel sequence and / or the to-be-processed pixel sequence to obtain a target reference pixel sequence and a target to-be-processed pixel sequence of the same length; The pixel color determining unit is used to determine the color of the pixel in the target reference pixel sequence based on the color of the pixel in the target to-be-processed pixel sequence.
[0020] Optionally, the pixel color determination unit includes: An alignment subunit, used to align the target reference pixel sequence and the target to-be-processed pixel sequence head to tail; The pixel color determination subunit is used to use the color of the pixel in the target to-be-processed pixel sequence that is closest to the pixel in the target reference pixel sequence as the color of the pixel in the target reference pixel sequence for any pixel in the target reference pixel sequence.
[0021] Optionally, the target image determination submodule includes: The target picture determination unit is used to determine the positions of the pixels in the reference pixel sequence in the target picture in sequence based on the traversal order of the Hilbert curve on the pixels in the reference picture and the shape of the Hilbert curve to obtain the target picture.
[0022] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0023] The embodiment of the present invention further discloses one or more computer-readable media on which instructions are stored. When executed by one or more processors, the processors are enabled to execute the method described in the embodiment of the present invention.
[0024] The embodiments of the present invention include the following advantages: Through the image resizing method provided in the embodiment of the present invention, a picture to be processed is obtained; the picture to be processed contains a number of pixels; a preset Hilbert curve is used to traverse the pixels in the picture to be processed; based on the traversal order of the Hilbert curve for the pixels in the picture to be processed, the pixels in the picture to be processed are expanded to obtain a pixel sequence to be processed; the pixel sequence to be processed includes at least one pixel arranged in the traversal order of the Hilbert curve; the Hilbert curve is used to traverse the pixels in a reference picture of a preset target size; based on the traversal order of the Hilbert curve for the pixels in the reference picture and the colors of the pixels in the pixel sequence to be processed, the colors of the pixels in the reference picture are determined to obtain a target picture. Thus, the image resizing process can be realized based on the Hilbert curve, the colors of each pixel in the target picture after resizing can be quickly determined, the resources required for calculation are small, and the generated picture is natural and has high quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 is a flowchart of a method for scaling a picture size provided in an embodiment of the present invention; Figure 2 is a schematic diagram of a Hilbert curve provided in an embodiment of the present invention; Figure 3 is a schematic diagram of a to-be-processed pixel sequence and a reference pixel point sequence provided in an embodiment of the present invention; Figure 4 is a schematic diagram of another to-be-processed pixel sequence and a reference pixel point sequence provided in an embodiment of the present invention; Figure 5 is a schematic diagram of a reference pixel sequence provided in an embodiment of the present invention; Figure 6 is a structural block diagram of a picture size scaling device provided in an embodiment of the present invention; Figure 7 is a block diagram of an electronic device provided in an embodiment of the present invention; Figure 8 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0027] Reference Figure 1 , shows a flowchart of a method for scaling a picture size provided in an embodiment of the present invention, which may specifically include the following steps: Step 101, obtaining a picture to be processed; the picture to be processed includes a number of pixels; Specifically, when it is necessary to perform scaling processing on an image, a to-be-processed image may be obtained, wherein the to-be-processed image may contain a number of pixels, and different pixels may be presented in different colors.
[0028] Step 102, using a preset Hilbert curve to traverse the pixels in the image to be processed; In the embodiment of the present invention, a Hilbert curve may be preset. The Hilbert curve may refer to a space-filling curve, which may be a continuous, self-similar curve that can traverse all points on a two-dimensional plane, and each point is visited only once.
[0029] Among them, the Hilbert curve can be expressed as: assuming that there is an n×n grid, when n=1, the Hilbert curve can be "U" shaped, and when n>1, the Hilbert curve can be composed of four n / 2×n / 2 Hilbert curves, where the first n / 2 xn / 2 Hilbert curve is placed in the upper left corner, the second n / 2×n / 2 Hilbert curve is placed in the upper right corner and rotated 90 degrees counterclockwise, the third n / 2×n / 2 Hilbert curve is placed in the lower right corner and rotated 90 degrees clockwise, and the fourth n / 2×n / 2 Hilbert curve is placed in the lower left corner and rotated 180 degrees counterclockwise.
[0030] Since the Hilbert curve can traverse all points on a two-dimensional plane, the Hilbert curve can be used to traverse the pixel points in the image to be processed, so as to subsequently reorder the pixel points in the image to be processed.
[0031] Step 103, based on the traversal order of the Hilbert curve for the pixel points in the image to be processed, expand the pixel points in the image to be processed to obtain a pixel sequence to be processed; the pixel sequence to be processed includes at least one pixel point arranged in the traversal order of the Hilbert curve; In a specific implementation, the Hilbert curve can traverse all the pixels in the image to be processed, and according to the extension method of the Hilbert curve, the traversal order of the Hilbert curve on the pixels in the image to be processed can be determined to obtain the pixel sequence to be processed. Thus, the pixels in the image to be processed can be expanded into a one-dimensional pixel sequence for further processing of the image.
[0032] Step 104, using the Hilbert curve to traverse the pixel points in the reference image of the preset target size; In an embodiment of the present invention, the image to be processed can be set to be scaled to a target size. Thus, a reference image of the target size can be generated in advance, and the Hilbert curve is used to traverse the pixels in the reference image, so that the reference image can be expanded into a one-dimensional pixel sequence through the Hilbert curve.
[0033] Step 105, based on the traversal order of the Hilbert curve for the pixels in the reference picture and the colors of the pixels in the pixel sequence to be processed, the colors of the pixels in the reference picture are determined to obtain the target picture.
[0034] In an embodiment of the present invention, since both the image to be processed and the reference image are expanded through the Hilbert curve, the traversal order of pixels in the image to be processed can be similar to the traversal order of pixels in the reference image, that is, pixels with similar traversal orders have similar positions in the image.
[0035] Therefore, the color of the pixel points in the reference picture can be quickly determined based on the traversal order of the Hilbert curve for the pixel points in the reference picture and the color of the pixel points in the pixel sequence to be processed.
[0036] Specifically, for any pixel in the reference image, based on the traversal order of the Hilbert curve for the pixel, the pixel with a similar traversal order can be found in the pixel sequence to be processed, and the color of the pixel in the reference image can be determined based on the pixel with a similar traversal order in the pixel sequence to be processed. In this way, the color of each pixel in the reference image can be quickly determined, and different pixels can be re-matched to corresponding positions in the reference image according to the traversal order of the Hilbert curve for the pixels in the reference image, so as to obtain the target image.
[0037] Through the image resizing method provided in the embodiment of the present invention, a to-be-processed image is obtained; the to-be-processed image contains a number of pixels; a preset Hilbert curve is used to traverse the pixels in the to-be-processed image; based on the traversal order of the Hilbert curve for the pixels in the to-be-processed image, the pixels in the to-be-processed image are expanded to obtain a to-be-processed pixel sequence; the to-be-processed pixel sequence includes at least one pixel arranged in the traversal order of the Hilbert curve; the Hilbert curve is used to traverse the pixels in a reference image of a preset target size; based on the traversal order of the Hilbert curve for the pixels in the reference image and the colors of the pixels in the to-be-processed pixel sequence, the colors of the pixels in the reference image are determined to obtain a target image. Thus, the image resizing processing can be realized based on the Hilbert curve. In the case of image resizing, the colors of each pixel in the resized target image can be quickly determined based on the Hilbert curve. The resources required for calculation are relatively small, and the generated image is natural.
[0038] In one embodiment of the present invention, the step of using a preset Hilbert curve to traverse the pixels in the image to be processed includes: S11, generating a Hilbert curve template including a Hilbert curve; Specifically, in order to quickly match the Hilbert curve with the image to be processed, a Hilbert curve template may be generated first. The size of the Hilbert curve template may be slightly larger than the size of the image to be processed to ensure that the Hilbert curve can normally traverse all pixels in the image to be processed.
[0039] S12, matching the Hilbert curve template with the image to be processed, so that the Hilbert curve passes through the pixel points in the image to be processed; Afterwards, the Hilbert curve template can be matched with the image to be processed. Since the Hilbert curve can pass through all points in the two-dimensional plane and the size of the Hilbert curve template is slightly larger than the size of the image to be processed, the Hilbert curve can pass through all pixels in the image to be processed.
[0040] Specifically, the upper left corner of the Hilbert curve template may be aligned with the upper left corner of the image to be processed, so that the Hilbert curve template may match the image to be processed.
[0041] S13, taking any end of the Hilbert curve as a starting point, taking the extension method of the Hilbert curve as a traversal order, and traversing the pixel points in the image to be processed.
[0042] The Hilbert curve may have two endpoints, and any end of the Hilbert curve may be selected as a starting point, and the pixel points in the image to be processed may be traversed according to the extension method of the Hilbert curve as a pixel point traversal method.
[0043] In one embodiment of the present invention, the step of expanding the pixel points in the image to be processed based on the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain the pixel sequence to be processed includes: S21, according to the traversal order of the Hilbert curve on the pixel points in the image to be processed, the pixel points in the image to be processed are arranged in the one-dimensional straight line direction to obtain a pixel sequence to be processed.
[0044] Specifically, the pixels in the image to be processed can be arranged in sequence in the one-dimensional straight line direction according to the traversal order of the pixels in the image to be processed by the Hilbert curve, thereby expanding the pixels in the image to be processed based on the Hilbert curve to obtain a pixel sequence to be processed.
[0045] In one embodiment of the present invention, taking any end of the Hilbert curve as a starting point and taking the extension mode of the Hilbert curve as a traversal order, the step of traversing the pixel points in the image to be processed includes: S31, taking any end of the Hilbert curve as a starting point, taking the extension method of the Hilbert curve as a traversal order, traversing the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, and taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection starting point; Specifically, since the size of the Hilbert curve template is slightly larger than the size of the image to be processed, and the Hilbert curve template is usually square, while the size of the image to be processed may be rectangular, the Hilbert curve will intersect with the boundary of the image to be processed. In this case, the Hilbert curve can be cut into several line segments by the boundary of the image to be processed.
[0046] For example, Figure 2 is a schematic diagram of a Hilbert curve provided in an embodiment of the present invention. The upper left corner of the Hilbert curve template can be aligned with the upper left corner of the image to be processed, and the Hilbert curve can be divided by the right boundary and the lower boundary of the image to be processed.
[0047] At this time, in order to determine the traversal order of the pixels, any end of the Hilbert curve can be used as the starting point, and the extension method of the Hilbert curve can be used as the traversal order to traverse the pixels in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, and the current intersection point is used as the connection starting point.
[0048] S32, along the extension of the Hilbert curve, searching for the next boundary of the image to be processed that intersects with the Hilbert curve, and taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point; Afterwards, the Hilbert curve can be extended in the same way. After the Hilbert curve is extended beyond the image to be processed, it can be extended in its original shape and intersect with another point on the boundary of the image to be processed. Thus, the boundary of the next image to be processed that intersects with the Hilbert curve can be found along the Hilbert curve extension method, and the pixel point corresponding to the intersection of the Hilbert curve and the boundary of the image to be processed is used as the connection end point.
[0049] Optionally, the boundary of the picture to be processed that is closest to the connection starting point and intersects with the Hilbert curve can be found on the boundary of the picture to be processed. This point is the next boundary of the picture to be processed that intersects with the Hilbert curve.
[0050] S33, establishing a connection relationship between the connection starting point and the connection end point; Thereafter, a connection relationship between the connection start point and the connection end point may be established, so that the Hilbert curve divided by the boundary of the image to be processed may be reconnected.
[0051] In a specific implementation, a linked list may be used to record the connection relationship between the connection start point and the connection end point, so as to quickly determine the arrangement order between the pixels based on the linked list.
[0052] S34, repeatedly executing the steps of taking the connection end point as the starting point, taking the extension method of the Hilbert curve as the traversal order, traversing the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection starting point, searching for the next boundary of the image to be processed that intersects with the Hilbert curve along the extension method of the Hilbert curve, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point, and establishing a connection relationship between the connection starting point and the connection end point, until the traversal of the pixel points in the image to be processed is completed.
[0053] Thereafter, the steps of determining the connection starting point and the connection end point may be repeated to complete the connection of all Hilbert curves segmented by the boundaries of the image to be processed.
[0054] The extension method of the Hilbert curve can continue to be used as the traversal order to traverse the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, and the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed is used as the connection starting point, and the boundary of the image to be processed that intersects with the Hilbert curve is found along the extension method of the Hilbert curve. The pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed is used as the connection end point, and a connection relationship between the connection starting point and the connection end point is established until the traversal of the pixel points in the image to be processed is completed.
[0055] In one embodiment of the present invention, the step of arranging the pixel points in the image to be processed in a one-dimensional straight line direction according to the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain the pixel sequence to be processed includes: S41, according to the traversal order of the pixel points in the image to be processed by the Hilbert curve and the connection relationship between the connection starting point and the connection end point, the pixel points in the image to be processed are arranged in the one-dimensional straight line direction to obtain a pixel sequence to be processed.
[0056] Specifically, after reconnecting the Hilbert curve by connecting the starting point and the end point, the arrangement order of the pixels in the image to be processed can be determined according to the traversal order of the pixels in the image to be processed by the Hilbert curve. When the Hilbert curve is disconnected, the next continuous Hilbert curve is determined by searching for the connection relationship between the starting point and the end point. In this way, the pixels in the image to be processed can be arranged in a one-dimensional straight line direction to obtain a pixel sequence to be processed.
[0057] In one embodiment of the present invention, based on the traversal order of the Hilbert curve for the pixels in the reference picture and the colors of the pixels in the pixel sequence to be processed, the step of determining the colors of the pixels in the reference picture to obtain the target picture includes: S51, generating a reference pixel sequence based on the number of pixels in the reference picture; In a specific implementation, in order to determine the color of a pixel in a reference picture, a reference pixel sequence including the number of pixels in the reference picture may be first generated.
[0058] S52, determining the color of the pixel in the reference pixel sequence based on the color of the pixel in the pixel sequence to be processed; Thereafter, the colors of pixels at different positions in the reference pixel sequence may be determined based on the positions and colors of the pixels in the to-be-processed pixel sequence.
[0059] S53, based on the traversal order of the Hilbert curve for the pixel points in the reference picture, fold the reference pixel point sequence according to the Hilbert curve to obtain the target picture.
[0060] Afterwards, the same Hilbert curve template can be used to traverse the pixels in the reference image, so as to obtain the traversal order of the Hilbert curve for the pixels in the reference image, so that the pixels in the reference pixel sequence can be arranged in a traversal order similar to the pixel traversal order in the image to be processed, so as to obtain the target image and complete the scaling of the image.
[0061] In one embodiment of the present invention, the step of determining the color of a pixel in a reference pixel sequence based on the color of a pixel in a pixel sequence to be processed includes: S61, adjusting the length of the reference pixel sequence and / or the to-be-processed pixel sequence to obtain a target reference pixel sequence and a target to-be-processed pixel sequence of the same length; Specifically, Figure 3 It is a schematic diagram of a pixel sequence to be processed and a reference pixel sequence provided in an embodiment of the present invention. Assuming that the pixels of the image to be processed are 30x20=600 pixels, then the pixel sequence A1~A600 can be obtained at this time. Assuming that the pixels of the reference image are 35x25=875 pixels, then the pixel sequence B1~B875 can be thought of at this time. It can be seen that at this time, due to the different numbers of pixels in the pixel sequence to be processed and the reference pixel sequence, the lengths of the pixel sequence to be processed and the reference pixel sequence may be different, making it difficult to determine the correspondence between different pixels in the pixel sequence to be processed and the reference pixel sequence.
[0062] Thus, the length of the reference pixel sequence and / or the to-be-processed pixel sequence can be adjusted to obtain a target reference pixel sequence and a target to-be-processed pixel sequence having the same length.
[0063] In a specific implementation, the pixel size in the longer sequence of the to-be-processed pixel sequence and the reference pixel sequence can be compressed so that the lengths of the to-be-processed pixel sequence and the reference pixel sequence are the same. Figure 4 It is a schematic diagram of another pixel sequence to be processed and a reference pixel sequence provided in an embodiment of the present invention. When the reference pixel sequence contains 875 pixels and is longer than the pixel sequence to be processed, the width of the pixels in the reference pixel sequence can be shortened to obtain a target reference pixel sequence and a target pixel sequence to be processed with the same length.
[0064] S62, determining the colors of the pixels in the target reference pixel sequence based on the colors of the pixels in the target to-be-processed pixel sequence.
[0065] When the lengths are the same, it is easy to determine the pixels in the to-be-processed pixel sequence and the reference pixel sequence with similar traversal order, and determine the colors of the pixels in the target reference pixel sequence based on the colors of the pixels in the to-be-processed pixel sequence.
[0066] In one embodiment of the present invention, the step of determining the color of a pixel in a target reference pixel sequence based on the color of a pixel in a target to-be-processed pixel sequence includes: S71, aligning the target reference pixel sequence and the target to-be-processed pixel sequence head to tail; S72, for any pixel in the target reference pixel sequence, use the color of the pixel in the target to-be-processed pixel sequence that is closest to the pixel in the target reference pixel sequence as the color of the pixel in the target reference pixel sequence.
[0067] Specifically, you can Figure 4 As shown, the target reference pixel sequence and the target to-be-processed pixel sequence are aligned head to tail. For any pixel in the target reference pixel sequence, the color of the pixel in the target to-be-processed pixel sequence that is closest to the pixel in the target reference pixel sequence is used as the color of the pixel in the target reference pixel sequence.
[0068] Specifically, for any pixel in the target reference pixel sequence, the center point of the pixel can be selected, and the pixel closest to the center point can be found in the target pixel sequence to be processed, and the color value of the pixel can be used as the color value of the pixel in the target reference pixel sequence.
[0069] In one embodiment of the present invention, based on the traversal order of the Hilbert curve for the pixels in the reference picture, the step of folding the reference pixel sequence according to the Hilbert curve to obtain the target picture includes: S81, based on the traversal order of the Hilbert curve for the pixels in the reference picture and the shape of the Hilbert curve, determine the positions of the pixels in the reference pixel sequence in the target picture in sequence to obtain the target picture.
[0070] In a specific implementation, after determining the color of the pixel in the reference pixel sequence, the position of the pixel in the pixel sequence in the target image can be re-determined based on the traversal order of the Hilbert curve for the pixel in the reference image and the shape of the Hilbert curve to obtain the target image.
[0071] In the specific implementation, Figure 5 : is a schematic diagram of a reference pixel sequence provided in an embodiment of the present invention. In order to facilitate the rapid determination of the position of the pixel in the reference pixel sequence in the target image. When referring to the pixel sequence, a reference pixel sequence B1~B875 can be first determined based only on the number of pixels in the reference image. Thereafter, the Hilbert curve is used to traverse the pixels in the reference image, and the reference pixel sequence C1~C875 is formed based on the traversal order of the pixels in the reference image by the Hilbert curve.
[0072] After determining the colors of the pixels in the reference pixel sequence B1-B875 based on the colors of the pixels in the pixel sequence to be processed, the positions of the pixels in the reference pixel sequence in the target image can be determined in turn based on the correspondence between the pixels in the reference pixel sequence C1-C875 and the Hilbert curve to obtain the target image.
[0073] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0074] Reference Figure 6 , shows a structural block diagram of a picture size scaling device provided in an embodiment of the present invention, which may specifically include the following modules: The image acquisition module 601 is used to acquire the image to be processed; the image to be processed includes a number of pixels; A first traversal module 602 is used to traverse the pixels in the image to be processed using a preset Hilbert curve; The module 603 for acquiring a pixel sequence to be processed is used to expand the pixel points in the image to be processed based on the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain a pixel sequence to be processed; the pixel sequence to be processed includes at least one pixel point arranged in the traversal order of the Hilbert curve; A second traversal module 604 is used to traverse the pixel points in the reference image of a preset target size using the Hilbert curve; The target image determination module 605 is used to determine the color of the pixel points in the reference image based on the traversal order of the Hilbert curve for the pixel points in the reference image and the color of the pixel points in the pixel sequence to be processed, so as to obtain the target image.
[0075] Optionally, the first traversal module includes: A template generation submodule, used for generating a Hilbert curve template including a Hilbert curve; A matching template block is used to match the Hilbert curve template with the image to be processed so that the Hilbert curve passes through the pixel points in the image to be processed; The first traversal submodule is used to take any end of the Hilbert curve as the starting point and the extension method of the Hilbert curve as the traversal order to traverse the pixel points in the image to be processed.
[0076] Optionally, the module for acquiring a pixel sequence to be processed includes: The submodule for obtaining the pixel sequence to be processed is used to arrange the pixel points in the image to be processed in the one-dimensional straight line direction according to the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain the pixel sequence to be processed.
[0077] Optionally, the first traversal submodule includes: A connection starting point search unit is used to take any end of the Hilbert curve as a starting point, take the extension mode of the Hilbert curve as a traversal order, traverse the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, and take the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection starting point; A connection end point search unit is used to search for the boundary of the next image to be processed that intersects with the Hilbert curve along the extension of the Hilbert curve, and use the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point; A connection relationship establishing unit, used to establish a connection relationship between a connection start point and a connection end point; The repeated search unit is used to repeatedly execute the steps of taking the connection end point as the starting point, taking the extension method of the Hilbert curve as the traversal order, traversing the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection starting point, searching for the next boundary of the image to be processed that intersects with the Hilbert curve along the extension method of the Hilbert curve, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point, and establishing a connection relationship between the connection starting point and the connection end point, until the traversal of the pixel points in the image to be processed is completed.
[0078] Optionally, the module for acquiring a pixel sequence to be processed includes: The submodule for obtaining the pixel sequence to be processed is used to arrange the pixel points in the image to be processed in the one-dimensional straight line direction according to the traversal order of the pixel points in the image to be processed by the Hilbert curve and the connection relationship between the connection starting point and the connection end point to obtain the pixel sequence to be processed.
[0079] Optionally, the target image determination module includes: A reference pixel sequence generation submodule, used to generate a reference pixel sequence based on the number of pixels in the reference picture; A pixel color determination submodule, used to determine the color of the pixel in the reference pixel sequence based on the color of the pixel in the pixel sequence to be processed; The target image determination submodule is used to fold the reference pixel sequence according to the Hilbert curve based on the traversal order of the pixel points in the reference image to obtain the target image.
[0080] Optionally, the pixel color determination submodule includes: A length adjustment unit, used to adjust the length of the reference pixel sequence and / or the pixel sequence to be processed to obtain a target reference pixel sequence and a target pixel sequence to be processed with the same length; The pixel color determination unit is used to determine the color of the pixel in the target reference pixel sequence based on the color of the pixel in the target to-be-processed pixel sequence.
[0081] Optionally, the pixel color determination unit includes: An alignment subunit, used to align the target reference pixel sequence and the target to-be-processed pixel sequence head to tail; The pixel color determination subunit is used to use the color of the pixel closest to the target reference pixel sequence in the target to-be-processed pixel sequence as the color of the pixel in the target reference pixel sequence for any pixel in the target reference pixel sequence.
[0082] Optionally, the target image determination submodule includes: The target image determination unit is used to determine the positions of the pixels in the reference pixel sequence in the target image in sequence based on the traversal order of the Hilbert curve for the pixels in the reference image and the shape of the Hilbert curve to obtain the target image.
[0083] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0084] In addition, an embodiment of the present invention further provides an electronic device, such as Figure 7 As shown, it includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704. Memory 703, used for storing computer programs; The processor 701 is used to execute the program stored in the memory 703 to implement the following steps: Get the image to be processed; the image to be processed contains a number of pixels; Use the preset Hilbert curve to traverse the pixels in the image to be processed; Expand the pixel points in the image to be processed based on the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain a pixel sequence to be processed; the pixel sequence to be processed includes at least one pixel point arranged in the traversal order of the Hilbert curve; The Hilbert curve is traversed through the pixels in the reference image of the preset target size; Based on the traversal order of the Hilbert curve for the pixels in the reference image and the colors of the pixels in the pixel sequence to be processed, the colors of the pixels in the reference image are determined to obtain the target image.
[0085] Optionally, the step of using a preset Hilbert curve to traverse the pixel points in the image to be processed includes: generating a Hilbert curve template including a Hilbert curve; Match the Hilbert curve template with the image to be processed so that the Hilbert curve passes through the pixel points in the image to be processed; Take any end of the Hilbert curve as the starting point, and use the extension method of the Hilbert curve as the traversal order to traverse the pixels in the image to be processed.
[0086] Optionally, the step of expanding the pixel points in the image to be processed based on the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain the pixel sequence to be processed includes: According to the traversal order of the pixels in the image to be processed by the Hilbert curve, the pixels in the image to be processed are arranged in the direction of a one-dimensional straight line to obtain a pixel sequence to be processed.
[0087] Optionally, taking any end of the Hilbert curve as a starting point and taking the extension of the Hilbert curve as a traversal order, the step of traversing the pixel points in the image to be processed includes: Take any end of the Hilbert curve as the starting point, take the extension method of the Hilbert curve as the traversal order, traverse the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, and take the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection starting point; Along the extension of the Hilbert curve, find the next boundary of the image to be processed that intersects with the Hilbert curve, and use the pixel point corresponding to the intersection of the Hilbert curve and the boundary of the image to be processed as the connection end point; Establishing a connection relationship between a connection starting point and a connection end point; Repeat the steps of taking the connection end point as the starting point, taking the extension method of the Hilbert curve as the traversal order, traversing the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection starting point, searching for the next boundary of the image to be processed that intersects with the Hilbert curve along the extension method of the Hilbert curve, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point, and establishing a connection relationship between the connection starting point and the connection end point until the traversal of the pixel points in the image to be processed is completed; Optionally, the step of arranging the pixel points in the image to be processed in a one-dimensional straight line direction according to the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain the pixel sequence to be processed includes: According to the traversal order of the pixel points in the image to be processed by the Hilbert curve and the connection relationship between the connection starting point and the connection end point, the pixel points in the image to be processed are arranged in the one-dimensional straight line direction to obtain a pixel sequence to be processed.
[0088] Optionally, the step of determining the color of the pixel points in the reference picture based on the traversal order of the Hilbert curve for the pixel points in the reference picture and the color of the pixel points in the pixel sequence to be processed to obtain the target picture includes: Based on the number of pixels in the reference image, a reference pixel sequence is generated; Determine the color of the pixel in the reference pixel sequence based on the color of the pixel in the to-be-processed pixel sequence; Based on the traversal order of the Hilbert curve for the pixels in the reference image, the reference pixel sequence is folded according to the Hilbert curve to obtain the target image.
[0089] Optionally, the step of determining the color of a pixel in a reference pixel sequence based on the color of a pixel in a pixel sequence to be processed includes: Adjusting the length of the reference pixel sequence and / or the pixel sequence to be processed to obtain a target reference pixel sequence and a target pixel sequence to be processed having the same length; The colors of the pixels in the target reference pixel sequence are determined based on the colors of the pixels in the target to-be-processed pixel sequence.
[0090] Optionally, the step of determining the color of a pixel in a target reference pixel sequence based on the color of a pixel in a target to-be-processed pixel sequence includes: Align the target reference pixel sequence and the target to-be-processed pixel sequence head to tail; For any pixel in the target reference pixel sequence, the color of the pixel in the target to-be-processed pixel sequence that is closest to the pixel in the target reference pixel sequence is used as the color of the pixel in the target reference pixel sequence.
[0091] Optionally, based on the traversal order of the Hilbert curve for the pixels in the reference picture, the step of folding the reference pixel sequence according to the Hilbert curve to obtain the target picture includes: Based on the traversal order of the Hilbert curve for the pixels in the reference image and the shape of the Hilbert curve, the positions of the pixels in the reference pixel sequence in the target image are determined in turn to obtain the target image.
[0092] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0093] The communication interface is used for communication between the above terminal and other devices.
[0094] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0095] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0096] like Figure 8 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 801 is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the image size scaling method described in the above embodiment.
[0097] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the image resizing method described in the above embodiment.
[0098] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0099] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0100] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0101] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for scaling a picture size, characterized in that: include: Get the image to be processed; The image to be processed contains a number of pixels; Using a preset Hilbert curve to traverse the pixel points in the image to be processed; Expand the pixel points in the image to be processed based on the traversal order of the Hilbert curve for the pixel points in the image to be processed to obtain a pixel sequence to be processed; the pixel sequence to be processed includes at least one pixel point arranged in the traversal order of the Hilbert curve; The Hilbert curve is traversed through the pixel points in the reference image of a preset target size; Based on the number of pixels in the reference picture, generating a reference pixel sequence; Determining the color of the pixel in the reference pixel sequence based on the color of the pixel in the to-be-processed pixel sequence; Based on the traversal order of the Hilbert curve on the pixels in the reference picture, the reference pixel sequence is folded according to the Hilbert curve to obtain a target picture.
2. The method according to claim 1, characterized in that The step of using a preset Hilbert curve to traverse the pixel points in the image to be processed includes: generating a Hilbert curve template including a Hilbert curve; Matching the Hilbert curve template with the image to be processed so that the Hilbert curve passes through the pixel points in the image to be processed; Any end of the Hilbert curve is taken as a starting point, and the extension mode of the Hilbert curve is taken as a traversal order to traverse the pixel points in the image to be processed.
3. The method according to claim 1, characterized in that The step of expanding the pixel points in the image to be processed based on the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain a pixel sequence to be processed comprises: According to the traversal order of the Hilbert curve for the pixel points in the image to be processed, the pixel points in the image to be processed are arranged in a one-dimensional straight line direction to obtain a pixel sequence to be processed.
4. The method according to claim 2 or 3, characterized in that: The step of taking any end of the Hilbert curve as a starting point, taking the extension mode of the Hilbert curve as a traversal order, and traversing the pixel points in the image to be processed comprises: Taking any end of the Hilbert curve as a starting point, taking the extension mode of the Hilbert curve as a traversal order, traversing the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, and taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as a connection starting point; Along the extension of the Hilbert curve, find the next boundary of the image to be processed that intersects with the Hilbert curve, and use the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point; Establishing a connection relationship between the connection starting point and the connection end point; Repeat the steps of taking the connection end point as the starting point, taking the extension method of the Hilbert curve as the traversal order, traversing the pixel points in the image to be processed until the Hilbert curve intersects with the boundary of the image to be processed, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection starting point, searching for the next boundary of the image to be processed that intersects with the Hilbert curve along the extension method of the Hilbert curve, taking the pixel point corresponding to the intersection position of the Hilbert curve and the boundary of the image to be processed as the connection end point, and establishing a connection relationship between the connection starting point and the connection end point, until the traversal of the pixel points in the image to be processed is completed.
5. The method according to claim 4, characterized in that The step of arranging the pixel points in the image to be processed in a one-dimensional straight line direction according to the traversal order of the pixel points in the image to be processed by the Hilbert curve to obtain a pixel sequence to be processed comprises: According to the traversal order of the Hilbert curve on the pixel points in the image to be processed and the connection relationship between the connection starting point and the connection end point, the pixel points in the image to be processed are arranged in a one-dimensional straight line direction to obtain a pixel sequence to be processed.
6. The method according to claim 1, characterized in that The step of determining the color of the pixel points in the reference pixel point sequence based on the color of the pixel points in the to-be-processed pixel point sequence comprises: Adjusting the length of the reference pixel sequence and / or the to-be-processed pixel sequence to obtain a target reference pixel sequence and a target to-be-processed pixel sequence of the same length; The colors of the pixels in the target reference pixel sequence are determined based on the colors of the pixels in the target to-be-processed pixel sequence.
7. The method according to claim 6, characterized in that The step of determining the color of the pixel points in the target reference pixel point sequence based on the color of the pixel points in the target to-be-processed pixel point sequence comprises: Aligning the target reference pixel sequence and the target to-be-processed pixel sequence head to tail; For any pixel in the target reference pixel sequence, the color of the pixel in the target to-be-processed pixel sequence that is closest to the pixel in the target reference pixel sequence is used as the color of the pixel in the target reference pixel sequence.
8. The method according to claim 6 or 7, characterized in that: The step of folding the reference pixel sequence according to the Hilbert curve based on the traversal order of the pixels in the reference picture to obtain the target picture comprises: Based on the traversal order of the Hilbert curve on the pixels in the reference picture and the shape of the Hilbert curve, the positions of the pixels in the reference pixel sequence in the target picture are determined in sequence to obtain the target picture.
9. A device for scaling image size, characterized in that: include: Image acquisition module, used to acquire images to be processed; The image to be processed contains a number of pixels; A first traversal module, used for traversing the pixel points in the image to be processed by using a preset Hilbert curve; A module for acquiring a pixel sequence to be processed, configured to expand the pixel points in the image to be processed based on the traversal order of the Hilbert curve for the pixel points in the image to be processed, so as to obtain a pixel sequence to be processed; the pixel sequence to be processed includes at least one pixel point arranged in the traversal order of the Hilbert curve; A second traversal module, used for traversing the Hilbert curve through the pixel points in the reference picture of a preset target size; A reference pixel sequence generation submodule, used to generate a reference pixel sequence based on the number of pixels in the reference picture; A pixel color determination submodule, used to determine the color of the pixel in the reference pixel sequence based on the color of the pixel in the to-be-processed pixel sequence; The target picture determination submodule is used to fold the reference pixel point sequence according to the Hilbert curve based on the traversal order of the pixel points in the reference picture to obtain the target picture.
10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 8 when executing the program stored in the memory.
11. A computer-readable medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Fast image filtering method based on space filling curves and extreme points
CN103218784A
Image scaling method based on bilinear interpolation algorithm processing
CN108986033A
Quantum circuit diagram and quantum color image scaling method based on bilinear interpolation
CN115423688A
Image edge tracking processing method and device and server
CN115690139A
Super-resolution image generation method and device based on space curve filling
CN117974447A
