Method for enhancing infrared microscopic images of Chinese medicinal materials
Through the method of two-dimensional Fourier transform and full-pixel end-member contribution weight set, the problem of weak contrast caused by spectral overlap in infrared microscopy imaging of Chinese medicinal materials was solved, and high-fidelity and high-robustness enhancement of Chinese medicinal materials microscopy images was achieved, improving the accuracy of component separation and positioning.
Patent Information
- Application Number
- CN202510892751.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-06-30
AI Technical Summary
The existing technology has a weak contrast problem in infrared microscopy of traditional Chinese medicines due to spectral overlap and nonlinear aliasing, which makes it difficult to effectively enhance the visualization of the microscopic distribution of specific chemical components. In addition, the dynamic range adjustment method is insufficient, resulting in component signal drowning or regional oversaturation.
Frequency domain peaks are identified through two-dimensional Fourier transform, and a de-streaked hyperspectral data cube is generated. A full-pixel endmember contribution weight set is constructed, and pixel values are adaptively adjusted based on statistical histograms. Image fusion is performed in combination with chemical composition-color coding to generate component-specific enhanced images.
It improves the component separation and positioning accuracy of microscopic images of traditional Chinese medicine, enhances the visualization sensitivity of weak components, solves the artifact problem caused by spectral aliasing, and provides high-fidelity and high-robustness image enhancement support.
Smart Images

