Image local direction detection method and device, electronic equipment, medium and product
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAN UNISOC TECH CO LTD
- Filing Date
- 2026-04-16
- Publication Date
- 2026-07-14
AI Technical Summary
In existing technologies, local orientation detection methods for images are sensitive to texture changes, weak gradient regions, and multi-directional edges, and are easily affected by noise, leading to orientation determination errors and low accuracy.
By generating orthogonal direction vectors for each pixel in a local image patch and accumulating them into an autocorrelation matrix to form an information matrix, the projection values of each candidate direction are determined based on the information matrix, thereby determining the image orientation of the local image patch.
It significantly improves the robustness and accuracy of orientation detection, reduces the probability of misjudgment caused by fixed window size, and improves the accuracy of orientation detection.
Smart Images

Figure CN122391136A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of digital image processing, and in particular to a method, apparatus, electronic device, medium, and product for detecting local orientation of an image. Background Technology
[0002] Local orientation detection of images is widely used in camera image optimization, display enhancement and visual analysis. It is usually based on gradient operators or neighborhood similarity to estimate the orientation of local image patches.
[0003] However, in related technologies, the detection methods of fixed operators and fixed windows are more sensitive to texture changes, weak gradient regions and multi-directional edges, and are easily affected by noise and produce deviations in direction determination, resulting in low accuracy of direction detection in local images.
[0004] Therefore, how to improve the robustness and accuracy of orientation detection under local image content has become an urgent technical problem to be solved. Summary of the Invention
[0005] This application provides a method, apparatus, electronic device, medium, and product for local image orientation detection, which improves the robustness and accuracy of local image orientation detection, thereby improving the accuracy of orientation detection.
[0006] In a first aspect, this application provides a method for detecting local orientation in an image, including:
[0007] Obtain a local image patch of the image to be processed;
[0008] Generate orthogonal direction vectors for each pixel in a local image patch;
[0009] The orthogonal direction vectors of each pixel are accumulated into the autocorrelation matrix to obtain the information matrix corresponding to the local image patch;
[0010] Based on the information matrix, determine the projection value of each preset candidate direction onto the information matrix;
[0011] The image orientation of a local image patch is determined based on the projection values of each candidate orientation onto the information matrix.
[0012] In some embodiments, generating orthogonal direction vectors for each pixel in a local image patch includes:
[0013] Determine the adjacent pixels of each pixel along the orthogonal direction;
[0014] Determine the pixel difference between a pixel and its neighboring pixels to obtain the orthogonal gradient value of the pixel;
[0015] Based on the orthogonal gradient value of each pixel, the orthogonal direction vector corresponding to each pixel is obtained.
[0016] In some embodiments, the orthogonal direction vectors of each pixel are accumulated into the autocorrelation matrix to obtain the information matrix corresponding to the local image patch, including:
[0017] The orthogonal direction vector of a pixel is split into horizontal and vertical components;
[0018] Determine the corresponding positions of the horizontal and vertical components in the autocorrelation matrix;
[0019] Iterate through the orthogonal direction vectors of all pixels in the local image patch, and accumulate the horizontal and vertical components of the orthogonal direction vector corresponding to each pixel to the corresponding positions in the autocorrelation matrix to obtain the information matrix.
[0020] In some embodiments, the orthogonal direction vectors of all pixels in a local image patch are traversed, and the horizontal and vertical components of the orthogonal direction vector corresponding to each pixel are accumulated to the corresponding positions in the autocorrelation matrix to obtain an information matrix, including:
[0021] Determine the algorithm corresponding to each position in the autocorrelation matrix;
[0022] By using algorithms corresponding to each position, the horizontal and / or vertical components of the orthogonal direction vectors corresponding to each pixel are calculated and then summed to obtain the information matrix.
[0023] In some embodiments, based on the information matrix, the projection values of each preset candidate direction onto the information matrix are determined, including:
[0024] Determine the candidate direction vector corresponding to each candidate direction;
[0025] For each candidate direction, the product of the corresponding candidate direction vector, the transpose of the candidate direction vector, and the information matrix is determined as the projection value of the candidate direction onto the information matrix.
[0026] In some embodiments, the image orientation of a local image patch is determined based on the projection values of each candidate orientation onto the information matrix, including:
[0027] Sort the projection values of each candidate direction onto the information matrix;
[0028] The candidate direction with the largest projection value is determined as the image direction of the local image block.
[0029] Secondly, embodiments of this application provide an image local orientation detection device, comprising:
[0030] The acquisition module is used to acquire local image patches of the image to be processed;
[0031] The generation module is used to generate orthogonal direction vectors for each pixel in a local image patch.
[0032] The processing module is used to accumulate the orthogonal direction vectors of each pixel into the autocorrelation matrix to obtain the information matrix corresponding to the local image patch;
[0033] The processing module is also used to determine the projection values of each preset candidate direction onto the information matrix based on the information matrix;
[0034] The processing module is also used to determine the image orientation of a local image block based on the projection values of each candidate orientation onto the information matrix.
[0035] Thirdly, embodiments of this application provide an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0036] The memory stores the instructions that the computer executes;
[0037] The processor executes computer execution instructions stored in memory to implement the image local orientation detection method provided above.
[0038] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the image local orientation detection method provided above.
[0039] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the image local orientation detection method provided above.
[0040] The image local orientation detection method, apparatus, electronic device, medium, and product provided in this application generate orientation vectors through the symmetric combination of orthogonal directional gradients, adapting to multi-directional edge scenes. The autocorrelation matrix, by integrating the gradient distribution of all pixels, ensures the integrity of orientation features, significantly improving orientation detection accuracy while reducing the probability of false positives due to fixed window sizes. Therefore, the image local orientation detection method provided in this application can improve the robustness and accuracy of orientation detection within local image content, thereby improving the accuracy of orientation detection. Attached Figure Description
[0041] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0042] Figure 1 This application provides a schematic diagram of the scenario.
[0043] Figure 2 Flowchart of the image local orientation detection method provided in this application Figure 1 ;
[0044] Figure 3 Flowchart of the image local orientation detection method provided in this application Figure 2 ;
[0045] Figure 4 Flowchart of the image local orientation detection method provided in this application Figure 3 ;
[0046] Figure 5 Flowchart of the image local orientation detection method provided in this application Figure 4 ;
[0047] Figure 6 Flowchart of the image local orientation detection method provided in this application Figure 5 ;
[0048] Figure 7 A schematic diagram illustrating alternative directions as an example;
[0049] Figure 8 This is a schematic diagram of the structure of the image local orientation detection device provided in the embodiments of this application;
[0050] Figure 9 A schematic diagram of the structure of the electronic device provided in this application.
[0051] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0052] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0053] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the solution.
[0054] Figure 1 The scenario diagram provided for this application is as follows: Figure 1As shown, the image comprises multiple local image patches. Local orientation detection for individual local image patches is a fundamental processing technique in the field of digital image processing. Local orientation detection is typically used to identify the dominant edge direction, texture arrangement direction, and structural line features of local regions in an image. In mobile terminal camera image optimization scenarios, this technology is often embedded in the post-processing module of the imaging chain, working in conjunction with sharpening, denoising, anti-aliasing, super-resolution reconstruction, and local contrast enhancement processes. In display device enhancement scenarios, local orientation information can serve as an important basis for adaptive rendering, dynamic resolution adjustment, edge protection display, and texture enhancement. In image analysis and artificial intelligence vision systems, orientation detection results are also frequently used as pre-input for algorithms such as texture classification, edge localization, feature matching, and target contour recognition. Therefore, this type of technology not only requires stable output of orientation information under different imaging devices and image content conditions, but also needs to adapt to real-time processing chains, balancing detection accuracy, computational efficiency, and support for subsequent image algorithms. In practical applications, the objects to be detected are usually not simple, regular geometric textures, but rather complex local image patches containing various elements such as building facades, road markings, text strokes, device edges, and natural textures. These elements often exhibit spatial variations in scale, orientation, and contrast, and are further compounded by interference factors such as motion blur, sensor noise, and compression distortion. To adapt to these application environments, the orientation detection module typically needs to operate continuously in the image acquisition, preprocessing, and post-processing chain, forming a complete system workflow with local window segmentation, pixel neighborhood analysis, and orientation determination to provide a stable and reliable orientation basis for subsequent enhancement or analysis tasks.
[0055] In existing technologies, local orientation detection in images is typically achieved using fixed gradient operators or neighborhood similarity analysis. Specifically, related schemes first divide the image into local windows, then calculate the changes in pixels along horizontal, vertical, or diagonal directions within each image block using a preset gradient operator. The dominant orientation of the image block is then determined based on the gradient magnitude, gradient sign, or local similarity index. Some schemes further construct independent computation paths for several preset directions, mapping the differences between local pixels and neighboring pixels to the corresponding directions, and finally determining the optimal orientation by comparing the response values of multiple directions. Such methods generally achieve usable results in images with simple textures and clear edges, but they exhibit significant drawbacks in complex scenes. First, the combination of fixed windows and fixed operators is difficult to accurately match the content of the real image. When an image block contains multiple edges, intersections of diagonal lines and right angles, and coexistence of coarse and fine textures, the local processing results are easily dominated by strong local edges, thus masking the overall orientation features of the image block and causing a deviation in orientation determination. Secondly, traditional gradient operators are sensitive to noise and weak gradient regions. When the image has low illumination, insufficient contrast, or compression artifacts, abnormal fluctuations in local pixels are directly amplified in the orientation decision result, leading to a decrease in orientation estimation stability. In summary, existing technologies generally suffer from orientation detection distortion and insufficient noise resistance in complex local image content.
[0056] In view of this, this application proposes an image local orientation detection method. After acquiring a local image patch of the image to be processed, it first generates orthogonal direction vectors for each pixel in the local image patch, then accumulates the orthogonal direction vectors of each pixel into an autocorrelation matrix to obtain the information matrix corresponding to the local image patch. Subsequently, based on the information matrix, it determines the projection values of each preset candidate direction onto the information matrix, and determines the image orientation of the local image patch based on the projection values of each candidate direction onto the information matrix. This method generates orientation vectors through the symmetric combination of orthogonal direction gradients, adapting to multi-directional edge scenes. The autocorrelation matrix integrates the gradient distribution of all pixels, ensuring the integrity of orientation features, significantly improving orientation detection accuracy, and reducing the probability of misjudgment due to fixed window size. Therefore, the image local orientation detection method provided by this application can improve the robustness and accuracy of orientation detection under local image content, thereby improving the accuracy of orientation detection.
[0057] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.
[0058] Example 1
[0059] Figure 2 Flowchart of the image local orientation detection method provided in this application Figure 1 ,like Figure 2 As shown, the image local orientation detection method of this application embodiment includes:
[0060] S201: Obtain a local image patch of the image to be processed.
[0061] In the context of this example, a local image patch refers to a local area extracted from the image to be processed. It serves as the basic processing object for orientation detection, dividing the entire image into smaller areas suitable for local analysis to extract and model the directional features of edges, textures, lines, and structural transition regions. In this embodiment, the image to be processed can originate from still images captured by a mobile terminal camera, video frames, input images from a display device, intermediate images in an image processing pipeline, or image data read by a visual analysis system. The execution entity can be an image signal processor, a central processing unit, a digital signal processor, an image processing chip, an edge computing device, or a software-implemented image processing module.
[0062] In one specific implementation, the image to be processed is first received and subjected to basic preprocessing. This preprocessing may include grayscale conversion, brightness normalization, noise suppression, boundary padding, and pixel format conversion to ensure that subsequent orientation detection is performed on a unified data representation. Subsequently, local image patches are extracted from the image to be processed according to preset window partitioning rules. These local image patches can be fixed-size rectangular windows, such as 8×8, 16×16, or 32×32 pixel windows, or other regular regions outside of rectangular windows. An adaptive partitioning method can also be used based on the image content distribution, dividing densely edged areas into smaller image patches and gently textured areas into larger image patches. Combined with... Figure 1 can Figure 1 The example image in the example is used as the image to be processed. It can be divided into nine local image blocks using a pixel window. To improve the coverage of the entire image, a sliding window approach can be used to acquire local image blocks one by one. The window sliding step size can be smaller than the window size, so that there is overlap between adjacent image blocks, thereby reducing the impact of boundary positions on the continuity of orientation determination.
[0063] In another implementation, candidate regions can be obtained first through salient region detection, edge density processing, region of interest extraction, or image segmentation. Then, local image patches are extracted from these candidate regions to concentrate the patches at locations containing valid structural information. For window regions at image edges, pixel augmentation, zero-padding, edge duplication, or cyclic edge patching can be used to supplement the local image patch, ensuring the complete execution of subsequent pixel neighborhood operations. Based on these acquisition methods, local image patches no longer rely on a single fixed scene but can adapt to complex image content such as building facades, road markings, text strokes, device edges, and natural textures. By first decomposing the entire image into local image patches and then performing orientation detection within each patch, the processing range can be reduced, the probability of interference between structures with different orientations can be decreased, and a stable data foundation can be provided for the subsequent generation of orthogonal orientation vectors. This makes image local orientation detection more suitable for block-by-block processing and parallel implementation in real-time processing chains. It should be understood that the above examples are for demonstration purposes only and are not limiting.
[0064] S202: Generate orthogonal direction vectors for each pixel in the local image patch.
[0065] With a scenario example, an orthogonal direction vector is a two-dimensional directional representation built based on the gradient information of pixels in mutually perpendicular directions. It is used to characterize the local directional change trend of the neighborhood of that pixel. Its core function is to transform the variation relationship of pixel intensity in an orthogonal coordinate system into a vector form that can participate in the overall processing, thereby replacing the discrete directional response that relies solely on a single gradient operator in the traditional method.
[0066] In this embodiment of the disclosure, after obtaining a local image block, each pixel within the local image block is traversed point by point. For each current pixel, a unilateral gradient value is calculated in both the horizontal and vertical orthogonal directions. For example, in the horizontal direction, the pixel difference between the current pixel and its left neighboring pixel is calculated to obtain the left gradient value, and the pixel difference between the current pixel and its right neighboring pixel is calculated to obtain the right gradient value; in the vertical direction, the pixel difference between the current pixel and its upper neighboring pixel is calculated to obtain the upper gradient value, and the pixel difference between the current pixel and its lower neighboring pixel is calculated to obtain the lower gradient value.
[0067] Subsequently, based on the symmetric combination method, the gradient values of each pixel in the two orthogonal directions of horizontal and vertical are processed to generate the orthogonal direction vector corresponding to the pixel. The orthogonal direction vector includes two components, where the horizontal component can be given by the combination of the right gradient value and the left gradient value corresponding to the pixel, and the vertical component can be given by the combination of the lower gradient value and the upper gradient value corresponding to the pixel.
[0068] S203: Accumulate the orthogonal direction vectors of each pixel into the autocorrelation matrix to obtain the information matrix corresponding to the local image patch.
[0069] In the context of a scenario example, the autocorrelation matrix is a matrix used to summarize the directional information of all pixels in a local image patch. Its function is to transform the discrete directional vectors distributed at each pixel location into a matrix representation reflecting the overall directional distribution through cumulative modeling. The information matrix, carrying the directional processing result of this accumulation, serves as the basis for subsequent projection calculations of various candidate directions. Based on the above analysis, this step, by mapping orthogonal directional vectors to the autocorrelation matrix and forming the information matrix, transforms pixel-level unstable responses into region-level stable processing results, thus solving the problem in existing technologies where fixed operators are easily dominated by a single strong edge, and local abnormal fluctuations are directly amplified. Especially when diagonal lines, straight lines, corner points, and weak textures coexist in the same local image patch, the information matrix can comprehensively reflect the overall directional distribution rather than just the strongest local response, making subsequent directional decisions more robust and consistent. It should be understood that the above example is merely illustrative and not limiting.
[0070] S204: Based on the information matrix, determine the projection value of each preset candidate direction onto the information matrix.
[0071] In the context of the scenario example, candidate directions are a pre-defined set of candidate directions used for comparison and judgment, serving as a unified reference standard for direction detection. The projection value is the response result of the candidate direction on the information matrix, used to measure the degree of matching between the candidate direction and the actual direction distribution of the local image patch. The larger the projection value, the closer the direction is to the dominant structural direction of the local image patch. In this embodiment, after obtaining the information matrix corresponding to the local image patch, a set of discrete candidate directions is pre-established. These candidate directions can include horizontal, vertical, and two main diagonal directions, or can be extended to cover multiple equally spaced directions within the range of 0 to 180 degrees, such as 8, 16, or 32 discrete directions. For any candidate direction θ, a corresponding unit direction vector "cosθ, sinθ" can be constructed. Subsequently, the direction vector is projected onto the information matrix to obtain the projection value of that direction. This calculation essentially projects the overall direction of the local image patch along the candidate direction, and the result can be interpreted as the structural consistency strength carried in that direction. If the projection value is large, it indicates that the information matrix has a strong component in that direction, and the directional changes of many pixels in the local image patch are consistent with that direction.
[0072] S205: Determine the image orientation of the local image block based on the projection values of each candidate orientation onto the information matrix.
[0073] In the context of the scenario example, image orientation refers to the dominant direction or texture direction corresponding to the local image patch. It is the final output of local orientation detection and can be used in subsequent processing steps such as sharpening, denoising, edge protection display, dynamic resolution adjustment, super-resolution reconstruction, texture classification, target contour recognition, and feature matching. In this embodiment, after obtaining the projection values of all candidate directions, the projection values are compared, and the candidate direction with the largest projection value can be directly selected as the image orientation of the local image patch. This selection logic indicates that the information matrix has the strongest projection energy in this direction, therefore, this direction can most effectively represent the overall structural orientation of the local image patch.
[0074] Based on the above analysis, this disclosure provides an image local orientation detection method, including: acquiring local image blocks of the image to be processed; generating orthogonal direction vectors for each pixel in the local image block; accumulating the orthogonal direction vectors of each pixel into an autocorrelation matrix to obtain an information matrix corresponding to the local image block; determining the projection values of each preset candidate direction on the information matrix based on the information matrix; and determining the image orientation of the local image block according to the projection values of each candidate direction on the information matrix. In this embodiment, by first dividing the image to be processed into local image blocks, then constructing a region-level information matrix based on pixel-level orthogonal direction vectors, and using a unified projection value comparison mechanism to complete the orientation determination, the orientation detection is transformed from a processing method relying on fixed gradient operators and multiple sets of orientation branches to a processing method relying on the overall matrix expression, thereby reducing the interference of strong local edges, random noise, weak gradient fluctuations, and edge breaks on orientation determination. This method generates direction vectors through the symmetric combination of orthogonal directional gradients, adapting to multi-directional edge scenes. The autocorrelation matrix integrates the gradient distribution of all pixels, ensuring the integrity of directional features and significantly improving direction detection accuracy while reducing the probability of false positives due to fixed window size. Therefore, the image local direction detection method provided in this application can improve the robustness and accuracy of direction detection within local image content, thereby enhancing the accuracy of direction detection.
[0075] Example 2
[0076] In one specific implementation, Figure 3 Flowchart of the image local orientation detection method provided in this application Figure 2 ,like Figure 3 As shown, S202 includes:
[0077] S301. Determine the adjacent pixels of each pixel along the orthogonal direction.
[0078] It's worth noting that adjacent pixels refer to pixels that are orthogonally adjacent to the current pixel, providing a differential reference for the current pixel; the orthogonal gradient value refers to the local change represented by the pixel difference between the current pixel and its adjacent pixels, reflecting the trend of grayscale, brightness, or other image features in the orthogonal direction; the pixel difference refers to the difference in pixel value between the current pixel and its adjacent pixels, and its value can be directly used for subsequent gradient construction. The pixel values corresponding to the above terms can be grayscale values or brightness values after color space conversion.
[0079] S302. Determine the pixel difference between a pixel and its neighboring pixels to obtain the orthogonal gradient value of the pixel.
[0080] In the context of a scenario, orthogonal gradient values refer to the left, right, top, and bottom gradient values corresponding to the current pixel. When calculating the pixel difference between the current pixel and its neighboring pixels, the subtraction direction should remain consistent. For example, in the horizontal direction, with the subtraction direction from left to right, the left gradient value can be obtained by subtracting the current pixel's pixel value from the left neighbor's pixel value, and the right gradient value can be obtained by subtracting the right neighbor's pixel value from the current pixel's pixel value. Alternatively, with the subtraction direction from right to left, the right gradient value can be obtained by subtracting the current pixel's pixel value from the right neighbor's pixel value, and the left gradient value can be obtained by subtracting the left neighbor's pixel value from the current pixel's pixel value. Similarly, in the vertical direction, with the subtraction direction from top to bottom, the top gradient value can be obtained by subtracting the current pixel's pixel value from the top neighbor's pixel value, and the bottom gradient value can be obtained by subtracting the bottom neighbor's pixel value from the current pixel's pixel value. Alternatively, if the subtraction direction is from bottom to top, the lower gradient value can be obtained by subtracting the pixel value of the current pixel from the pixel value of the lower neighboring pixel, and the upper gradient value can be obtained by subtracting the pixel value of the upper neighboring pixel from the pixel value of the current pixel.
[0081] S303. Based on the orthogonal direction gradient value of each pixel, obtain the orthogonal direction vector corresponding to each pixel.
[0082] Based on the scenario example, the gradient value on the left can be denoted as... The gradient value on the right is denoted as The gradient value on the left is denoted as The gradient value on the left is denoted as The orthogonal direction vector is a two-dimensional vector consisting of two elements. The left or right gradient value is determined as one element of the orthogonal direction vector, and the upper or lower gradient value is determined as the other element. These elements are then processed to obtain four orthogonal direction vectors g00, g01, g10, and g11 corresponding to the pixel, where:
[0083]
[0084] This example first obtains adjacent pixels, then calculates the pixel difference to form a gradient value, and finally constructs a direction vector from the gradient value. This allows the variation trends of local edges, textures, and lines to be stored in vector form, enabling subsequent direction determination based on matrix projection to utilize more stable local processing results. This implementation reduces the interference of abnormal fluctuations in single pixels on direction determination, improves the stability of direction representation in weak textures, oblique edges, and noisy scenes, and makes local direction information more suitable for direct use in image enhancement, display optimization, and visual analysis processing.
[0085] Example 3
[0086] Optional, Figure 4 Flowchart of the image local orientation detection method provided in this application Figure 3 ,like Figure 4 As shown, S203 includes:
[0087] S401. Decompose the orthogonal direction vector of the pixel into horizontal and vertical components.
[0088] In a scenario example, the horizontal component refers to the horizontal component of the orthogonal direction vector, used to characterize the local directional change of a pixel in the horizontal direction; the vertical component refers to the vertical component of the orthogonal direction vector, used to characterize the local directional change of a pixel in the vertical direction. For example, in the orthogonal direction vector g00, the corresponding horizontal component is... The corresponding vertical component is In the orthogonal direction vector g01, the corresponding horizontal component is The corresponding vertical component is In the orthogonal direction vector g10, the corresponding horizontal component is: The corresponding vertical component is In the orthogonal direction vector g11, the corresponding horizontal component is: The corresponding vertical component is .
[0089] S402. Determine the corresponding positions of the horizontal and vertical components in the autocorrelation matrix.
[0090] In conjunction with scenario examples, the autocorrelation matrix can be a 2×2 matrix, including four element positions. According to the preset matrix mapping relationship, the horizontal component and the vertical component are mapped to the corresponding element positions in the autocorrelation matrix. For example, the horizontal component is accumulated to the element position representing the horizontal change, the vertical component is accumulated to the element position representing the vertical change, and the coupling relationship between the two is accumulated to the intersection element position.
[0091] S403. Traverse the orthogonal direction vectors of all pixels in the local image patch, and accumulate the horizontal and vertical components of the orthogonal direction vector corresponding to each pixel to the corresponding positions of the autocorrelation matrix to obtain the information matrix.
[0092] With a scenario example, when traversing a local image patch, a pixel-by-pixel scanning method can be used to sequentially read the orthogonal direction vector of each pixel, and the corresponding components of each pixel are accumulated into a matrix. After accumulation, the resulting information matrix can simultaneously reflect the directional distribution characteristics of the local image patch in both horizontal and vertical orthogonal dimensions, and provide a stable processing foundation for subsequent projection calculations of candidate directions.
[0093] The working principle of this method is to decompose the pixel-level orientation vector into two orthogonal components, and then accumulate all pixels uniformly through an autocorrelation matrix, transforming the local orientation information from a discrete vector into a region-level matrix representation. Since the components of each pixel participate in the accumulation, local noise and isolated anomalous responses are smoothed during processing, while the dominant orientation features of local image patches are preserved and enhanced. The resulting information matrix can be directly used for subsequent orientation projection and decision-making, improving the stability and consistency of orientation detection.
[0094] This implementation method enables the expression of directional information of local image patches in a matrix-based processing manner, reducing the impact of abnormal fluctuations in individual pixels on orientation determination, while enhancing adaptability to complex textures, diagonal edges, and intersecting structures. Since the horizontal and vertical components are accumulated to their corresponding positions, the structure of the information matrix is clearer, and subsequent projection calculations are easier to process uniformly, thereby improving the noise resistance, robustness, and computational efficiency of local image orientation detection.
[0095] Example 4
[0096] In one specific implementation, Figure 5 Flowchart of the image local orientation detection method provided in this application Figure 4 ,like Figure 5 As shown, S403 includes:
[0097] S501. Determine the algorithm corresponding to each position in the autocorrelation matrix.
[0098] In a scenario example, the autocorrelation matrix (ACM) carries the directional distribution information within a local image patch. The corresponding algorithm at each position defines the accumulation rules of the matrix elements, enabling different positions to process the input components according to a preset algorithm. The ACM can be constructed as a two-dimensional matrix, with each position corresponding to a combination of horizontal and vertical components. When determining the algorithm for each position, different operation rules can be established based on the row and column indices of the matrix elements. For example, square accumulation can be used for the main diagonal positions, while cross-term accumulation can be used for the off-diagonal positions.
[0099] For example, the algorithm corresponding to each position in the autocorrelation matrix is shown below:
[0100]
[0101] Where C is the information matrix, The horizontal component represents the i-th orthogonal direction vector. It represents the vertical component of the i-th orthogonal direction vector.
[0102] S502. Using the algorithm corresponding to each position, the horizontal and / or vertical components of the orthogonal direction vector corresponding to each pixel are calculated and then summed to obtain the information matrix.
[0103] With a scenario example, when traversing a local image patch, the orthogonal direction vector corresponding to each pixel is first read. Then, the horizontal and / or vertical components are processed according to the algorithm corresponding to each position. Subsequently, the data is written to the corresponding position in the autocorrelation matrix and continuously accumulated until all pixels have been processed. The resulting information matrix can reflect the dominant direction distribution of the local image patch under a unified matrix expression and can provide a stable input for subsequent direction projection calculations.
[0104] For example, each pixel includes four orthogonal direction vectors. When processing the orthogonal direction vector g00, the horizontal component is... The squares are accumulated to the top left position, and then... The squares are accumulated to the bottom right position, and then... and The multiplication and accumulation are applied to the top right and bottom positions. For other orthogonal direction vectors corresponding to this pixel, as well as the orthogonal direction vectors corresponding to other pixels, the calculations are performed and accumulated according to the algorithm at each position to obtain the corresponding information matrix.
[0105] This disclosure improves the information matrix's adaptability to noise, weak edges, and multi-directional textures by introducing corresponding algorithms at each position of the matrix. Instead of simply superimposing pixel orientation components into the processing, these components undergo differentiated calculations based on their positional attributes before being accumulated. Since the matrix elements comprehensively reflect the directional energy distribution of local image patches, more stable projection results can be obtained during subsequent orientation determination, thereby improving the accuracy and robustness of local orientation detection.
[0106] Example 5
[0107] In one specific implementation, Figure 6 Flowchart of the image local orientation detection method provided in this application Figure 5 ,like Figure 6As shown, S204 includes:
[0108] S601. Determine the candidate direction vector corresponding to each candidate direction.
[0109] The candidate direction vector is a reference direction vector that corresponds one-to-one with each pre-set candidate direction, used to characterize the matching benchmark of the local image patch in the discrete direction set. This vector can be constructed from pre-defined angle parameters and adapted to the dimension of the information matrix so as to participate in matrix multiplication operations.
[0110] Figure 7 This diagram illustrates 16 possible directions, including both horizontal and vertical ones. The angle between each candidate direction and the horizontal line is determined, denoted as θ. The candidate direction vector can be represented as... The candidate direction vector can be represented as a two-dimensional column vector containing direction cosine and direction sine. The candidate direction vector can then be obtained using the following formula:
[0111]
[0112] For example, for the horizontal candidate direction, since the angle with the horizontal line is 0, the corresponding candidate direction vector is:
[0113]
[0114] S602. For each candidate direction, the product of the corresponding candidate direction vector, the transpose of the candidate direction vector, and the information matrix is determined as the projection value of the candidate direction onto the information matrix.
[0115] In practical processing, each candidate direction vector can be stored in a direction lookup table for direct retrieval after generating an information matrix for a local image patch. Subsequently, a candidate direction vector and its transpose are multiplied by the information matrix to obtain the scalar response value corresponding to that direction, which is used as the projection value of that candidate direction onto the information matrix.
[0116] For example, the projected value can be represented as ,
[0117]
[0118] in, Alternate direction vectors The transpose of .
[0119] This response value reflects the energy distribution of the information matrix in the corresponding direction. The larger the value, the more consistent the direction is with the dominant structure of the local image patch.
[0120] In this approach, candidate directions are first converted into direction vectors of a unified format. Then, the projection calculation is performed using the product relationship between the direction vector, its transpose, and the information matrix. This ensures that the evaluation of different directions is based on the same matrix, thus avoiding the need to set up independent detection logic for each direction. This implementation improves the consistency of direction response, enabling stable projection results for local image patches even under conditions of multi-directional textures, weak edges, and noise interference. It also provides a reliable basis for subsequently determining image directions based on projection values.
[0121] Example 6
[0122] In one specific implementation, Figure 7 Flowchart of the image local orientation detection method provided in this application Figure 6 ,like Figure 7 As shown, S205 includes:
[0123] S701. Sort the projection values of each candidate direction onto the information matrix.
[0124] In this embodiment, the candidate directions are a pre-defined set of candidate angles, and the information matrix is a matrix representation of the pixel directions in a local image patch. Both serve as the input basis for direction determination. Sorting can be implemented in descending order, or, when hardware or software resources are limited, the maximum projection value can be calculated first, and the remaining projection values can be compared simultaneously to achieve an equivalent sort.
[0125] S702. The candidate direction with the largest projection value is determined as the image direction of the local image block.
[0126] The projection value is used to characterize the degree of matching between a candidate direction and the local dominant structure reflected by the information matrix. The larger the projection value, the more representative the direction of the local image patch is of the overall directional characteristics. Therefore, the candidate direction with the largest projection value is the image direction of the local image patch.
[0127] In this embodiment, the information matrix can be formed by accumulating the orthogonal direction vectors of each pixel within a local image patch, thus containing comprehensive information about the horizontal, vertical, and diagonal structures within that local region. When projecting each candidate direction based on this matrix, the direction responses of multiple pixels and locations can be uniformly mapped to the same evaluation scale, thereby avoiding interference from single-point gradient fluctuations in direction determination. By sorting the projection values of all candidate directions and selecting the direction corresponding to the maximum value, the output direction can be made consistent with the dominant edge direction or texture arrangement direction in the local image patch, making it suitable for complex scenes such as road markings, text strokes, building edges, and natural textures.
[0128] With this implementation, direction determination no longer relies on a single pixel or local extrema, but rather on a comparison based on the overall processing results, thus improving stability under conditions of complex textures, weak contrast, and noise interference. Furthermore, the direction corresponding to the maximum value is directly selected after sorting, resulting in clear logic and a simple calculation path, facilitating real-time processing in image processing chips, terminal devices, or edge computing modules.
[0129] Figure 8 This is a schematic diagram of the image local orientation detection device provided in the embodiments of this application, as shown below. Figure 8 As shown, it includes:
[0130] The acquisition module 81 is used to acquire local image patches of the image to be processed;
[0131] Generation module 82 is used to generate orthogonal direction vectors for each pixel in a local image patch;
[0132] Processing module 83 is used to accumulate the orthogonal direction vectors of each pixel into the autocorrelation matrix to obtain the information matrix corresponding to the local image patch;
[0133] The processing module 83 is also used to determine the projection values of each preset candidate direction on the information matrix based on the information matrix;
[0134] The processing module 83 is also used to determine the image orientation of the local image block based on the projection values of each candidate orientation onto the information matrix.
[0135] Optionally, the generation module 82 is specifically used to determine the adjacent pixels corresponding to each pixel along the orthogonal direction;
[0136] The generation module 82 is further used to determine the pixel difference between a pixel and its neighboring pixels in order to obtain the orthogonal gradient value of the pixel.
[0137] The generation module 82 is further used to obtain the orthogonal direction vector corresponding to each pixel based on the orthogonal direction gradient value of each pixel.
[0138] Optionally, the processing module 83 is specifically used to split the orthogonal direction vector of the pixel into a horizontal component and a vertical component;
[0139] Processing module 83 is also specifically used to determine the corresponding positions of the horizontal and vertical components in the autocorrelation matrix;
[0140] The processing module 83 is further used to traverse the orthogonal direction vectors of all pixels in the local image block, so as to accumulate the horizontal and vertical components of the orthogonal direction vector corresponding to each pixel to the corresponding positions of the autocorrelation matrix to obtain the information matrix.
[0141] Optionally, the processing module 83 is further used to determine the algorithm corresponding to each position in the autocorrelation matrix;
[0142] The processing module 83 is further used to perform calculations on the horizontal and / or vertical components of the orthogonal direction vector corresponding to each pixel point using the algorithm corresponding to each position, and then accumulate them to obtain an information matrix.
[0143] Optionally, the processing module 83 is further used to determine the candidate direction vector corresponding to each candidate direction;
[0144] The processing module 83 is further used to determine the projection value of the candidate direction onto the information matrix by multiplying the corresponding candidate direction vector, the transpose of the candidate direction vector, and the information matrix for each candidate direction.
[0145] Optionally, the processing module 83 is further used to sort the projection values of each alternative direction onto the information matrix;
[0146] The processing module 83 is further used to determine the candidate direction with the largest projection value as the image direction of the local image block.
[0147] The image local orientation detection device provided in this embodiment can execute the image local orientation detection method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.
[0148] Figure 9 A schematic diagram of the structure of the electronic device provided in this application. Figure 9 As shown, the electronic device 50 provided in this embodiment includes at least one processor 501 and a memory 502. Optionally, the electronic device 50 further includes a communication component 503. The processor 501, memory 502, and communication component 503 are connected via a bus.
[0149] In a specific implementation, at least one processor 501 executes computer execution instructions stored in memory 502, causing at least one processor 501 to perform the above-described method.
[0150] The specific implementation process of processor 501 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0151] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0152] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0153] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0154] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0155] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.
[0156] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0157] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.
[0158] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0159] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0160] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0161] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to related technologies, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0162] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0163] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A method for detecting local orientation in an image, characterized in that, include: Obtain a local image patch of the image to be processed; Generate orthogonal direction vectors for each pixel in the local image block; The orthogonal direction vectors of each pixel are accumulated into the autocorrelation matrix to obtain the information matrix corresponding to the local image patch; Based on the information matrix, determine the projection value of each preset candidate direction onto the information matrix; The image orientation of the local image block is determined based on the projection values of each candidate orientation onto the information matrix.
2. The method according to claim 1, characterized in that, The generation of orthogonal direction vectors for each pixel in the local image patch includes: Determine the adjacent pixels of each pixel along the orthogonal direction; Determine the pixel difference between the pixel and its neighboring pixels to obtain the orthogonal gradient value of the pixel; Based on the orthogonal gradient values of each pixel, the orthogonal direction vector corresponding to each pixel is obtained.
3. The method according to claim 1, characterized in that, The step of accumulating the orthogonal direction vectors of each pixel into the autocorrelation matrix to obtain the information matrix corresponding to the local image patch includes: The orthogonal direction vector of the pixel is split into a horizontal component and a vertical component; Determine the corresponding positions of the horizontal and vertical components in the autocorrelation matrix; The orthogonal direction vectors of all pixels in the local image block are traversed, and the horizontal and vertical components of the orthogonal direction vector corresponding to each pixel are accumulated to the corresponding positions of the autocorrelation matrix to obtain the information matrix.
4. The method according to claim 3, characterized in that, The process involves traversing the orthogonal direction vectors of all pixels in the local image patch, and then accumulating the horizontal and vertical components of the orthogonal direction vector corresponding to each pixel to the corresponding positions in the autocorrelation matrix to obtain the information matrix, including: Determine the algorithm corresponding to each position in the autocorrelation matrix; The information matrix is obtained by calculating and accumulating the horizontal and / or vertical components of the orthogonal direction vector corresponding to each pixel using the algorithm corresponding to each position.
5. The method according to claim 1, characterized in that, Based on the information matrix, the projection values of each preset candidate direction onto the information matrix are determined, including: Determine the candidate direction vector corresponding to each candidate direction; For each candidate direction, the product of the corresponding candidate direction vector, the transpose of the candidate direction vector, and the information matrix is determined as the projection value of the candidate direction onto the information matrix.
6. The method according to claim 1, characterized in that, Determining the image orientation of the local image patch based on the projection values of each candidate orientation onto the information matrix includes: Sort the projection values of each candidate direction onto the information matrix; The candidate direction with the largest projection value is determined as the image direction of the local image block.
7. An image local orientation detection device, characterized in that, include: The acquisition module is used to acquire local image patches of the image to be processed; The generation module is used to generate orthogonal direction vectors for each pixel in the local image block; The processing module is used to accumulate the orthogonal direction vectors of each pixel into the autocorrelation matrix to obtain the information matrix corresponding to the local image patch; The processing module is also used to determine the projection value of each preset candidate direction on the information matrix based on the information matrix; The processing module is also used to determine the image orientation of the local image block based on the projection values of each alternative orientation onto the information matrix.
8. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the image local orientation detection method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the image local orientation detection method as described in any one of claims 1-6.
10. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the image local orientation detection method as described in any one of claims 1-6.