Hyperspectral image particle segmentation method and device
By constructing a preset matrix and coherence value of the hyperspectral image to judge the candidate edge pixels, and combining spatial and spectral information to perform hyperspectral image particle segmentation, the problem of low segmentation accuracy in the existing technology is solved, and higher segmentation accuracy and edge detection accuracy are achieved.
Patent Information
- Application Number
- CN202511211844.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-28
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-08-28
AI Technical Summary
Existing hyperspectral image particle segmentation methods have low segmentation accuracy in rock thin sections due to large differences in mineral particle size, spectral signal overlap and noise interference. It is particularly difficult to segment particles with blurred edges but different mineral compositions.
By obtaining the spectral vector of the local area of the image to be processed, constructing a preset matrix and calculating the eigenvalue, it is determined whether the pixel is a candidate edge pixel. The spatial dimension and spectral dimension information are combined for segmentation, and the coherence value and watershed segmentation methods are used to improve the accuracy.
It improves the accuracy of hyperspectral image particle segmentation, reduces misjudgment, improves the accuracy of edge detection, and can achieve accurate segmentation of mineral particles in complex lithofacies backgrounds.
Smart Images

Figure CN120747144A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a hyperspectral image particle segmentation method and device. Background Art
[0002] Hyperspectral imaging technology can be used to image and analyze rock thin sections. The obtained hyperspectral images include characteristic data of the spatial and spectral dimensions of the rock thin sections. Through image analysis, mineral composition identification, grain boundary division or spatial distribution quantification can be achieved, providing key data support for the analysis of reservoir microscopic characteristics.
[0003] Mineral particle segmentation based on hyperspectral imagery is a core technology. However, thin rock sections often present complex matrix backgrounds and gradual mineral contact boundaries. Mineral particle segmentation is often extremely challenging due to large size differences, spectral signal overlap, blurred edges, and noise interference. Existing edge detection methods use spatial gradient information in images to detect particle edges. However, the accuracy of mineral particle segmentation in these images is low. For example, it is difficult to separate particles with blurred edges but different mineral compositions. Summary of the Invention
[0004] In view of this, an object of the present invention is to provide a method and apparatus for particle segmentation of a hyperspectral image, which can improve the accuracy of particle segmentation based on a hyperspectral image.
[0005] To achieve the above object, the present invention provides the following technical solutions: A hyperspectral image particle segmentation method, comprising: Acquire an image to be processed, wherein any pixel of the image to be processed includes data of multiple spectral bands; For any pixel of the image to be processed, a local area corresponding to the pixel is selected in the image to be processed, where the local area corresponding to the pixel is a local area including the pixel, and a plurality of spectral vectors corresponding to the pixel are obtained, where the plurality of spectral vectors corresponding to the pixel are spectral vectors of pixels included in the local area corresponding to the pixel, where the spectral vector of the pixel is formed by data of the plurality of spectral bands of the pixel; For any pixel of the image to be processed, obtaining a preset matrix for the pixel, where the preset matrix for the pixel is formed by the covariance of any two spectral vectors among a plurality of spectral vectors corresponding to the pixel, and obtaining a plurality of eigenvalues of the preset matrix for the pixel, and determining the pixel as a candidate edge pixel if a difference in magnitudes of the plurality of eigenvalues of the pixel meets a first preset requirement; The image to be processed is binarized according to whether any pixel of the image to be processed is the candidate edge pixel to obtain an edge image. In the edge image, the pixel is determined to be a pixel in the particle area or an edge pixel of the particle area according to the gray value of the pixel, and the particle area is segmented.
[0006] In some embodiments, selecting the local area corresponding to the pixel in the image to be processed includes: In the image to be processed, a local area centered on the pixel is selected as the local area corresponding to the pixel.
[0007] In some embodiments, obtaining a preset matrix of the pixel includes: Obtaining a data matrix of the pixel, where the data matrix of the pixel is formed by a plurality of spectral vectors corresponding to the pixel; The transposed matrix of the data matrix of the pixel is multiplied by the data matrix of the pixel to obtain the preset matrix of the pixel.
[0008] In some embodiments, the coherence value of the pixel is used to represent the size difference of the multiple eigenvalues of the pixel, and the coherence value of the pixel is the ratio of the absolute value of the maximum eigenvalue among the multiple eigenvalues of the pixel to the sum of the absolute values of the multiple eigenvalues; The difference in the sizes of the multiple characteristic values of the pixel meeting the first preset requirement includes: the coherence value of the pixel being greater than a first threshold.
[0009] In some embodiments, determining in the edge image that a pixel is a pixel in a particle region or an edge pixel of the particle region based on a grayscale value of the pixel, and segmenting the particle region includes: In the edge image, seeds are selected from pixels other than the candidate edge pixels and a target area is grown using the seeds. In the target area grown using the seeds, for adjacent pixels of the target area, the adjacent pixels are classified as pixels within the target area or as edge pixels of the target area according to the grayscale values of the adjacent pixels, and the target area obtained by growth is determined as the particle area.
[0010] In some embodiments, in the edge image, selecting seeds from pixels other than the candidate edge pixels includes: in the edge image, for any non-candidate edge pixel, obtaining the distance from the non-candidate edge pixel to the nearest candidate edge pixel, selecting the non-candidate edge pixel whose distance meets a second preset requirement as a seed pixel, and obtaining a connected domain formed by the seed pixels as the seed.
[0011] In some embodiments, for any pixel of the image to be processed, before selecting the local area corresponding to the pixel in the image to be processed, the method further includes: For any pixel of the image to be processed, obtaining a spectral similarity weight and a spatial distance weight of the pixel with respect to any pixel in a neighborhood of the pixel, wherein the spectral similarity weight of the pixel is obtained based on a first ratio of the pixel, where the first ratio of the pixel is a ratio of a dot product of the spectral vector of the pixel and the spectral vector of any pixel in the neighborhood of the pixel, and a product of a length of the spectral vector of the pixel and the length of the spectral vector of any pixel in the neighborhood of the pixel, and the spatial distance weight of the pixel is obtained based on a distance between the pixel and any pixel in the neighborhood of the pixel; For any pixel of the image to be processed, the spectral vectors of each pixel in the neighborhood of the pixel are weighted averaged using the spectral similarity weight and spatial distance weight corresponding to the pixels in the neighborhood of the pixel, and the obtained vector is used as the spectral vector of the pixel.
[0012] In some embodiments, performing weighted averaging on the spectral vectors of each pixel in the neighborhood of the pixel using the spectral similarity weights and spatial distance weights corresponding to the pixels in the neighborhood of the pixel includes: Calculating a first summation result and a second summation result, where the first summation result is the sum of first products of each pixel in a neighborhood of the pixel, where the first product is the product of the spectral vector of the pixel in the neighborhood of the pixel, the spectral similarity weight corresponding to the pixel in the neighborhood of the pixel, and the spatial distance weight; and the second summation result is the sum of second products of each pixel in the neighborhood of the pixel, where the second product is the product of the spectral similarity weight corresponding to the pixel in the neighborhood of the pixel and the spatial distance weight; The ratio of the first summation result to the second summation result is obtained, and the obtained vector is used as the spectral vector of the pixel.
[0013] In some embodiments, before determining in the edge image according to the grayscale value of the pixel that the pixel is a pixel in the particle area or an edge pixel of the particle area, the method further includes: Performing a first preset operation on the edge image, including: traversing pixels of the edge image with a first preset structuring element, and when the first preset structuring element moves to any pixel of the edge image, if there is at least one candidate edge pixel within a coverage range of the first preset structuring element, determining the any pixel as a candidate edge pixel; Performing a second preset operation on the edge image that has undergone the first preset operation includes: traversing pixels of the edge image with a second preset structuring element, and when the second preset structuring element moves to any pixel of the edge image, if all pixels within a coverage range of the second preset structuring element are candidate edge pixels, then determining the any pixel as a candidate edge pixel; if there is at least one non-candidate edge pixel within the coverage range of the second preset structuring element, then determining the any pixel as a non-candidate edge pixel.
[0014] A hyperspectral image particle segmentation device, comprising: memory for storing computer programs; A processor is configured to implement the steps of any one of the above methods for hyperspectral image particle segmentation when executing the computer program.
[0015] It can be seen from the above technical solution that the hyperspectral image particle segmentation method and device provided by the present invention include: obtaining an image to be processed, wherein any pixel of the image to be processed includes data of multiple spectral bands; for any pixel of the image to be processed, selecting a local area corresponding to the pixel in the image to be processed, and obtaining multiple spectral vectors corresponding to the pixel, the multiple spectral vectors corresponding to the pixel are spectral vectors of pixels contained in the local area corresponding to the pixel, and the spectral vector of the pixel is formed by the data of the multiple spectral bands of the pixel; for any pixel of the image to be processed, obtaining a preset matrix of the pixel, which is formed by the covariance of any two spectral vectors among the multiple spectral vectors corresponding to the pixel, and obtaining multiple eigenvalues of the preset matrix of the pixel, if the size difference of the multiple eigenvalues of the pixel meets the first preset requirement, then the pixel is determined as a candidate edge pixel; according to whether any pixel of the image to be processed is a candidate edge pixel, the image to be processed is binarized to obtain an edge image, and in the edge image, the pixel is determined as a pixel in the particle area or an edge pixel of the particle area according to the grayscale value of the pixel, thereby segmenting the particle area.
[0016] The beneficial effects of the present invention are that the local area corresponding to the pixel is selected and a preset matrix of the pixel is constructed based on the spectral vector of the pixel in the local area. The preset matrix of the pixel reflects the changes in the spatial dimension information and spectral dimension information of the local area corresponding to the pixel. The pixel is judged whether it is a candidate edge pixel based on the eigenvalue of the preset matrix, so that the judgment of whether the pixel is a candidate edge pixel combines the characteristics of the spatial dimension and the spectral dimension. Compared with the existing edge detection method that only uses the spatial gradient information of the image to detect the edge, it can improve the accuracy of detecting edge pixels. Further, according to the candidate edge pixels, the particle area is segmented, which can improve the accuracy of segmenting the particle area. Therefore, the hyperspectral image particle segmentation method and device of the present invention can improve the accuracy of detecting edge pixels and can improve the accuracy of particle segmentation based on hyperspectral images. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 A flowchart of a hyperspectral image particle segmentation method provided by an embodiment; Figure 2-1 A three-dimensional data cube of a thin section of quartz rock obtained for a specific example; Figure 2-2 A three-dimensional data cube of a thin section of feldspar-containing quartz rock obtained for a specific example; Figure 3-1 Three single-band images of a thin section of quartz-bearing rock acquired for a specific example; Figure 3-2 Three single-band images of a thin section of feldspar-bearing quartz rock obtained for a specific example; Figure 4-1 An image of a thin section of quartz rock obtained for a specific instance, from which candidate edge pixels are screened; Figure 4-2 An image of a thin section of a feldspar-containing quartz rock obtained for a specific example, from which candidate edge pixels are screened; Figure 5-1 A grain-segmented image of a thin section of quartz-bearing rock obtained for a specific example; Figure 5-2 A grain-segmented image of a thin section of feldspar-bearing quartz rock obtained for a specific example. DETAILED DESCRIPTION
[0019] In order to enable those skilled in the art to better understand the technical solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0020] For reference Figure 1 , Figure 1 This is a flow chart of a hyperspectral image particle segmentation method provided by an embodiment. As shown in the figure, the hyperspectral image particle segmentation method includes the following steps.
[0021] S11: Acquire an image to be processed, where any pixel of the image to be processed includes data of multiple spectral bands.
[0022] The image to be processed includes spatial dimension data and spectral dimension data. The data of multiple spectral bands included in any pixel form spectral dimension data, and the data included in each pixel of the image to be processed forms spatial dimension data.
[0023] S12: For any pixel of the image to be processed, select a local area corresponding to the pixel in the image to be processed, where the local area corresponding to the pixel is the local area including the pixel, and obtain multiple spectral vectors corresponding to the pixel, where the multiple spectral vectors corresponding to the pixel are spectral vectors of pixels included in the local area corresponding to the pixel, and the spectral vector of the pixel is formed by data of the multiple spectral bands of the pixel.
[0024] For any pixel, the spectral vector of the pixel is formed by the data of the multiple spectral bands of the pixel.
[0025] For any pixel, a local area corresponding to the pixel is selected in the image to be processed, and multiple spectral vectors corresponding to the pixel are further obtained, that is, the spectral vectors of each pixel contained in the local area corresponding to the pixel are obtained.
[0026] S13: For any pixel of the image to be processed, obtain a preset matrix of the pixel, where the preset matrix of the pixel is formed by the covariance of any two spectral vectors among the multiple spectral vectors corresponding to the pixel, and obtain multiple eigenvalues of the preset matrix of the pixel. If the size difference of the multiple eigenvalues of the pixel meets a first preset requirement, the pixel is determined as a candidate edge pixel.
[0027] A preset matrix is obtained for each pixel. The pixel's preset matrix is formed by the covariance between any two spectral vectors from the multiple spectral vectors corresponding to the pixel. The covariance between two spectral vectors reflects the degree of linear correlation between the two spectral vectors. The eigenvalues of the preset matrix for the pixel measure the directional consistency of the gradients of each pixel in the local area corresponding to the pixel.
[0028] For any pixel, if the pixel is located in a non-edge region, i.e., an interior region, of a particle, the spatial data and spectral data of the local region corresponding to the pixel vary slightly, the multiple eigenvalues of the pixel are relatively uniform, and the difference in the magnitude of the multiple eigenvalues of the pixel is small. If the pixel is located at the edge of a particle, the spatial data and / or spectral data of the local region corresponding to the pixel vary significantly, the multiple eigenvalues of the pixel are non-uniform, and the difference in the magnitude of the multiple eigenvalues of the pixel is large. Based on this, if the difference in the magnitude of the multiple eigenvalues of the pixel meets a first preset requirement, the pixel is determined to be a candidate edge pixel.
[0029] S14: Binarize the image to be processed according to whether any pixel of the image to be processed is the candidate edge pixel to obtain an edge image, determine in the edge image whether the pixel is a pixel in the particle area or an edge pixel of the particle area according to the grayscale value of the pixel, and segment the particle area.
[0030] For any pixel, the pixel is binarized according to whether it is a candidate edge pixel.
[0031] In the edge image, the pixel is determined to be a pixel in the particle area or an edge pixel of the particle area according to the gray value of the pixel in the edge image, and the particle area is segmented according to the edge image.
[0032] The hyperspectral image particle segmentation method of this embodiment selects a local region corresponding to a pixel and constructs a preset matrix for the pixel based on the spectral vectors of the pixels within the local region. The preset matrix of the pixel reflects the changes in the spatial and spectral dimension information of the local region corresponding to the pixel. The pixel is then determined to be a candidate edge pixel based on the eigenvalues of the preset matrix. This determination combines the characteristics of the spatial and spectral dimensions. Compared to existing edge detection methods that only use the spatial gradient information of the image to detect edges, this method can improve the accuracy of detecting edge pixels. Furthermore, particle regions can be segmented based on the candidate edge pixels, thereby improving the accuracy of segmenting particle regions. Therefore, the hyperspectral image particle segmentation method of this embodiment can improve the accuracy of detecting edge pixels and improve the accuracy of particle segmentation based on hyperspectral images.
[0033] In some embodiments, the image to be processed can be considered a three-dimensional data cube comprising spatial and spectral data. Any pixel in the image to be processed includes data from multiple spectral bands. Such images are typically referred to as hyperspectral images. The spectral vector I(x) for pixel x is formed by the data from these multiple spectral bands. The data for pixel x in these multiple spectral bands can be extracted from the three-dimensional data cube of the image to be processed and arranged in band order to obtain the spectral vector I(x).
[0034] Selecting the local region corresponding to the pixel in the image to be processed includes: selecting a local region centered on the pixel in the image to be processed as the local region corresponding to the pixel. For example, a region centered on the pixel and including M×M pixels can be selected as the local region corresponding to the pixel, where M is a positive integer greater than or equal to 3. The local region corresponding to the pixel can also be referred to as a local window of the pixel.
[0035] In some embodiments, obtaining the preset matrix of the pixel includes: obtaining the data matrix of the pixel, the data matrix of the pixel being formed by a plurality of spectral vectors corresponding to the pixel; and multiplying the transposed matrix of the data matrix of the pixel by the data matrix of the pixel to obtain the preset matrix of the pixel. The plurality of spectral vectors corresponding to the pixel are spectral vectors of a plurality of pixels contained in the local area corresponding to the pixel, and the data matrix of the pixel is obtained based on the plurality of spectral vectors corresponding to the pixel. Exemplarily, the data matrix of the pixel can be expressed as W, and the multiplication of the transposed matrix of the data matrix of the pixel by the data matrix of the pixel can be expressed as: A=W T W; A represents a preset matrix. Any element in the preset matrix A represents the covariance between any pair of spectral vectors among the multiple spectral vectors corresponding to the pixel. The preset matrix A can reflect the changes in the spatial dimension information and spectral dimension information of the local area corresponding to the pixel, and measures the gradient of the fusion features of the spatial dimension data and spectral dimension data of the local area corresponding to the pixel. The preset matrix A can be called an autocovariance matrix, which captures the changes in the spectral dimension and spatial dimension features at the same time through the covariance of any two spectral vectors among the multiple spectral vectors corresponding to the pixel.
[0036] In some embodiments, the coherence value of the pixel is used to represent the difference in magnitude of the multiple eigenvalues of the pixel, and the coherence value of the pixel is the ratio of the absolute value of the maximum eigenvalue among the multiple eigenvalues of the pixel to the sum of the absolute values of the multiple eigenvalues. The difference in magnitude of the multiple eigenvalues of the pixel meeting a first preset requirement includes: the coherence value of the pixel being greater than a first threshold.
[0037] In the method of this embodiment, by selecting the local area corresponding to the pixel and constructing a preset matrix of the pixel, the preset matrix of the pixel is formed by the covariance between any two spectral vectors among the multiple spectral vectors of the local area corresponding to the pixel. The preset matrix can reflect the changes in the spatial and spectral dimensional information of the local area corresponding to the pixel. Compared with the method of calculating the gradient separately for each spectral band and each direction and then fusing them, this method performs statistics on the local area corresponding to the pixel at one time, which can not only suppress noise more stably, but also naturally fuse the spatial data gradient and the spectral data gradient into the same metric, and further use the coherence value to concisely express the consistency of local multidimensional changes. However, the differential calculation performed when calculating the gradient separately for each spectral band and each direction may amplify random noise.
[0038] For example, the coherence value of this pixel can be expressed as: ; (1) Where c represents the coherence value, λ max represents the maximum eigenvalue, λ iRepresents the i-th eigenvalue. The preset matrix A can be decomposed into multiple eigenvalues by eigenvalue decomposition. These eigenvalues are arranged from large to small according to their absolute values, and the coherence value is further calculated according to the above formula (1).
[0039] Coherence can measure the consistency of local gradients in a certain direction. The difference in the size of the multiple eigenvalues of the pixel's preset matrix determines the level of coherence. If in a local area, all gradient vectors change in almost the same direction (corresponding to the edge position), then the corresponding preset matrix has a large main eigenvalue, and the other eigenvalues are relatively small, and the coherence value will be large (close to 1). If it is a non-edge area, all eigenvalues are close in size, and the coherence value will be small. If the pixel is at the edge of the particle, the spatial data and / or spectral data of the local area corresponding to the pixel vary greatly, the maximum eigenvalue is much larger than the other eigenvalues, and the coherence value approaches 1; if the pixel is in the internal area of the particle, the spatial data and spectral data of the local area corresponding to the pixel vary little, the eigenvalues are evenly distributed, and the coherence value approaches 0.
[0040] In practical applications, by traversing the pixels of the image to be processed, a coherence value matrix with the same size as the original image to be processed can be generated, and then candidate edge pixels can be screened based on the coherence value matrix, and pixels with coherence values greater than a first threshold can be marked as candidate edge pixels to obtain preliminary edge detection results. The method of this embodiment can be considered to have adopted a coherent edge detection method. By selecting the local area corresponding to the pixel and constructing a preset matrix of pixels, a structural tensor analysis is performed on the local neighborhood of the pixel, and the coherence value reflecting the joint spatial and spectral characteristics is calculated to detect the edge. The spectral gradient and spatial gradient information of the image to be processed are organically integrated, so that the boundary positioning error of spectrally similar minerals is significantly reduced. Compared with the existing edge detection method that only uses the spatial information of the image to detect the edge, it overcomes the problem of insufficient utilization of spectral information, reduces misjudgment, and improves the accuracy of edge detection.
[0041] In some embodiments, binarizing the image to be processed according to whether any pixel of the image to be processed is the candidate edge pixel to obtain the edge image includes: for any pixel of the image to be processed, if the pixel is a candidate edge pixel, setting the value of the pixel to 1; if the pixel is a non-candidate edge pixel, setting the value of the pixel to 0 to obtain the edge image. Non-candidate edge pixels refer to pixels that are not determined to be candidate edge pixels, that is, pixels other than candidate edge pixels. After the image to be processed is binarized, pixels with values of 1 and 0 can be assigned corresponding grayscale values respectively to obtain the edge image. For example, pixels with a value of 1 are assigned a grayscale value of 255, and pixels with a value of 0 are assigned a grayscale value of 1.
[0042] In some embodiments, in an edge image, a pixel is determined to be a pixel within a particle region or an edge pixel of the particle region based on its grayscale value, and segmenting the particle region includes: in the edge image, selecting seeds from pixels other than the candidate edge pixels and growing a target region with the seeds, and in the target region grown with the seeds, for adjacent pixels of the target region, determining to classify the adjacent pixels as pixels within the target region or as edge pixels of the target region based on their grayscale values, and determining the grown target region as the particle region.
[0043] Growing a target area with a seed includes: the target area expands from the seed to the adjacent pixels. For the adjacent pixels of the current target area, if the adjacent pixels are determined to be pixels within the target area of the seed based on the grayscale values of the adjacent pixels, the expansion continues to the adjacent pixels of the target area after growth. If the adjacent pixels are determined to be edge pixels based on the grayscale values of the adjacent pixels, the growth is stopped, and the target area obtained after the growth is stopped is determined as the particle area.
[0044] In some embodiments, determining in the edge image whether a pixel is a pixel within a particle region or an edge pixel of the particle region based on its grayscale value may include: if the grayscale value of the pixel in the edge image satisfies a first preset condition, determining the pixel as a pixel within the particle region; and if the grayscale value of the pixel satisfies a second preset condition, determining the pixel as an edge pixel of the particle region. Accordingly, growing a target region using a seed may include: expanding the target region from the seed toward adjacent pixels; if the grayscale values of adjacent pixels in the current target region satisfy the first preset condition, classifying the adjacent pixels as the target region for the seed; if the grayscale values of adjacent pixels in the current target region satisfy the second preset condition, stopping growth and treating the adjacent pixels as edge pixels of the target region for the seed; and determining the target region obtained after stopping growth as the particle region. In some embodiments, the grayscale value of a pixel satisfying the first preset condition may be that the grayscale value of the pixel is less than a third threshold, where the first preset condition is a low gradient condition. The grayscale value of a pixel satisfying the second preset condition may be that the grayscale value of the pixel is greater than a fourth threshold, where the second preset condition is a high gradient condition.
[0045] In this embodiment, the image to be processed is binarized according to whether the pixel is a candidate edge pixel to obtain an edge image, and the particle area is segmented according to the grayscale value of the pixel in the edge image. The candidate edge pixels are used as constraints to limit the region growth across the edge to ensure that the segmentation boundary and the actual particle edge are consistent. In the method of this embodiment, based on the change of the grayscale value of the pixel in the edge image, the adjacent pixels with smaller gradients are assimilated from the seed, and the region growth is performed according to the change of the pixel grayscale value. When the candidate edge pixel is encountered, the growth is stopped. As the growth process progresses, different particle areas gradually expand. This embodiment adopts the watershed segmentation method. If the method of this embodiment is applied to the image of the mineral slice, according to the watershed segmentation result, each target area obtained by growth corresponds to an independent mineral particle, thereby achieving accurate segmentation of mineral particles in a complex lithological background. In some embodiments, the fourth threshold value can be set according to the grayscale value corresponding to the candidate edge pixel in the edge image.
[0046] In some embodiments, in an edge image, selecting seeds from pixels other than the candidate edge pixels includes: in the edge image, for any non-candidate edge pixel, obtaining the distance from the non-candidate edge pixel to the nearest candidate edge pixel, selecting the non-candidate edge pixel whose distance meets the second preset requirement as a seed pixel, and obtaining the connected domain formed by the seed pixels as the seed. Non-candidate edge pixels refer to pixels that are not determined to be candidate edge pixels, that is, pixels other than candidate edge pixels. For any non-candidate edge pixel, calculate the distance from the non-candidate edge pixel to the nearest candidate edge pixel. The greater the distance from the non-candidate edge pixel to the nearest candidate edge pixel, the farther the non-candidate edge pixel is from the edge and the higher the possibility that it is inside the particle. Based on this, if the distance corresponding to the non-candidate edge pixel meets the second preset requirement, the non-candidate edge pixel is used as a seed pixel.
[0047] In some embodiments, the distance of the non-candidate edge pixel meeting the second preset requirement may be that the distance of the non-candidate edge pixel is greater than a second threshold. In the edge image, for any non-candidate edge pixel, the distance from the non-candidate edge pixel to the nearest candidate edge pixel is obtained to obtain a distance image, and the value of any pixel in the distance image is the distance value corresponding to the pixel (i.e., the distance value from the pixel to the nearest candidate edge pixel). The distance image can be further binarized according to the second threshold, and pixels with distance values greater than the second threshold are marked as seed pixels. In practical applications, the second threshold can be set accordingly. In some embodiments, obtaining the distance from the non-candidate edge pixel to the nearest candidate edge pixel may be obtaining the Euclidean distance from the non-candidate edge pixel to the nearest candidate edge pixel.
[0048] In some embodiments, a connected domain analysis can be performed on seed pixels to obtain a connected domain formed by the seed pixels. A label can be assigned to any seed, i.e., any independent connected domain formed by the seed pixels, to distinguish different seeds. Different seeds grow into different granular regions, and assigning labels to the seeds facilitates subsequent differentiation of different granular regions.
[0049] In some embodiments, for any pixel of the image to be processed, before selecting the local area corresponding to the pixel in the image to be processed, the following steps are further included: S101: For any pixel of the image to be processed, obtain a spectral similarity weight and a spatial distance weight of the pixel with respect to any pixel in a neighborhood of the pixel, wherein the spectral similarity weight of the pixel is obtained based on a first ratio of the pixel, where the first ratio of the pixel is a ratio of a dot product of the spectral vector of the pixel and the spectral vector of any pixel in the neighborhood of the pixel, and a product of a length of the spectral vector of the pixel and the length of the spectral vector of any pixel in the neighborhood of the pixel; and the spatial distance weight of the pixel is obtained based on a distance between the pixel and any pixel in the neighborhood of the pixel; S102: For any pixel of the image to be processed, perform weighted averaging on the spectral vectors of each pixel in the neighborhood of the pixel using the spectral similarity weight and spatial distance weight corresponding to the pixels in the neighborhood of the pixel, and use the obtained vector as the spectral vector of the pixel.
[0050] In this embodiment, the spectral similarity weight and spatial distance weight of the pixels in the pixel neighborhood of the pixel to be processed are obtained, and the spectral similarity weight and spatial distance weight corresponding to the pixels in the pixel neighborhood are weighted averaged to obtain the spectral vector of the pixel. By fusing the spatial distance weight and spectral similarity weight, the image to be processed is preprocessed to achieve noise suppression and edge preservation.
[0051] In some embodiments, weighted averaging of the spectral vectors of each pixel in the neighborhood of the pixel using the spectral similarity weights and spatial distance weights corresponding to the pixels in the neighborhood of the pixel includes: calculating a first summation result and a second summation result, the first summation result being the sum of the first products of each pixel in the neighborhood of the pixel, the first product being the product of the spectral vectors of the pixels in the neighborhood of the pixel, the spectral similarity weights corresponding to the pixels in the neighborhood of the pixel, and the spatial distance weight; the second summation result being the sum of the second products of each pixel in the neighborhood of the pixel, the second product being the product of the spectral similarity weights and the spatial distance weights corresponding to the pixels in the neighborhood of the pixel; obtaining a ratio of the first summation result to the second summation result, and using the obtained vector as the spectral vector of the pixel.
[0052] For example, for any pixel x in the image to be processed, the spectral similarity weight of its neighboring pixel x' can be defined as: ; (2) Among them, ω r (x,x´) represents the spectral similarity weight of pixel x with respect to its neighboring pixel x´, I(x) represents the spectral vector of pixel x, and I(x´) represents the spectral vector of its neighboring pixel x´. represents the cosine similarity between the spectral vector of pixel x and the spectral vector of its neighboring pixel x´, β represents the spectral similarity adjustment parameter, β>0.
[0053] The spatial distance weight can be defined as: ; (3) Among them, ω s (x,x´) represents the spatial distance weight of pixel x with respect to its neighboring pixel x´, |xx´| represents the distance between pixel x and its neighboring pixel x´, σ s Represents the standard deviation of the spatial domain Gaussian kernel, which can be set to σ s = 1. The spatial distance weight is expressed using the Gaussian kernel function.
[0054] The spectral vector of each pixel in the neighborhood of this pixel is weighted averaged using the spectral similarity weight and spatial distance weight corresponding to the pixels in the neighborhood of this pixel, which can be expressed as: ; (4) Among them, I flee (x) represents the obtained spectral vector of the pixel, and Ω(x) represents the neighborhood of pixel x. The neighborhood of pixel x can be a local area centered on pixel x.
[0055] The distance between the current pixel and any pixel in its neighborhood can be the Euclidean distance between the current pixel and any pixel in its neighborhood. That is, |xx´| can be the Euclidean distance between pixel x and its neighboring pixel x´.
[0056] In the method of this embodiment, the spectral similarity weight ω r The spectral similarity is measured by the cosine distance between the spectral vectors of pixel x and its neighboring pixel x′. The more similar the spectral vectors of pixel x and its neighboring pixel x′ are, the closer ω r Approaches 1. When the spectral difference is large, ω r Approaches 0. Spatial distance weight ω sUsing the Gaussian kernel function, the closer the distance between pixel x and its neighboring pixel x′, the higher the spatial distance weight, and the farther the distance, the lower the spatial distance weight. After weighted averaging the spectral vectors of each pixel in the pixel neighborhood using the spectral similarity weight and the spatial distance weight, it comprehensively reflects the characteristics of assigning high weights to pixels with similar spectra and close spatial distances, and assigning low weights to pixels with large spectral differences or large spatial distances. The method of this embodiment quantifies spectral similarity through cosine distance, assigning low weights to pixels with large spectral differences to avoid edge blurring; applying high weights to pixels with similar spectra, effectively suppressing sensor noise and rock matrix texture interference, and providing a spatial spectral feature basis with a high signal-to-noise ratio for subsequent edge detection.
[0057] In some embodiments, before determining in an edge image whether a pixel is a pixel in a particle area or an edge pixel of the particle area based on the grayscale value of the pixel, the method further includes: performing a first preset operation on the edge image, including: traversing the pixels of the edge image with a first preset structural element, and when the first preset structural element moves to any pixel of the edge image, if there is at least one candidate edge pixel within the coverage range of the first preset structural element, then determining any one pixel as a candidate edge pixel.
[0058] Moving the first preset structuring element to any pixel in the edge image means that the origin of the first preset structuring element coincides with the pixel in the edge image. The origin of the first preset structuring element is the central reference point of the first preset structuring element. In this embodiment, the first preset operation is performed on the edge image to connect adjacent but disconnected candidate edge pixels.
[0059] In some embodiments, traversing the pixels of the edge image with the first preset structuring element includes: moving the structuring element after reflection of the first preset structuring element about its origin to any pixel of the edge image; when the reflected structuring element moves to any pixel of the edge image, if there is at least one candidate edge pixel within the coverage range of the reflected structuring element, then determining the any pixel as a candidate edge pixel.
[0060] Reflecting the first preset structuring element about its origin means performing a mirror transformation on the first preset structuring element with the origin of the first preset structuring element as the center of symmetry, that is, with the origin of the first preset structuring element as the point of symmetry, the first preset structuring element is mirror-flipped in two-dimensional space (that is, a center-symmetric transformation is performed), so that the position of each point in the first preset structuring element is symmetrically mapped relative to the origin, and a new structuring element with a shape symmetrical to the first preset structuring element is obtained. The origin of the first preset structuring element is the geometric center of the first preset structuring element. The edge image is traversed by the structuring element after the first preset structuring element is reflected about its origin, so that the structuring element is aligned and calculated with the edge image with the origin as the reference during the translation process. Performing the first preset operation on the edge image can be considered as performing an expansion operation. For example, it can be expressed as: ; (5) Wherein, E represents the edge image, S1 represents the first preset structure element, ⊕ represents the dilation operator, It indicates that the reflected structural element is translated to the area at pixel z, ∩ indicates the set intersection, represents the empty set. E dilate It represents the image after the first preset operation is performed on the edge image E.
[0061] In some embodiments, before determining in an edge image whether a pixel is a pixel in a particle area or an edge pixel of the particle area based on the grayscale value of the pixel, the method further includes: performing a second preset operation on the edge image that has undergone the first preset operation, including: traversing the pixels of the edge image with a second preset structural element, and when the second preset structural element moves to any pixel of the edge image, if all the pixels within the coverage range of the second preset structural element are candidate edge pixels, then the any pixel is determined as a candidate edge pixel; if there is at least one non-candidate edge pixel within the coverage range of the second preset structural element, then the any pixel is determined as a non-candidate edge pixel.
[0062] In this embodiment, the second preset operation is performed on the edge image to remove isolated noise points. The second preset operation on the edge image can be considered as an erosion operation. For example, it can be expressed as: ; (6) in, represents the corrosion operator, S2 represents the second preset structure element, S2 z represents the area where the second preset structure element is translated to pixel z, Represents a subset relationship. E erode Represents the image E dilate The image after the second preset operation.
[0063] In this embodiment, the closing operation of dilation followed by erosion can further optimize edge continuity, fill internal tiny holes, and smooth the contour. The closing operation of dilation followed by erosion can be defined as: . (7)
[0064] In some embodiments, the first preset structure element S1 and the second preset structure element S2 may be the same structure element, that is, S1=S2=S. Then, performing the first preset operation on the edge image E may be expressed as: ; (8) in, Represents the area where the reflected structural element is translated to pixel z.
[0065] The edge image E after the first preset operation dilate The second preset operation can be expressed as: ; (9) Among them, S z Represents the region where the structural element S is translated to pixel z.
[0066] The closed-loop operation on the edge image E can be expressed as: . (10)
[0067] Exemplarily, the first preset structuring element or the second preset structuring element may be a rectangular kernel or a square kernel, such as a 3×3 or 5×5 rectangular kernel.
[0068] In some embodiments, before determining in an edge image whether a pixel is a pixel in a particle area or an edge pixel of the particle area based on the grayscale value of the pixel, the method further includes: cyclically operating the edge image multiple times, each operation on the edge image including: performing a first preset operation on the edge image, and performing a second preset operation on the edge image after the first preset operation; wherein, performing the first preset operation on the edge image includes: traversing the pixels of the edge image with a first preset structuring element, and when the first preset structuring element moves to any pixel of the edge image, if there is at least one candidate edge pixel within the coverage of the first preset structuring element, then determining the any pixel as a candidate edge pixel; performing the second preset operation on the edge image includes: traversing the pixels of the edge image with a second preset structuring element, and when the second preset structuring element moves to any pixel of the edge image, if all the pixels within the coverage of the second preset structuring element are candidate edge pixels, then determining the any pixel as a candidate edge pixel, and if there is at least one non-candidate edge pixel within the coverage of the second preset structuring element, then determining the any pixel as a non-candidate edge pixel. After the dilation operation on the edge image, the non-candidate edge pixel area will be expanded, bridging the adjacent but broken candidate edge pixels. The subsequent corrosion operation can restore the non-candidate edge pixel area to its original state, but the holes inside the area have been filled. Repeated dilation and corrosion operations are performed multiple times to help form a more accurate continuous and complete closed edge contour. In this embodiment, the image with determined candidate edge pixels is subjected to morphological post-processing to optimize the edge structure, including dilation, corrosion and closing operations. Through the above operations, the broken real edges are effectively connected, isolated noise points are eliminated, and the small holes inside the edge are filled to form a continuous and complete closed edge contour, providing accurate edge constraints for subsequent watershed segmentation, significantly improving the integrity of the particle boundary and the robustness of the segmentation.
[0069] If the hyperspectral image particle segmentation method of this embodiment is applied to a rock slice, the image to be processed is an image obtained from the rock slice and includes its spatial information and spectral information.
[0070] This embodiment further provides a hyperspectral image particle segmentation device, comprising: memory for storing computer programs; A processor is configured to implement the steps of the hyperspectral image particle segmentation method as described in any one of the above embodiments when executing the computer program.
[0071] The hyperspectral image particle segmentation device of this embodiment selects the local area corresponding to a pixel and constructs a preset matrix for the pixel based on the spectral vector of the pixel in the local area. The preset matrix of the pixel reflects the changes in the spatial dimension information and spectral dimension information of the local area corresponding to the pixel. The pixel is judged to be a candidate edge pixel based on the eigenvalue of the preset matrix. This judgment combines the characteristics of the spatial dimension and the spectral dimension. Compared with the existing edge detection method that only uses the spatial gradient information of the image to detect the edge, it can improve the accuracy of detecting edge pixels. It can further segment the particle area based on the candidate edge pixels, thereby improving the accuracy of segmenting the particle area. The hyperspectral image particle segmentation device of this embodiment can improve the accuracy of detecting edge pixels and can improve the accuracy of particle segmentation based on hyperspectral images.
[0072] In one specific example, a polarizing microscope and a hyperspectral camera were used to build an acquisition system with a spectral range of 400-1000nm and a resolution of 2.5nm; data processing was performed on a PC platform. A rock thin section sample containing quartz and feldspar was selected to obtain a 480×480×300 hyperspectral 3D data cube. Figure 2-1 and Figure 2-2 , Figure 2-1 A 3D data cube containing a thin section of quartz rock obtained for a specific example, Figure 2-2 A 3D data cube of a thin section of feldspar-containing quartz rock obtained for a specific example. Also see Figure 3-1 and Figure 3-2 , Figure 3-1 Three single-band images of a quartz rock thin section obtained for a specific example, which are 50-band, 150-band, and 250-band images respectively. Figure 3-2 Three single-band images of a thin section of feldspar-containing quartz rock obtained for a specific example, namely the 50-band, 150-band, and 250-band images.
[0073] A 3×3 local window was used and the weighting of spatial distance and spectral similarity (β=1.0, σ s = 1.0), iterated 3 times to preprocess the data to suppress noise and preserve edges. Structural tensor analysis was performed based on a 3×3 local window to calculate the coherence value c, and candidate edge pixels were marked by threshold screening. A 5×5 circular kernel was used to perform dilation, erosion, and closing operations to optimize edge continuity and fill holes. Figure 4-1 and Figure 4-2 , Figure 4-1 An image of a quartz rock slice obtained for a specific example, where candidate edge pixels are screened out. Figure 4-2 An image of a thin section of feldspar-containing quartz rock obtained for a specific example, in which candidate edge pixels are screened out.
[0074] By marking the internal seed pixels through distance transformation, the region growing and segmentation are completed with the morphologically optimized edges as constraints. Figure 5-1 and Figure 5-2 , Figure 5-1 This is a grain segmented image of a quartzite rock slice obtained for a specific example. Figure 5-2 A grain-segmented image of a thin section of feldspar-bearing quartz rock obtained for a specific example.
[0075] The hyperspectral image particle segmentation method of this embodiment is based on the spatial-spectral joint feature edge detection method of the structure tensor. By calculating the coherence value of the local window and fusing the spectral gradient and spatial gradient information of the hyperspectral image, it solves the problem of misjudgment of the boundaries of spectrally similar minerals, realizes high-precision edge positioning under complex backgrounds, and realizes continuous and complete mineral edge extraction under complex backgrounds. The hyperspectral image segmentation device adapted for rock thin section data acquisition integrates a microscopic hyperspectral imaging system with an edge-guided watershed segmentation algorithm, supports real-time processing and integrated segmentation of multi-scale mineral particle images, and breaks through the adaptability limitations of traditional methods to high-noise and fuzzy boundary scenes. The hyperspectral image segmentation device adapted for rock thin section data acquisition supports real-time processing of collected multi-scale mineral particle images, realizing integrated and efficient processing from data acquisition to complete particle segmentation.
[0076] The hyperspectral image particle segmentation method and apparatus provided by the present invention have been described in detail above. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above examples is intended only to facilitate understanding of the method and core concepts of the present invention. It should be noted that those skilled in the art will be able to make various improvements and modifications to the present invention without departing from the principles of the present invention, and such improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A hyperspectral image particle segmentation method, characterized in that: include: Acquire an image to be processed, wherein any pixel of the image to be processed includes data of multiple spectral bands; For any pixel of the image to be processed, a local area corresponding to the pixel is selected in the image to be processed, where the local area corresponding to the pixel is a local area including the pixel, and a plurality of spectral vectors corresponding to the pixel are obtained, where the plurality of spectral vectors corresponding to the pixel are spectral vectors of pixels included in the local area corresponding to the pixel, where the spectral vector of the pixel is formed by data of the plurality of spectral bands of the pixel; For any pixel of the image to be processed, obtaining a preset matrix for the pixel, where the preset matrix for the pixel is formed by the covariance of any two spectral vectors among a plurality of spectral vectors corresponding to the pixel, and obtaining a plurality of eigenvalues of the preset matrix for the pixel, and determining the pixel as a candidate edge pixel if a difference in magnitudes of the plurality of eigenvalues of the pixel meets a first preset requirement; The image to be processed is binarized according to whether any pixel of the image to be processed is the candidate edge pixel to obtain an edge image. In the edge image, the pixel is determined to be a pixel in the particle area or an edge pixel of the particle area according to the gray value of the pixel, and the particle area is segmented.
2. The hyperspectral image particle segmentation method according to claim 1, characterized in that: Selecting the local area corresponding to the pixel in the image to be processed includes: In the image to be processed, a local area centered on the pixel is selected as the local area corresponding to the pixel.
3. The hyperspectral image particle segmentation method according to claim 1, characterized in that: The preset matrix for obtaining this pixel includes: Obtaining a data matrix of the pixel, where the data matrix of the pixel is formed by a plurality of spectral vectors corresponding to the pixel; The transposed matrix of the data matrix of the pixel is multiplied by the data matrix of the pixel to obtain the preset matrix of the pixel.
4. The hyperspectral image particle segmentation method according to claim 1, characterized in that: The coherence value of the pixel is used to represent the size difference of the multiple eigenvalues of the pixel, and the coherence value of the pixel is the ratio of the absolute value of the maximum eigenvalue among the multiple eigenvalues of the pixel to the sum of the absolute values of the multiple eigenvalues; The difference in the sizes of the multiple characteristic values of the pixel meeting the first preset requirement includes: the coherence value of the pixel being greater than a first threshold.
5. The hyperspectral image particle segmentation method according to claim 1, characterized in that: Determining in the edge image that a pixel is a pixel in a particle region or an edge pixel of the particle region according to a grayscale value of the pixel, and segmenting the particle region includes: In the edge image, seeds are selected from pixels other than the candidate edge pixels and a target area is grown using the seeds. In the target area grown using the seeds, for adjacent pixels of the target area, the adjacent pixels are classified as pixels within the target area or as edge pixels of the target area according to the grayscale values of the adjacent pixels, and the target area obtained by growth is determined as the particle area.
6. The hyperspectral image particle segmentation method according to claim 5, characterized in that: In the edge image, selecting seeds from pixels other than the candidate edge pixels includes: in the edge image, for any non-candidate edge pixel, obtaining the distance from the non-candidate edge pixel to the nearest candidate edge pixel, selecting the non-candidate edge pixel whose distance meets a second preset requirement as a seed pixel, and obtaining a connected domain formed by the seed pixels as the seed.
7. The hyperspectral image particle segmentation method according to any one of claims 1 to 6, characterized in that: For any pixel of the image to be processed, before selecting the local area corresponding to the pixel in the image to be processed, the method further includes: For any pixel of the image to be processed, obtaining a spectral similarity weight and a spatial distance weight of the pixel with respect to any pixel in a neighborhood of the pixel, wherein the spectral similarity weight of the pixel is obtained based on a first ratio of the pixel, where the first ratio of the pixel is a ratio of a dot product of the spectral vector of the pixel and the spectral vector of any pixel in the neighborhood of the pixel, and a product of a length of the spectral vector of the pixel and the length of the spectral vector of any pixel in the neighborhood of the pixel, and the spatial distance weight of the pixel is obtained based on a distance between the pixel and any pixel in the neighborhood of the pixel; For any pixel of the image to be processed, the spectral vectors of each pixel in the neighborhood of the pixel are weighted averaged using the spectral similarity weight and spatial distance weight corresponding to the pixels in the neighborhood of the pixel, and the obtained vector is used as the spectral vector of the pixel.
8. The hyperspectral image particle segmentation method according to claim 7, characterized in that: Performing weighted averaging on the spectral vectors of each pixel in the neighborhood of the pixel using the spectral similarity weights and spatial distance weights corresponding to the pixels in the neighborhood of the pixel includes: Calculating a first summation result and a second summation result, where the first summation result is the sum of first products of each pixel in the neighborhood of the pixel, where the first product is the product of the spectral vector of the pixel in the neighborhood of the pixel, the spectral similarity weight corresponding to the pixel in the neighborhood of the pixel, and the spatial distance weight; and the second summation result is the sum of second products of each pixel in the neighborhood of the pixel, where the second product is the product of the spectral similarity weight corresponding to the pixel in the neighborhood of the pixel and the spatial distance weight; The ratio of the first summation result to the second summation result is obtained, and the obtained vector is used as the spectral vector of the pixel.
9. The hyperspectral image particle segmentation method according to any one of claims 1 to 6, characterized in that: Before determining in the edge image according to the grayscale value of the pixel that the pixel is a pixel in the particle area or an edge pixel of the particle area, the method further includes: Performing a first preset operation on the edge image, including: traversing pixels of the edge image with a first preset structuring element, and when the first preset structuring element moves to any pixel of the edge image, if there is at least one candidate edge pixel within a coverage range of the first preset structuring element, determining the any pixel as a candidate edge pixel; Performing a second preset operation on the edge image that has undergone the first preset operation includes: traversing pixels of the edge image with a second preset structuring element, and when the second preset structuring element moves to any pixel of the edge image, if all pixels within a coverage range of the second preset structuring element are candidate edge pixels, then determining the any pixel as a candidate edge pixel; if there is at least one non-candidate edge pixel within the coverage range of the second preset structuring element, then determining the any pixel as a non-candidate edge pixel.
10. A hyperspectral image particle segmentation device, characterized in that: include: memory for storing computer programs; A processor is configured to implement the steps of the hyperspectral image particle segmentation method according to any one of claims 1 to 9 when executing the computer program.
Citation Information
Patent Citations
Material grain structure segmentation method based on edge information
CN109961451A
Engineering rock group remote sensing classification method and system based on space and spectrum combined characteristics
CN116758361A
Non-parametric iteration hyperspectral image target detection method and system, and storage medium
CN118608756A
Hyperspectral image classification method and system
CN119418114A
Material classification fused with spatio-spectral edge detection in spectral imagery
US9430842B1
Cited By
Porosity characteristics of thermal spray coatings technical field
US20250347608A1