Figure CN120430953B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image enhancement, in particular to a method for enhancing infrared microscopic images of traditional Chinese medicines. Background Art
[0002] The infrared microscopic image enhancement method of traditional Chinese medicine addresses the weak contrast problem caused by complex components and spectral overlap in microscopic imaging of traditional Chinese medicine. By fusing infrared spectra with spatial features, the visualization effect of the microscopic distribution of specific chemical components (such as saponins and polysaccharides) is enhanced.
[0003] Existing technologies, based on linear mixed models or fixed-endmember spectral libraries, lack adaptability to spectral variation and nonlinear aliasing. Mismatches in the number of endmembers or spectral characteristics can easily lead to biased weight calculations, resulting in spatial ambiguity or component misclassification in the generated abundance maps. Furthermore, existing dynamic range adjustment methods often employ global histogram equalization or fixed threshold stretching, making it difficult to adaptively optimize mapping parameters based on the local statistical properties of the target component. This can result in low-abundance component signals being overwhelmed by background noise or oversaturation in high-abundance regions. Therefore, improvements are needed. Summary of the Invention
[0004] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a method for enhancing infrared microscopic images of traditional Chinese medicines.
[0005] In order to achieve the above object, the present invention adopts the following technical solution, a method for enhancing infrared microscopic images of Chinese medicinal materials, comprising the following steps:
[0006] Based on the input original infrared spectral microscopic image data of traditional Chinese medicine, a two-dimensional Fourier transform is performed on each spectral band image to obtain a frequency domain representation. The target frequency peak position generated by interference in the frequency domain representation is identified to generate a de-streaked hyperspectral data cube.
[0007] Based on the de-streaked hyperspectral data cube, the spectral vector of each pixel in the cube is decomposed to establish a full-pixel endmember contribution weight set; based on the full-pixel endmember contribution weight set, the contribution weight values of all pixels corresponding to the same index are extracted and organized into a two-dimensional matrix according to the index of the endmember spectral vector to obtain an original abundance atlas;
[0008] Based on the original abundance atlas, one or more abundance maps corresponding to the target Chinese medicinal material chemical components are selected, a statistical histogram of the pixel values of the selected abundance maps is calculated, a target abundance map calibration parameter set is established, and based on the target abundance map calibration parameter set, each pixel value in the selected abundance map is mapped and adjusted according to the set transformation function parameters to expand the dynamic range of the pixel value, thereby obtaining an enhanced abundance map of the target component;
[0009] Grayscale intensity mapping rules are set according to the pixel value range of the target component enhanced abundance map. At the same time, abundance layers representing different components are selected from the original abundance map set to obtain multiple layers of data channels to be fused. Based on the multiple layers of data channels to be fused, color synthesis is performed pixel by pixel to establish a component-specific enhanced microscopic image of Chinese medicinal materials.
[0010] Preferably, the steps of obtaining the de-streaked hyperspectral data cube are:
[0011] Based on the input original infrared spectrum microscopic image data of traditional Chinese medicine, a two-dimensional Fourier transform is performed on each spectral band image to convert the spatial domain pixel matrix into a frequency domain matrix containing complex frequency coefficients to generate a frequency domain representation;
[0012] Based on the frequency domain representation, the amplitude spectrum matrix of the frequency domain representation is scanned, and positions with amplitude values greater than three times the standard deviation of the mean amplitude values of adjacent frequency points are located as candidate peaks. A density clustering algorithm is used to eliminate pseudo peaks with discrete spatial distribution, and a set of peaks with continuous distribution and density exceeding a preset threshold is screened to identify the target frequency peak position. The geometric center coordinates are calculated as the center frequency of the band-stop filter based on the peak position coordinates. The bandwidth is calculated based on the frequency range covered by the peak area. The attenuation depth is set according to the ratio of the peak amplitude to the background noise amplitude to generate the band-stop filter parameters.
[0013] Based on the band-stop filter parameters, a circular stopband region with the center frequency as the center and the bandwidth as the radius is constructed in the frequency domain representation. The amplitudes of the complex frequency coefficients within the stopband are multiplied by the attenuation depth coefficient, and the original amplitudes of the coefficients outside the stopband are retained. An inverse two-dimensional Fourier transform is performed on the modified frequency domain matrix, and the complex matrix is converted into a real pixel matrix to generate a de-streaked hyperspectral data cube.
[0014] Preferably, the steps of obtaining the full-pixel endmember contribution weight set are:
[0015] Based on the de-streaked hyperspectral data cube, extracting the spectral vector of each pixel point in the cube, performing an initialized orthogonal projection operation on each spectral vector, calculating the projection vector of the spectral vector in the direction of the endmember spectral vector, and generating an initial projection vector;
[0016] Calculating a contribution weight value based on the initial projection vector;
[0017] Based on the contribution weight values, all combinations of pixel points and endmember spectral vectors are traversed, and a mapping relationship is constructed between the contribution weight values according to pixel indices and endmember indices to generate a full-pixel endmember contribution weight set.
[0018] Preferably, the steps of obtaining the original abundance atlas are:
[0019] Based on the full-pixel endmember contribution weight set, traverse the three-dimensional coordinates of each pixel in the data cube, extract the contribution weight value of each pixel under each endmember index, create an independent storage queue according to the index number of the endmember spectral vector, store the weight values of all pixels under the same index into a hash table as key-value pairs, and generate an endmember index weight mapping table;
[0020] Based on the endmember index weight mapping table, the number of image rows H and columns W of the striped hyperspectral data cube is read, and an H×W blank floating-point matrix is created. All key-value pairs under a certain endmember index in the hash table are traversed, and the contribution weight values of the corresponding pixels are filled into the corresponding row and column positions of the blank matrix. The unfilled positions are assigned 0 to generate a two-dimensional endmember weight matrix.
[0021] Based on the two-dimensional endmember weight matrix, the global maximum and minimum values of all non-zero elements in the matrix are calculated, each matrix element value is mapped to the range of 0-255, and the mapped matrix is converted into an 8-bit grayscale image to generate the original abundance atlas.
[0022] Preferably, the steps for obtaining the target abundance map calibration parameter set are:
[0023] Based on the original abundance atlas, the grayscale value of each pixel in the image is read, the grayscale value range of 0-255 is divided into 256 equal-width intervals, the number of pixels in each interval is counted, and the frequency array is recorded in the order of the intervals to generate a target abundance map pixel value statistical histogram;
[0024] Based on the pixel value statistical histogram of the target abundance map, the grayscale value with a cumulative probability of 5% in the frequency array is calculated as the lower threshold, and the grayscale value with a cumulative probability of 95% is used as the upper threshold. The S-shaped curve function is selected as the transformation function for pixel value remapping, the grayscale value of the midpoint of the curve is set to the mean of the upper and lower thresholds, and the curve steepness coefficient is set to one-third of the difference between the upper and lower limits, to generate a target abundance map calibration parameter set.
[0025] Preferably, the steps for obtaining the target component enhanced abundance map are:
[0026] Based on the target abundance map calibration parameter set, parsing the lower threshold, upper threshold, S-curve midpoint and steepness coefficient stored in the calibration parameter set, loading the parameters into memory variables, and generating mapping adjustment parameters;
[0027] calculating an enhanced pixel value for each pixel value in the target abundance map based on the mapping adjustment parameter;
[0028] Based on the enhanced pixel value, all pixel coordinates of the abundance map are traversed, and the enhanced pixel values are filled into the new image matrix according to the coordinates. The matrix is converted into an 8-bit grayscale image and stored according to the target component name to generate the target component enhanced abundance map.
[0029] Preferably, the steps of obtaining the multiple layers of data channels to be fused are:
[0030] Based on the target component enhancement abundance map, the grayscale values of all pixels in the image are traversed, the 5% quantile and the 95% quantile of the pixel value distribution are counted, the 5% quantile is set as the benchmark lower limit value of the grayscale intensity mapping, and the 95% quantile is set as the benchmark upper limit value, and a grayscale intensity mapping rule is generated;
[0031] Based on the original abundance atlas, according to the preset name list of the chemical components of traditional Chinese medicine, the atlas index directory is traversed, and the abundance map files that are completely consistent with the names of the components in the list are screened by full word matching to generate a candidate abundance map set;
[0032] Based on the grayscale intensity mapping rule, pixel value remapping is performed on each layer in the candidate abundance map set, and the pixel values of each layer are linearly stretched according to the benchmark lower limit value and upper limit value to generate multiple layers of data channels to be fused.
[0033] Preferably, the steps for acquiring the component-specific enhanced microscopic image of Chinese medicinal materials are:
[0034] Based on the multi-layer data channels to be fused, the chemical component name of the Chinese medicinal material corresponding to each data channel is parsed, and a channel color coding vector set is generated according to a preset chemical component-color mapping table;
[0035] Calculate the RGB pixel value vector of each pixel based on the channel color coding vector set;
[0036] Based on the RGB pixel value vector, all pixel coordinates are traversed, and the RGB pixel value vector is filled into a three-dimensional tensor by rows and columns. The tensor is converted into a 24-bit true color image and embedded with chemical component label metadata to generate a component-specific enhanced Chinese medicinal material microscopic image.
[0037] Compared with the prior art, the advantages and positive effects of the present invention are:
[0038] This method uses a two-dimensional Fourier transform to perform frequency domain analysis on raw infrared spectral microscopy images, identifying and eliminating fringe noise generated by optical path interference. This method generates a de-fringe hyperspectral data cube, improving the input data quality for subsequent component separation. The de-fringe spectral vector is then nonlinearly decomposed to construct a full-pixel endmember contribution weight set. The weight values are then organized into a two-dimensional matrix of raw abundance atlases using endmember spectral indices, achieving spatial decoupling and independent expression of the distribution of multiple chemical components. Pixel value mapping parameters are adaptively set based on the statistical histogram of the target component abundance map, and a nonlinear function is employed to expand the dynamic range, overcoming the contrast limitations of traditional linear stretching and enhancing the visual sensitivity of faint components. Multi-component abundance maps are uniformly standardized according to grayscale intensity mapping rules. Pixel-by-pixel color synthesis is performed in conjunction with chemical component-color coding vectors to generate component-specific enhanced images that fuse multi-channel information, addressing artifacts caused by spectral aliasing in traditional methods. This method improves the localization accuracy and visual distinction of target components while preserving the original spectral characteristics, providing high-fidelity and robust image enhancement support for microscopic analysis of complex Chinese medicinal materials. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 Schematic diagram of the steps of the present invention. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0041] See also Figure 1 The present invention provides a technical solution, a method for enhancing infrared microscopic images of Chinese medicinal materials, comprising the following steps:
[0042] Based on the input original infrared spectral microscopic image data of traditional Chinese medicine, a two-dimensional Fourier transform is performed on each spectral band image to obtain a frequency domain representation. The target frequency peak position generated by interference in the frequency domain representation is identified to generate a de-streaked hyperspectral data cube.
[0043] Based on the de-streaked hyperspectral data cube, the spectral vector of each pixel in the cube is decomposed to establish a full-pixel endmember contribution weight set. Based on the full-pixel endmember contribution weight set, the contribution weight values of all pixels corresponding to the same index are extracted and organized into a two-dimensional matrix according to the index of the endmember spectral vector to obtain the original abundance atlas.
[0044] Based on the original abundance atlas, one or more abundance maps corresponding to the target Chinese medicinal material chemical components are selected, a statistical histogram of the pixel values of the selected abundance maps is calculated, a target abundance map calibration parameter set is established, and based on the target abundance map calibration parameter set, each pixel value in the selected abundance map is mapped and adjusted according to the set transformation function parameters to expand the dynamic range of the pixel value and obtain an enhanced abundance map of the target component;
[0045] The grayscale intensity mapping rules are set according to the pixel value range of the target component enhanced abundance map. At the same time, abundance layers representing different components are selected from the original abundance map set to obtain multiple layers of data channels to be fused. Based on the multiple layers of data channels to be fused, color synthesis is performed pixel by pixel to establish component-specific enhanced microscopic images of Chinese medicinal materials.
[0046] The steps to obtain the de-streaked hyperspectral data cube are:
[0047] Based on the input original infrared spectrum microscopic image data of traditional Chinese medicine, a two-dimensional Fourier transform is performed on each spectral band image to convert the spatial domain pixel matrix into a frequency domain matrix containing complex frequency coefficients to generate a frequency domain representation;
[0048] Based on the frequency domain representation, the amplitude spectrum matrix represented in the frequency domain is scanned, and the positions with amplitude values greater than three times the standard deviation of the mean amplitude values of adjacent frequency points are located as candidate peaks. The density clustering algorithm is used to eliminate pseudo peaks with discrete spatial distribution, and the peak set with continuous distribution and density exceeding the preset threshold is screened. The target frequency peak position is identified, and the geometric center coordinates are calculated as the center frequency of the band-stop filter based on the peak position coordinates. The bandwidth is calculated based on the frequency range covered by the peak area, and the attenuation depth is set according to the ratio of the peak amplitude to the background noise amplitude to generate the band-stop filter parameters.
[0049] Based on the band-stop filter parameters, a circular stopband region with the center frequency as the center and the bandwidth as the radius is constructed in the frequency domain representation. The amplitude of the complex frequency coefficient within the stopband is multiplied by the attenuation depth coefficient, and the original amplitude of the coefficient outside the stopband is retained. An inverse two-dimensional Fourier transform is performed on the modified frequency domain matrix to convert the complex matrix into a real pixel matrix to generate a de-streaked hyperspectral data cube.
[0050] Specifically, based on the input original infrared spectrum microscopic image data of traditional Chinese medicine, the fast Fourier transform (FFT) algorithm is first applied independently to the two-dimensional image data corresponding to each spectral band. This process converts the spatial domain intensity value of each pixel point into a complex coefficient in the frequency domain. These complex coefficients contain the amplitude and phase information of the spatial frequency component. Specifically, for a certain pixel size (e.g. ) band image, its two-dimensional discrete Fourier transform produces a frequency domain matrix of the same size, in which each element is a complex number. By repeating this two-dimensional Fourier transform operation on all spectral band images, the entire hyperspectral data cube is converted from the spatial domain to the frequency domain, and a frequency domain representation consisting of the frequency domain matrices of each band is obtained.
[0051] Based on the frequency domain representation, the amplitude spectrum of the frequency domain matrix of each band is calculated, that is, the amplitude of each complex frequency coefficient is calculated (the value is equal to the square root of the sum of the square of the real part and the square of the imaginary part of the complex number), and the amplitude spectrum matrix is obtained. Then, each frequency point in the amplitude spectrum matrix is traversed, and the eight adjacent frequency points around it are examined. The arithmetic mean and standard deviation of the amplitudes of the eight adjacent points are calculated. If the amplitude of the current frequency point is greater than the sum of the average amplitude of its eight adjacent points plus three times the standard deviation of the amplitude of the adjacent points, the frequency point is marked as a candidate peak position. Subsequently, the position coordinate set of all candidate peaks is taken as input, and the density-based The spatial clustering algorithm of degree (such as DBSCAN) requires setting two key parameters: the neighborhood radius and the minimum number of neighborhood points required for the core object. The setting of these two parameters is based on experience or a priori analysis of the stripe characteristics of the sample data. For example, the neighborhood radius can be set to 3 frequency units and the minimum number of neighborhood points can be set to 5 based on experience. The clustering algorithm clusters candidate peaks that are close to each other in space (the distance is less than or equal to the set neighborhood radius) and have a sufficient number (the number of points in the neighborhood is greater than or equal to the set minimum number of neighborhood points), and identifies discrete candidate peaks that do not belong to any cluster as pseudo peaks and eliminates them, thus screening out peaks representing interference. The density of each filtered peak cluster is further calculated, for example, the number of peak points in the cluster is divided by the minimum circumscribed rectangular area occupied by the cluster in the frequency domain, and a density threshold is set. The threshold can be determined based on the comparative analysis of the normal image spectrum and the spectrum of the image containing stripes. For example, by analyzing multiple groups of samples, if it is found that the density of the peak cluster caused by stripes is generally higher than 10 points per square frequency unit, this value can be set as the density threshold. If the density of a peak cluster is lower than the preset density threshold, it will also be eliminated. The peak cluster that is finally retained is identified as the target frequency peak set. For each identified target frequency peak set (representing an interference fringe), calculate the geometric center of all the frequency point coordinates it contains (that is, the average value of the horizontal coordinate and the average value of the vertical coordinate of each point), and use this geometric center coordinate as the center frequency of the band-stop filter corresponding to the fringe. Calculate the maximum distance from all points in the peak set to the calculated center frequency (the distance calculation method is the square root of the sum of the squares of the difference between the coordinates of the two points), and use this maximum distance value (a small safety margin can be added, such as adding 1-2 frequency units) as the bandwidth of the filter. Finally, calculate the average amplitude value of the frequency points in the peak set , and select a background area away from all peaks in the amplitude spectrum (for example, an area at least twice the bandwidth away from the center of all peaks), and calculate the average amplitude value of the frequency points in the background area , based on the ratio of peak amplitude to background noise amplitude (Right now Divide by ) to set the filter's attenuation depth coefficient For example, you can Set it to the inverse of the ratio, or set it to 1.5 times the inverse value to avoid over-suppression. Specific calculation example: If the calculated peak average amplitude is 500, the background average amplitude is 10, then the ratio , you can set the attenuation depth coefficient or , the center frequency, bandwidth and attenuation depth coefficients corresponding to each target frequency peak calculated are summarized to generate the band-stop filter parameters.
[0052] Based on the band-stop filter parameters obtained in the previous steps and the frequency domain representation of each band (complex frequency coefficient matrix), for each identified target frequency peak and its corresponding center frequency, bandwidth and attenuation depth coefficient, a circular stopband area with the center frequency as the center and the corresponding bandwidth as the radius is defined in the frequency domain representation. In the specific operation, each frequency point in the frequency domain matrix is traversed, and the distance from its frequency coordinate to the center frequency of each filter is calculated (the calculation method is the square root of the sum of the squares of the difference between the coordinates of the two points). If the point falls into any defined circular stopband area (that is, its distance to a filter center frequency is less than or equal to the bandwidth of the filter), the complex coefficient of the frequency point is adjusted, and its amplitude is multiplied by the corresponding attenuation depth coefficient, while keeping its phase angle unchanged, so as to obtain a new complex frequency point. Frequency coefficient, if a frequency point does not fall into any defined stopband area, its complex frequency coefficient remains unchanged. After performing this filtering operation on the frequency domain matrices of all spectral bands in the frequency domain representation, a set of modified frequency domain matrices is obtained. Then, an inverse two-dimensional fast Fourier transform (I2DFFT) algorithm is performed on each modified band frequency domain matrix. This transform converts the frequency domain complex matrix back to a spatial domain matrix. Since the original image is real-valued and the applied filtering operation has been designed to ensure that the output result is real (or the imaginary part is extremely small and can be ignored), the real part of the inverse transform result is directly taken to obtain the spatial domain pixel matrix after de-striping of the band. The real pixel matrices obtained after processing all spectral bands are restacked and combined in the original spectral order to finally generate a de-striped hyperspectral data cube.
[0053] The steps to obtain the full pixel endmember contribution weight set are:
[0054] Based on the de-streaked hyperspectral data cube, the spectral vector of each pixel in the cube is extracted, and an initial orthogonal projection operation is performed on each spectral vector to calculate the projection vector of the spectral vector in the direction of the endmember spectral vector to generate an initial projection vector.
[0055] Based on the initial projection vector, the contribution weight value is calculated using the following formula:
[0056] ;
[0057] in, is the contribution weight of the i-th pixel to the k-th endmember spectrum vector, is the residual vector between the i-th normalized spectrum vector and the initial projection vector, is the kth endmember spectrum vector, is the j-th endmember spectrum vector, is the total number of end members, represents the L2 norm of the vector, is the dot product of the residual vector and the end member vector;
[0058] Based on the contribution weight value, all combinations of pixel points and endmember spectral vectors are traversed, and the contribution weight value is mapped to the pixel index and the endmember index to generate a full-pixel endmember contribution weight set.
[0059] Specifically, based on the de-streaked hyperspectral data cube, we first need to determine the spectral features representing the pure chemical components in the sample, namely the endmember spectral vectors. These endmember spectral vectors can be extracted from the data cube itself using an endmember extraction algorithm (such as the vertex component analysis (VCA) algorithm). The VCA algorithm is used to analyze the spectral distribution of all pixels in the de-streaked hyperspectral data cube, identify the spectral vectors that can form the vertices of the simplex that encloses all data points, and use these vertex spectral vectors as endmember spectral vectors. , and determine the total number of end members (For example, the intrinsic dimension of the data is estimated by the HySime method ), then traverse each pixel in the de-streaked hyperspectral data cube , extract its corresponding spectral vector (i.e. the response value sequence of the pixel in all spectral bands), next, for each pixel's spectral vector , perform the initialization orthogonal projection operation, specifically calculate the spectral vector In all endmember spectral vector The orthogonal projection on the spanned spectral subspace represents the part of the pixel spectrum that can be explained by the linear combination of this set of pure chemical components. This calculation can be completed by the least squares method, that is, solving a coefficient vector Make and The L2 norm of the difference vector (residual) is the smallest, where Therefore Is a matrix of column vectors, the resulting projection vector is , repeat this process for all pixels in the cube to generate the initial projection vector for each pixel.
[0060] formula: The usefulness of the formula is that it calculates the pixel by combining the angular similarity between the residual vector and the end-member vector (reflected in the parameters of the exponential function, that is, the result of the normalized dot product between the two is close to the cosine value of the angle between the two) and the size of the projection component of the residual vector in the direction of the end-member vector (reflected in multiplying by the absolute value of the dot product). The residual part of the end element The exponential function amplifies the influence of angular similarity, so that the endmembers with more consistent directions with the residual vectors obtain higher basic weights. Multiplying by the absolute value of the dot product further emphasizes the size of the endmember component actually contained in the residual.
[0061] The steps for obtaining the total number of end members are as follows: the de-streaked hyperspectral data cube is analyzed using the hyperspectral signal recognition algorithm (HySime). The algorithm estimates the number of independent signal sources in the data, i.e., the number of end members, by evaluating the signal subspace and the noise subspace. For example, the HySime algorithm is applied to a data cube of infrared microscopic images of Chinese herbal medicines containing hundreds of bands and millions of pixels, and the noise estimation threshold is set (e.g., based on the signal-to-noise ratio analysis, it is set to ), the algorithm output results show that there are 4 significant independent signal sources in the data, so the total number of end members is determined ;
[0062] and The steps for obtaining (the kth and jth endmember spectral vectors) are: after determining the total number of endmembers Finally, the vertex component analysis (VCA) algorithm is used to process the de-streaked hyperspectral data cube. The VCA algorithm iteratively projects the data points to random directions to find the vertices of the simplex formed by the data scatter points. These vertices are considered to be end-member spectra. After the algorithm is executed, four end-member spectrum vectors are obtained. , each vector contains the response values corresponding to all spectral bands. For example, in a simplified representation (only 4 bands are shown), the 4 endmember vectors obtained are: ,
[0063] , ,
[0064] ;
[0065] The steps to obtain (the residual vector of the i-th pixel) are: first, you need to obtain the spectral vector of the i-th pixel and its end members The initial projection vector on the spanned subspace , the residual vector It is defined as the difference between the original pixel spectrum vector and its projection vector, that is, , which represents the part of the pixel spectrum that cannot be explained by the linear combination of endmembers, e.g., for pixel , whose spectral vector is , which is calculated in the previous step (Taking the simplified example vector above as an example) the initial projection vector on the Zhang Cheng subspace is , then the residual vector of the pixel is
[0066] ;
[0067] The steps to obtain (the dot product of the residual vector and the end member vector) are: calculate the sum of the products of the corresponding components of the two vectors;
[0068] Substitute the parameters into the formula to calculate , , , the result shows that: for the selected example pixels , whose residual spectrum vector is the same as the first end member Shows the strongest correlation, contribution weight It is about 0.5966, which is higher than other end members. This shows that nearly 60% of the features of the pixel spectrum that cannot be explained by the initial projection (main component) can be attributed to the first pure chemical component ( representative), while the correlations with the other three components were relatively weak (approximately 18.4%, 15.6%, and 6.4%, respectively).
[0069] Based on the calculated For each end member Contribution weight value , these weight values need to be organized effectively in order to generate and analyze the abundance map later. The specific operation is to traverse all the pixels in the de-striated hyperspectral data cube, and the total number is set to , while traversing all The index of the endmember spectrum vector (from 1 to ), for each pixel (corresponding to the spatial coordinates in the image ) and each endmember index , a specific contribution weight value has been calculated in the previous step , in order to construct the full pixel endmember contribution weight set, a data structure can be created, such as using Two-dimensional arrays, each of which has the same dimension as the spatial dimension of the original microscopic image (number of rows H × number of columns W). A two-dimensional array is used to store all pixel pairs The contribution weight of the end members, that is, for pixel Its spatial coordinates are , the weight value calculated Deposit A two-dimensional array Position, process all pixels in sequence (from arrive ) and all end members (from arrive ) combination, and finally get A complete two-dimensional weight matrix, The matrices together constitute the full-pixel endmember contribution weight set.
[0070] The steps to obtain the original abundance atlas are:
[0071] Based on the full-pixel endmember contribution weight set, the three-dimensional coordinates of each pixel in the data cube are traversed to extract the contribution weight value of each pixel under each endmember index. An independent storage queue is created according to the index number of the endmember spectral vector. The weight values of all pixels under the same index are stored in a hash table as key-value pairs to generate an endmember index weight mapping table.
[0072] Based on the endmember index weight mapping table, the number of image rows H and columns W of the striped hyperspectral data cube is read, and an H×W blank floating-point matrix is created. All key-value pairs under a certain endmember index in the hash table are traversed, and the contribution weight values of the corresponding pixels are filled into the corresponding row and column positions of the blank matrix. The unfilled positions are assigned 0 to generate a two-dimensional endmember weight matrix.
[0073] Based on the two-dimensional endmember weight matrix, the global maximum and minimum values of all non-zero elements in the matrix are calculated, each matrix element value is mapped to the range of 0-255, and the mapped matrix is converted into an 8-bit grayscale image to generate the original abundance atlas.
[0074] Specifically, based on the full pixel end member contribution weight set (the weight set contains each pixel For each end member Contribution weight value ), its data structure needs to be converted so that the weight information can be organized by end-member index. First, a traversal process is started to visit each pixel point in the spatial dimension of the de-striated hyperspectral data cube in turn to obtain its two-dimensional spatial coordinates (or equivalent 1-D indexing ), for the currently visited pixel , extract the corresponding end-member contribution weight from the full pixel end-member contribution weight set weight values (i.e. ), then, according to the index number of the end member spectrum vector (from 1 to ), create or prepare An independent hash table (or dictionary) structure, each hash table is used to store the weight values of all pixels corresponding to a specific end element index. When The contribution weight of each end member Extract it and store this weight value in the A hash table where the key is set to the spatial coordinate of the pixel (or its one-dimensional index ), the value is the weight Repeat this extraction and storage operation for all pixels until all pixels are The weight values have been stored in the corresponding hash table according to the end member index. After the traversal is completed, the The end-member index weight mapping table consists of hash tables.
[0075] Based on the end member index weight mapping table (including Hash tables, each of which stores all pixel weights corresponding to an end member), these mapping relationships need to be converted into a two-dimensional image matrix. First, the spatial dimension of the image, that is, the number of rows of the image, is read from the metadata of the de-streaked hyperspectral data cube. and number of columns , then, for each end member index (from 1 to ), do the following: Create a A two-dimensional floating-point matrix with all elements initialized to 0.0, then access the end member index weight mapping table corresponding to the current end member index The hash table, iterates over all key-value pairs in the hash table, each key-value pair provides the pixel coordinates (key) and corresponding contribution weight value (value) (if the key is a one-dimensional index , you need to convert it back to two-dimensional coordinates first ), the extracted weight value Fill in the previously created The corresponding position in the blank matrix At , the original initial value 0.0 is overwritten. Since the matrix has been pre-filled with 0, for pixels that may be missing in the hash table for some reason (theoretically, it should not happen, but as a robustness treatment), their values in the matrix will remain 0. After completing the traversal and filling of all key-value pairs in the hash table, the The matrix is the The two-dimensional endmember weight matrix of endmembers is Repeat this process for each end member index, and finally generate A two-dimensional endmember weight matrix.
[0076] Based on the previous step Two-dimensional end-member weight matrices need to be converted into standard visual grayscale image formats containing floating-point weight values. For each two-dimensional end-member weight matrix (corresponding to an end-member ) independently perform the following steps: First, iterate over all elements of the matrix and find the global maximum among all non-zero elements and the global minimum , these two values define the actual dynamic range of the current endmember weight value (if all values are zero, the abundance map is completely black), then, traverse each element in the two-dimensional endmember weight matrix again , apply the linear mapping method to change its value from the original interval Convert to the standard interval [0, 255] of 8-bit grayscale image, the specific mapping calculation is: , its corresponding gray value The calculation method is , need to pay attention to handle equal In the special case of (for example, when all non-zero values in the matrix are the same, or all values are zero), in this case, the grayscale values of all corresponding pixels can be set to 0 or 127, and the calculated integer grayscale value Stored in a new, same size The corresponding position of the integer matrix After completing the mapping of all elements, The integer grayscale value matrix is saved as a standard 8-bit grayscale image file format. Repeat this process for a two-dimensional end-member weight matrix, and finally generate The raw abundance atlas of grayscale images.
[0077] The steps to obtain the target abundance map parameter set are:
[0078] Based on the original abundance atlas, read the grayscale value of each pixel in the image, divide the grayscale value range of 0-255 into 256 equal-width intervals, count the number of pixels in each interval, record them in the order of intervals as a frequency array, and generate a statistical histogram of the pixel values of the target abundance map;
[0079] Based on the pixel value statistical histogram of the target abundance map, the grayscale value with a cumulative probability of 5% in the frequency array was calculated as the lower threshold, and the grayscale value with a cumulative probability of 95% was used as the upper threshold. The S-shaped curve function was selected as the transformation function for pixel value remapping. The grayscale value of the midpoint of the curve was set to the mean of the upper and lower thresholds, and the curve steepness coefficient was set to one-third of the difference between the upper and lower limits to generate the target abundance map calibration parameter set.
[0080] Specifically, based on the original abundance atlas (including the corresponding end member Grayscale images), first, one or more abundance maps corresponding to the specific chemical components of the target Chinese medicinal materials need to be selected for processing. The selection can be based on the predetermined end member index corresponding to the chemical component, or by observing the matching degree between the pattern of each map in the abundance map set and the distribution area of the known chemical components. After selecting a target abundance map (for example, selecting Abundance map), read the image file, the image is a A matrix where each element is an 8-bit grayscale value ranging from 0 to 255. Next, initialize an integer array of length 256 with all elements set to zero. This array will be used to store the frequency statistics of the grayscale values. Then, traverse each pixel in the selected target abundance map. , get its grayscale value , using this grayscale value as an index, perform an increment operation on the count of the corresponding index position in the frequency array (i.e., frequency array [G_{x, y, k}]++), and complete the image all After traversing pixels, the frequency array completely records the total number of pixels that appear in the target abundance map at each gray level between 0 and 255. This frequency array is the generated target abundance map pixel value statistical histogram.
[0081] Based on the target abundance map pixel value statistical histogram (i.e., a frequency array with a length of 256), it is necessary to calculate the parameters for subsequent pixel value adjustment. First, calculate the total number of pixels in the image. , that is, sum all elements in the frequency array, then calculate the cumulative frequency distribution and generate a cumulative frequency array of the same length of 256, where the first The value of the element is equal to the original frequency array from index 0 to index Then, based on the cumulative frequency distribution, the cumulative probability is calculated to find the grayscale threshold that meets the conditions: Find the minimum grayscale value , so that the ratio of the cumulative number of pixels of this gray value and all previous gray values to the total number of pixels reaches or exceeds 5% for the first time (i.e., the cumulative probability ), this gray value is set as the lower threshold; similarly, find the minimum gray value , so that the ratio of the cumulative number of pixels of this gray value and all previous gray values to the total number of pixels reaches or exceeds 95% for the first time (i.e., the cumulative probability ), this gray value is set as the upper threshold, these two thresholds and The determination is based on the distribution characteristics of the data itself. The purpose is to exclude the extreme values at both ends of the distribution (5% each) and focus on the main distribution interval of the pixel value. Next, select an S-type (Sigmoid) curve function as the transformation function model for subsequent pixel value remapping, and according to the calculated lower threshold and upper threshold To set the key parameters of the S-shaped curve: set the gray value at the inflection point of the curve, that is, the midpoint of the curve , is the arithmetic mean of the upper and lower thresholds, and the calculation formula is ; Set the steepness coefficient of the curve This coefficient affects the slope of the curve near the inflection point, that is, the speed of gray value change. Its value is set to one-third of the difference between the upper and lower thresholds. The calculation formula is For example, if the lower threshold of a target abundance map is obtained by calculation , upper threshold , then the midpoint of the curve is calculated , steepness coefficient , the calculated lower threshold , upper threshold , midpoint of the S-shaped curve and the steepness coefficient These four values are combined to generate the target abundance map calibration parameter set.
[0082] The steps for obtaining the target component enhanced abundance map are:
[0083] Based on the target abundance map calibration parameter set, the lower threshold, upper threshold, S-curve midpoint and steepness coefficient stored in the calibration parameter set are parsed, the parameters are loaded into memory variables, and mapping adjustment parameters are generated;
[0084] Based on the mapping adjustment parameters, the enhanced pixel value of each pixel value in the target abundance map is calculated using the following formula:
[0085] ;
[0086] in, For coordinates The enhanced pixel value at is the coordinate in the original abundance map The pixel value of is the lower threshold, is the upper threshold, is the midpoint of the S-shaped curve, is the steepness coefficient;
[0087] Based on the enhanced pixel values, all pixel coordinates of the abundance map are traversed, and the enhanced pixel values are filled into the new image matrix according to the coordinates. The matrix is converted into an 8-bit grayscale image and stored according to the target component name to generate the enhanced abundance map of the target component.
[0088] Specifically, a parameter set is determined based on the target abundance map (the parameter set includes the lower limit threshold calculated for the specific target abundance map in the previous step , upper threshold , midpoint of the S-shaped curve and steepness coefficient ), first perform a parsing operation, that is, read the four specific values from the data structure storing the parameter set (such as a file or memory object), and then load these four values into the corresponding variables in the memory when the program is running. For example, the read lower threshold is assigned to the variable lower_threshold, the upper threshold is assigned to the variable upper_threshold, the midpoint of the S-shaped curve is assigned to the variable midpoint, and the steepness coefficient is assigned to the variable steepness. After loading is completed, this set of memory variables containing specific values constitutes the mapping adjustment parameters used for subsequent pixel value adjustment calculations.
[0089] formula: The formula is beneficial in that it uses an S-shaped curve (specifically, the inverse tangent function) to perform nonlinear mapping on the pixel values of the target abundance map, achieving adaptive contrast enhancement by using the lower threshold calculated from the image's own histogram. and upper threshold , will be lower than Pixel values are directly mapped to 0 (pure black), and values above The pixel value is directly mapped to 255 (pure white), which effectively suppresses the influence of possible noise or irrelevant background pixels at both ends. and The main pixel value interval between the two is stretched by using the S-shaped characteristic of the inverse tangent function, especially the middle grayscale area (around the midpoint ) makes the distribution details of the target components more clearly visible, and the and The stretching range of the region is small and the transition is smooth;
[0090] (Coordinates in the original abundance map The steps for obtaining the pixel value of is as follows: the value is the abundance image selected as the current processing target (for example, the corresponding end member) in the original abundance atlas (8-bit grayscale image set) generated earlier in the processing process. Abundance map) in spatial coordinates The grayscale value of the pixel at , which ranges from 0 to 255. For example, in the selected target abundance map, the coordinate is The pixel value is ; The coordinates are The pixel value is ; The coordinates are The pixel value is ;
[0091] The steps for obtaining the (lower threshold) are as follows: This value comes directly from the "target abundance map calibration parameter set" generated in the previous step. It is the grayscale value corresponding to the cumulative probability of 5% calculated when analyzing the pixel value statistical histogram of the target abundance map. For example, according to the calculation results of the previous step, the lower threshold is ;
[0092] The steps for obtaining the upper threshold are as follows: This value is also directly derived from the "target abundance map calibration parameter set" generated in the previous step. It is the grayscale value corresponding to the cumulative probability of 95% calculated when analyzing the pixel value statistical histogram of the target abundance map. For example, according to the calculation results of the previous step, the upper threshold is ;
[0093] The steps for obtaining the midpoint of the S-shaped curve are as follows: This value comes directly from the "target abundance map calibration parameter set" generated in the previous step and is the lower limit threshold calculated based on and upper threshold The calculated arithmetic mean ( ), for example, according to the calculation results of the previous step, the midpoint of the S-shaped curve is ;
[0094] The steps to obtain the (steepness coefficient) are as follows: This value comes directly from the "target abundance map calibration parameter set" generated in the previous step and is calculated based on the lower limit threshold and upper threshold One third of the calculated difference ( ), for example, according to the calculation results of the previous step, the steepness coefficient is ;
[0095] Substituting the parameters into the formula, we get 67. This result shows that by applying the parameters calculated based on the grayscale distribution characteristics of the target abundance map itself ( ) and the S-shaped curve (inverse tangent function) transformation formula, the original pixel values are effectively remapped to the range of 0-255. Pixels with original values below the lower threshold of 40 (such as 30) are mapped to 0, and pixels above the upper threshold of 220 (such as 230) are mapped to 255. Pixel values in the middle range (such as 100) are nonlinearly mapped to new grayscale values (such as 67) according to their position on the S-shaped curve. This process achieves contrast stretching of the main grayscale range.
[0096] Based on the coordinates of each pixel calculated in the previous step The corresponding enhanced pixel value (its value range is between 0 and 255), these enhanced values need to be combined into a complete image. First, according to the dimension of the original target abundance map (number of rows and number of columns ), create a new one of the same size A two-dimensional matrix, which is used to store the final 8-bit grayscale image data. Its data type should be set to an 8-bit unsigned integer (capable of storing values 0-255). Then, traverse all possible pixel coordinates. ,in From 0 to , From 0 to , for each coordinate , and its corresponding, calculated enhanced pixel value Fill in the newly created two-dimensional matrix Position, when all pixel coordinates are traversed and filled, this two-dimensional matrix contains the complete enhanced image information. Finally, the two-dimensional matrix is encoded and saved in a standard image file format (such as PNG, TIFF, BMP, etc.). When saving the file, a file name that reflects its content is used. For example, if the enhancement is the abundance map representing the component "flavonoids", the file name can be set to "enhanced abundance map_flavonoids.png", thereby generating and storing the enhanced abundance map of the target component.
[0097] The steps for obtaining multiple layers of data channels to be fused are as follows:
[0098] Based on the target component enhancement abundance map, the grayscale values of all pixels in the image are traversed, and the 5% quantile and 95% quantile of the pixel value distribution are counted. The 5% quantile is set as the benchmark lower limit of the grayscale intensity mapping, and the 95% quantile is set as the benchmark upper limit to generate the grayscale intensity mapping rule;
[0099] Based on the original abundance atlas, according to the preset name list of Chinese medicinal materials chemical components, the atlas index directory is traversed, and the abundance map files that are exactly the same as the names of the components in the list are screened by full word matching to generate a candidate abundance map set;
[0100] Based on the grayscale intensity mapping rule, pixel value remapping is performed on each layer in the selected abundance map set, and the pixel values of each layer are linearly stretched according to the benchmark lower limit and upper limit to generate multiple layers of data channels to be fused.
[0101] Specifically, based on the target component enhanced abundance map (the map is an 8-bit grayscale image with enhanced contrast of a specific chemical component generated in the previous step), it is necessary to determine a unified grayscale intensity mapping benchmark for the subsequent multi-layer data fusion step. First, traverse each pixel point in the target component enhanced abundance map, read its grayscale value (range 0-255), collect the grayscale values of all pixels to form a data set, and then perform statistical analysis on this data set, calculate its cumulative distribution function or directly use the quantile estimation algorithm to determine the 5% quantile and 95% quantile of the grayscale value distribution. The specific calculation process is as follows: sort the grayscale values of all pixels in the image. If the total number of pixels in the image is , then the 5% quantile is the quantile in the first The gray value of the position (needs to be rounded or interpolated), the 95% quantile is the gray value at the first position after sorting. For example, for a 1-million-pixel enhanced abundance map, after sorting all its pixel values, the first The value of the pixel (for example, 30) is the 5% quantile, and the The value of the pixel (for example, 210) is the 95% quantile, the calculated 5% quantile value is set as the benchmark lower limit value of the grayscale intensity mapping (for example, the benchmark lower limit value = 30), and the 95% quantile value is set as the benchmark upper limit value (for example, the benchmark upper limit value = 210). These two values together constitute the grayscale intensity mapping rule.
[0102] Based on the original abundance atlas (containing all The original grayscale abundance map without enhancement corresponding to the end members) needs to be screened out from a predefined list of chemical components of interest in the target Chinese medicinal materials to participate in the subsequent color synthesis. This preset name list needs to be determined according to the analysis purpose before using this method. For example, the list may contain ["alkaloids", "flavonoids", "organic acids"]. Each name in the list corresponds to a chemical component that is expected to be displayed or analyzed in the final composite image. Next, the directory or data structure storing the original abundance atlas will be accessed, and each original abundance map file or data record therein will be traversed to read the corresponding The chemical component name associated with each abundance map (the name may be stored in the file name, such as "abundance map_alkaloid.png", or stored in the metadata tag of the image file) is matched accurately and whole-word with each entry in the preset name list (case-sensitive or case-insensitive, the matching rules are set according to actual needs, but consistency must be ensured). If the component name associated with an original abundance map is exactly the same as a name in the preset list, the original abundance map (or its file path or reference) is added to a new set. After traversing all original abundance maps, this new set is the candidate abundance map set.
[0103] Based on the previously determined grayscale intensity mapping rule (i.e., the benchmark lower limit and benchmark upper limit calculated from the target component enhanced abundance map) and the selected abundance map set (which contains multiple unprocessed original abundance maps, each of which represents a chemical component layer to be fused), it is necessary to perform pixel value standardization on these selected layers. The specific operation is to traverse each abundance map (layer) in the set of candidate abundance maps, and for the currently processed layer (set its pixel value to be ), create a new one of the same size ( ) is used to store the remapped values, and then traverse all pixel coordinates of the layer , read its original pixel grayscale value , apply the following linear stretching rule to calculate the remapped value :like Less than or equal to the lower limit of the benchmark, then ;like Greater than or equal to the upper limit of the benchmark, then ;like Between the lower limit and upper limit of the benchmark, , it is necessary to handle the special case where the upper limit of the benchmark is equal to the lower limit of the benchmark (in this case, all Set to 0.0 or 0.5), the calculated floating point value (range between 0.0 and 1.0) is stored in the newly created two-dimensional matrix After all pixels in the current layer are remapped, the two-dimensional floating-point matrix is saved, and then this process is repeated for the next layer in the set until all candidate abundance maps have completed pixel value remapping and normalization based on a unified benchmark. Finally, a set of two-dimensional floating-point matrices (the number is equal to the number of candidate abundance maps) is obtained, which constitutes a multi-layer data channel to be fused.
[0104] The steps for acquiring component-specific enhanced microscopic images of Chinese medicinal materials are as follows:
[0105] Based on the multi-layer data channels to be fused, the chemical component names of the Chinese medicinal materials corresponding to each data channel are parsed, and a channel color coding vector set is generated according to the preset chemical component-color mapping table;
[0106] Based on the channel color coding vector set, the RGB pixel value vector of each pixel is calculated using the following formula:
[0107] ;
[0108] in, For coordinates The RGB pixel value vector at , For the A color-coded vector of channels, For coordinates Place Normalized pixel values of channels, is the total number of channels, is the L2 norm of the vector;
[0109] Based on the RGB pixel value vector, all pixel coordinates are traversed and the RGB pixel value vector is filled into a three-dimensional tensor by rows and columns. The tensor is converted into a 24-bit true color image and the chemical component label metadata is embedded to generate component-specific enhanced microscopic images of Chinese medicinal materials.
[0110] Specifically, based on the multi-layer data channels to be fused (which contain multiple two-dimensional data layers corresponding to specific chemical components and have been normalized), it is first necessary to assign a unique color identifier to each data channel (i.e., each chemical component layer). The program needs to parse the name of the chemical component of the Chinese medicinal material associated with each data channel. This name information should have been attached when creating the data channel or can be obtained through the file name, for example, channel 1 is associated with "alkaloids", channel 2 is associated with "flavonoids", and channel 3 is associated with "organic acids". At the same time, a pre-set "chemical component-color mapping table" is required, which clearly specifies the name of each possible chemical component and its appearance in the final color. The correspondence between the colors (usually RGB vectors) represented in the image. This mapping table needs to be prepared in advance according to the experimental design or visualization requirements. For example, you can set: {"alkaloids": [0, 255, 0], "flavonoids": [255, 0, 0], "organic acids": [0, 0, 255]}, that is, alkaloids are represented by pure green, flavonoids are represented by pure red, and organic acids are represented by pure blue. The program then traverses each channel in the multiple layers of data channels to be fused, and searches the mapping table for the corresponding RGB color vector according to the name of the associated chemical component. These found color vectors are collected to form a channel color coding vector set consistent with the order of the data channels.
[0111] formula: The benefit of the formula is that it combines the normalized distribution information of multiple chemical components ( ) into a single RGB color value, with each component's contribution calculated by multiplying its normalized abundance value by its preset color vector ( ) to represent it, and add these weighted color vectors to obtain a mixed color vector. This linear mixing method intuitively reflects the relative proportion and coexistence of each chemical component at a single pixel point. The normalization term in the denominator is intended to adjust the overall brightness or intensity of the mixed color to prevent color saturation beyond the display range (for example, RGB values exceed 255) due to multiple components having high abundance values at the same time. The final floor operation converts the calculated floating-point RGB value into a standard 8-bit integer value, and the final generated RGB vector Can simultaneously display the distribution information of multiple chemical components in a mixed color manner within one pixel;
[0112] (No. The steps to obtain the color coding vector of the channel are: The preset colors of the chemical component channels are directly obtained from the "channel color coding vector set" generated in the previous step. This set is generated based on the preset "chemical component-color mapping table" and the chemical component names corresponding to the channels. The selection of colors should focus on differentiation and visualization effects. For example, if there are three channels , corresponding to "flavonoids", "alkaloids", and "organic acids" respectively. The mapping table is set to {"flavonoids": [255, 0, 0], "alkaloids": [0, 255, 0], "organic acids": [0, 0, 255]}, and the obtained color coding vector is (red), (green), (blue);
[0113] (coordinate Place The steps to obtain the normalized pixel value of each channel are as follows: This value comes from the first “multi-layer fusion data channel” generated in the early stage of the process. channels (2D floating point matrices) at coordinates The value at this point is obtained by linearly stretching the original abundance map based on a unified benchmark, and its range is between 0.0 and 1.0, representing the Chemical composition in pixels The relative abundance or intensity at , for example, for pixel coordinates , the normalized values read from the corresponding matrices of the three channels are: , , ;
[0114] The steps to obtain (total number of channels) are as follows: this value is equal to the number of data channels (two-dimensional matrices) contained in the "Multi-layer Data Channels to be Fusion" set, that is, the number of chemical components that will eventually participate in color synthesis. This number is determined by the number of entries in the "Preset Name List" used when filtering the "Candidate Abundance Map Set" in the previous step. For example, if the preset list contains 3 component names and the corresponding original abundance maps are found for all of them, then .
[0115] Substitute the parameters into the formula to calculate , the result shows that: for pixel coordinates , its final RGB color value is [137, 39, 78], which is a mixed color, in which the red component (137) is relatively the highest, reflecting the higher relative abundance (0.7) of the first chemical component ("flavonoids", corresponding to red) at this point, and at the same time mixed with the green component (39) contributed by the second component ("alkaloids", green, abundance 0.2) and the blue component (78) contributed by the third component ("organic acid", blue, abundance 0.4). This RGB vector is the color information of a pixel point that constitutes the final color image. The value is in the range of [0, 255] and can be directly used for image display.
[0116] Based on the coordinates of each pixel calculated in the previous step Corresponding RGB pixel value vector (where R, G, and B are all integers between 0 and 255), these vectors need to be organized into a standard color image format. First, according to the dimensions of the original image (number of rows and number of columns ), creates a three-dimensional data tensor with dimensions , the data type is usually set to an 8-bit unsigned integer (uint8), which is used to store the values of the three RGB color channels. Then, traverse all the pixel coordinates ,in Ranges from 0 to , Ranges from 0 to , for each coordinate , the calculated RGB vector The three components are respectively filled into the three channels of the corresponding positions of the three-dimensional tensor, that is, tensor [x, y, 0] = Rxy, tensor [x, y, 1] = Gxy, tensor [x, y, 2] = Bxy). After all pixels are filled, the three-dimensional tensor contains the complete color image data. Subsequently, this three-dimensional tensor is converted into a standard 24-bit true color image file format (such as PNG, TIFF, etc.). When saving the image file, the correspondence between chemical components and colors (for example, "Red: flavonoids, Green: alkaloids, Blue: organic acids") must be embedded into the image file as metadata or saved in association with the image file in other ways to explain the meaning of different colors in the image. Finally, a component-specific enhanced microscopic image of Chinese medicinal materials is generated and saved.
[0117] The above are merely preferred embodiments of the present invention and do not limit the present invention in any other form. Any technician familiar with the profession may use the technical content disclosed above to change or modify it into an equivalent embodiment with equivalent changes and apply it to other fields. However, any simple modification, equivalent change and modification made to the above embodiment based on the technical essence of the present invention without departing from the content of the technical solution of the present invention shall still fall within the scope of protection of the technical solution of the present invention.
Claims
1. A method for enhancing infrared microscopic images of Chinese medicinal materials, characterized in that: The following steps are involved: Based on the input original infrared spectral microscopic image data of traditional Chinese medicine, a two-dimensional Fourier transform is performed on each spectral band image to obtain a frequency domain representation. The target frequency peak position generated by interference in the frequency domain representation is identified to generate a de-streaked hyperspectral data cube. Based on the de-streaked hyperspectral data cube, the spectral vector of each pixel in the cube is decomposed to establish a full-pixel endmember contribution weight set; based on the full-pixel endmember contribution weight set, the contribution weight values of all pixels corresponding to the same index are extracted and organized into a two-dimensional matrix according to the index of the endmember spectral vector to obtain an original abundance atlas; Based on the original abundance atlas, one or more abundance maps corresponding to the target Chinese medicinal material chemical components are selected, a statistical histogram of the pixel values of the selected abundance maps is calculated, a target abundance map calibration parameter set is established, and based on the target abundance map calibration parameter set, each pixel value in the selected abundance map is mapped and adjusted according to the set transformation function parameters to expand the dynamic range of the pixel value, thereby obtaining an enhanced abundance map of the target component; A grayscale intensity mapping rule is set according to the pixel value range of the target component enhanced abundance map, and abundance layers representing different components are selected from the original abundance map set to obtain multiple layers of data channels to be fused. Based on the multiple layers of data channels to be fused, color synthesis is performed pixel by pixel to establish a component-specific enhanced microscopic image of Chinese medicinal materials; The steps for obtaining the target component enhanced abundance map are: Based on the target abundance map calibration parameter set, parsing the lower threshold, upper threshold, S-curve midpoint and steepness coefficient stored in the calibration parameter set, loading the parameters into memory variables, and generating mapping adjustment parameters; calculating an enhanced pixel value for each pixel value in the target abundance map based on the mapping adjustment parameter; Based on the enhanced pixel values, traverse all pixel coordinates of the abundance map, fill the enhanced pixel values into the new image matrix according to the coordinates, convert the matrix into an 8-bit grayscale image and store it according to the target component name, and generate an enhanced abundance map of the target component; The steps for obtaining the component-specific enhanced microscopic image of Chinese medicinal materials are as follows: Based on the multi-layer data channels to be fused, the chemical component name of the Chinese medicinal material corresponding to each data channel is parsed, and a channel color coding vector set is generated according to a preset chemical component-color mapping table; Calculate the RGB pixel value vector of each pixel based on the channel color coding vector set; Based on the RGB pixel value vector, all pixel coordinates are traversed, and the RGB pixel value vector is filled into a three-dimensional tensor by rows and columns. The tensor is converted into a 24-bit true color image and embedded with chemical component label metadata to generate a component-specific enhanced Chinese medicinal material microscopic image.
2. The method for enhancing infrared microscopic images of traditional Chinese medicine according to claim 1, characterized in that: The steps for obtaining the de-streaked hyperspectral data cube are as follows: Based on the input original infrared spectrum microscopic image data of traditional Chinese medicine, a two-dimensional Fourier transform is performed on each spectral band image to convert the spatial domain pixel matrix into a frequency domain matrix containing complex frequency coefficients to generate a frequency domain representation; Based on the frequency domain representation, the amplitude spectrum matrix of the frequency domain representation is scanned, and positions with amplitude values greater than three times the standard deviation of the mean amplitude values of adjacent frequency points are located as candidate peaks. A density clustering algorithm is used to eliminate pseudo peaks with discrete spatial distribution, and a set of peaks with continuous distribution and density exceeding a preset threshold is screened to identify the target frequency peak position. The geometric center coordinates are calculated as the center frequency of the band-stop filter based on the peak position coordinates. The bandwidth is calculated based on the frequency range covered by the peak area. The attenuation depth is set according to the ratio of the peak amplitude to the background noise amplitude to generate the band-stop filter parameters. Based on the band-stop filter parameters, a circular stopband region with the center frequency as the center and the bandwidth as the radius is constructed in the frequency domain representation. The amplitudes of the complex frequency coefficients within the stopband are multiplied by the attenuation depth coefficient, and the original amplitudes of the coefficients outside the stopband are retained. An inverse two-dimensional Fourier transform is performed on the modified frequency domain matrix, and the complex matrix is converted into a real pixel matrix to generate a de-streaked hyperspectral data cube.
3. The method for enhancing infrared microscopic images of traditional Chinese medicine according to claim 1, characterized in that: The steps for obtaining the full-pixel endmember contribution weight set are: Based on the de-streaked hyperspectral data cube, extracting the spectral vector of each pixel point in the cube, performing an initialized orthogonal projection operation on each spectral vector, calculating the projection vector of the spectral vector in the direction of the endmember spectral vector, and generating an initial projection vector; Calculating a contribution weight value based on the initial projection vector; Based on the contribution weight values, all combinations of pixel points and endmember spectral vectors are traversed, and a mapping relationship is constructed between the contribution weight values according to pixel indices and endmember indices to generate a full-pixel endmember contribution weight set.
4. The method for enhancing infrared microscopic images of traditional Chinese medicine according to claim 1, characterized in that: The steps for obtaining the original abundance atlas are: Based on the full-pixel endmember contribution weight set, traverse the three-dimensional coordinates of each pixel in the data cube, extract the contribution weight value of each pixel under each endmember index, create an independent storage queue according to the index number of the endmember spectral vector, store the weight values of all pixels under the same index into a hash table as key-value pairs, and generate an endmember index weight mapping table; Based on the endmember index weight mapping table, the number of image rows H and columns W of the striped hyperspectral data cube is read, and an H×W blank floating-point matrix is created. All key-value pairs under a certain endmember index in the hash table are traversed, and the contribution weight values of the corresponding pixels are filled into the corresponding row and column positions of the blank matrix. The unfilled positions are assigned 0 to generate a two-dimensional endmember weight matrix. Based on the two-dimensional endmember weight matrix, the global maximum and minimum values of all non-zero elements in the matrix are calculated, each matrix element value is mapped to the range of 0-255, and the mapped matrix is converted into an 8-bit grayscale image to generate the original abundance atlas.
5. The method for enhancing infrared microscopic images of traditional Chinese medicine according to claim 1, characterized in that: The steps for obtaining the target abundance map calibration parameter set are: Based on the original abundance atlas, the grayscale value of each pixel in the image is read, the grayscale value range of 0-255 is divided into 256 equal-width intervals, the number of pixels in each interval is counted, and the frequency array is recorded in the order of the intervals to generate a target abundance map pixel value statistical histogram; Based on the pixel value statistical histogram of the target abundance map, the grayscale value with a cumulative probability of 5% in the frequency array is calculated as the lower threshold, and the grayscale value with a cumulative probability of 95% is used as the upper threshold. The S-shaped curve function is selected as the transformation function for pixel value remapping, the grayscale value of the midpoint of the curve is set to the mean of the upper and lower thresholds, and the curve steepness coefficient is set to one-third of the difference between the upper and lower limits, to generate a target abundance map calibration parameter set.
6. The method for enhancing infrared microscopic images of traditional Chinese medicine according to claim 1, characterized in that: The steps for obtaining the multi-layer data channels to be fused are: Based on the target component enhancement abundance map, the grayscale values of all pixels in the image are traversed, the 5% quantile and the 95% quantile of the pixel value distribution are counted, the 5% quantile is set as the benchmark lower limit value of the grayscale intensity mapping, and the 95% quantile is set as the benchmark upper limit value, and a grayscale intensity mapping rule is generated; Based on the original abundance atlas, according to the preset name list of the chemical components of traditional Chinese medicine, the atlas index directory is traversed, and the abundance map files that are completely consistent with the names of the components in the list are screened by full word matching to generate a candidate abundance map set; Based on the grayscale intensity mapping rule, pixel value remapping is performed on each layer in the candidate abundance map set, and the pixel values of each layer are linearly stretched according to the benchmark lower limit value and upper limit value to generate multiple layers of data channels to be fused.
Citation Information
Patent Citations
Drug quality dynamic monitoring and control method
CN118052334A
Road area intelligent extraction system for aerial image of unmanned aerial vehicle
CN120182939A