A method for fast electron counting of Medipix2 data using LUT method
By pre-calculating the centroid localization result table using the LUT method and embedding it in memory, the problem of low computational efficiency of the Medipix2 detector is solved, and image processing with fast electron counting and high signal-to-noise ratio is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BIOISLAND LAB
- Filing Date
- 2026-04-28
- Publication Date
- 2026-07-31
AI Technical Summary
While existing Medipix-type detectors offer high positioning accuracy when processing Medipix2 data, their computational efficiency is low, making it impossible to achieve near real-time imaging. Traditional algorithms are also slow, failing to meet the demands for efficient and rapid electronic counting.
The LUT method is used to pre-compute the centroid localization result table of a 3×3 matrix binary image and embed it in memory. Electron counting is quickly realized through the lookup table, including centroid localization, matrix filter traversal and result table lookup, and signal processing is performed directly on the hardware.
It significantly improved the image signal-to-noise ratio (SNR) and greatly reduced the processing time, achieving rapid electronic counting with a processing speed increase of 4.4 times.
Smart Images

Figure CN122492812A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data processing and single electron counting algorithms for direct electron detectors (Hybrid Pixel Detectors) in electron microscopes. Specifically, it relates to a method for high-speed single electron localization and counting using a fixed spatial pixel cluster pattern lookup table (LUT) for two-dimensional electron event data acquired by the Medipix2 hybrid pixel detector. Background Technology
[0002] In electron microscopy imaging, the detector receives not a clear single electron, but rather a signal formed by the diffusion of electrons across multiple pixels after their initial impact. If frame integration is used directly, not only is the electron information accumulated, but noise is also superimposed, leading to a decrease in image signal-to-noise ratio and limited resolution. To address this issue, direct electron detectors introduce electron counting algorithms. The core idea is to identify the pixel clusters formed by individual electron impacts and determine their locations, then count them using a "one electron = one event" approach. This effectively reduces noise and improves image contrast, with significant advantages, especially under low-dose conditions. Currently common detectors include CMOS indirect detectors, MAPS (Monolithic Active Pixel Sensor), and HPD (Hybrid Pixel Detector). CMOS and MAPS typically employ threshold detection combined with centroid localization. This method is simple to implement and widely used in commercial devices, but its accuracy is insufficient and computationally time-consuming when there is high noise or electron overlap. Another type of algorithm based on point spread function or Gaussian fitting can achieve higher sub-pixel localization accuracy, but its computational overhead is huge and it is not suitable for real-time imaging. Among HPD detectors, Medipix and Timepix3 are representative solutions. The event-driven Timepix3 can use time and energy information to distinguish overlapping events, resulting in higher localization accuracy, but it has extremely high requirements for hardware and computing resources.
[0003] Medipix is a series of hybrid pixel detectors developed in collaboration with CERN. Its core concept is not to measure continuous signal strength, but to count each individual photon or particle that arrives at the sensor layer and to measure its energy.
[0004] Although Medipix lacks time and energy resolution, it boasts a frame rate far exceeding that of CMOS and MAPS, resulting in a significant increase in data volume. Traditional algorithms are slow to process this data and cannot achieve near real-time processing. Consequently, traditional centroid methods or Gaussian fitting are extremely inefficient, making it difficult to achieve near real-time imaging. Therefore, how to significantly improve processing efficiency and reduce computational burden while ensuring positioning accuracy has become a critical technical problem that counting algorithms for Medipix-type detectors urgently need to solve.
[0005] The purpose of this invention is to provide a method for efficient, fast, and accurate Medipix2 electronic counting. Summary of the Invention
[0006] To achieve the above objectives, this invention first provides a method for rapid electron counting using 2D data from the electron detector Medipix2 via a Look-Up Table (LUT) method. The method includes the following steps:
[0007] S11. Pre-calculate the centroid localization result table of pixel clusters in a 3×3 matrix binary image, and obtain the centroid localization result table of 512 pixel combination patterns;
[0008] S12. The centroid positioning result table is built into memory;
[0009] S13. Collect experimental image data;
[0010] S14. Preprocess the image data;
[0011] S15. The matrix filter traverses the image data and calculates the centroid location of each effective pixel cluster of the 3×3 matrix;
[0012] S16. Locate the centroid positioning results table and overwrite the source data;
[0013] S17. Output the resulting image.
[0014] Existing lookup table (LUT)-based techniques are mostly used for memory access optimization at the general image processor or compiler level. They address data scheduling and access efficiency issues between multiple memory banks, but do not address the spatial clustering characteristics of single electron events, pixel cluster geometric centroid localization, and electron counting problems in electron microscope detectors. The LUT used in this invention is a mapping table between the spatial pattern of 3×3 binary pixel clusters and the electron event localization results, belonging to a signal processing algorithm at the specific detector application level.
[0015] In a preferred embodiment, the centroid positioning strategy for the 512 pixel combination modes in S11 is as follows:
[0016] (1) All Black Mode: Outputs all black when there are no white dots;
[0017] (2) Single-point mode: When there is only one white dot, the original position is retained;
[0018] (3) Centroid mode: Calculate the centroid and retain only the position of the centroid when there are 2-9 white points.
[0019] In a preferred embodiment, the centroid coordinate algorithm for the centroid pattern is as follows: In each connected region (set of white pixels) in the two-dimensional image, assuming that the region contains N valid pixels, the coordinates of each pixel are (x... i , y i ), where i = 1, 2, ..., N,
[0020] The x-coordinate of the centroid is:
[0021] The ordinate of the centroid is: .
[0022] In a preferred embodiment, the experimental image data mentioned in S13 refers to data collected by the Medipix hybrid pixel detector.
[0023] In a preferred embodiment, the preprocessing of the image data in S14 includes defect pixel removal and image data binarization.
[0024] In a preferred embodiment, the centroid positioning described in S15 includes:
[0025] S61. Centroid Coordinate Calculation: Calculate the centroid (geometric center) coordinates of the effective pixel clusters in each connected region;
[0026] S62. Window Extraction: Extract a matrix window of the corresponding size centered on each centroid coordinate to obtain a binary window pixel pattern.
[0027] In a preferred embodiment, the search strategy for finding the centroid positioning result table in S16 is as follows: the binary pixel sequence within the window is converted into a byte stream, and the LUT result table is searched with the connected component positioning coordinates as the center and a 3×3 matrix as the filtering range. When the number of matrix pixels is 2 or 4, after outputting the result in the LUT lookup table, the positioning result coordinates are selected to be shifted left or right based on whether the generated random number is greater than 0.5. When the number of matrix pixels is 3 or 5, the corresponding electronic counting positioning result is directly output from the LUT result table. When the number of matrix pixels is greater than 6, the source data is used without processing.
[0028] In a preferred embodiment, the process of overwriting the source data in S16 is as follows:
[0029] S81 coordinate mapping: The processing window uses the centroid as the anchor point to map the coordinates of the centroid center of the output connected region to the corresponding position in the output image. For overlapping regions, subsequent processing overwrites previous results to ensure that each connected region is processed independently.
[0030] S82 pixel assignment: Writes the processing result into the corresponding area of the output image;
[0031] S83 value range unification: ultimately unifies all valid pixels to a single intensity value of 1;
[0032] S84 generates an output image of the same size as the input, where pixel values represent the optimized signal locations.
[0033] Secondly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method for rapid electron counting of 2D data from the electron detector Medipix2 using the LUT method.
[0034] Finally, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method for rapid electron counting of 2D data of the electron detector Medipix2 using the LUT method.
[0035] The present invention provides a method for rapid electron counting of 2D data from the Medipix2 electron detector using the LUT method, which can be implemented directly in hardware without the need for software. Compared with traditional centroid methods, this method improves the image signal-to-noise ratio (SNR) while significantly reducing processing time. Attached Figure Description
[0036] Figure 1 .LUT algorithm experimental workflow diagram;
[0037] Figure 2 The LUT exhaustively searches the lookup table; the left half represents the shape of possible signal clusters. Taking a 3×3 cluster as an example, there are 2... 9 In this case, only a portion is shown in the figure. Each row represents the cluster shape of different classification cases, which can be counted as the same electron counting location result, thus forming a lookup table.
[0038] Figure 3 Example 1 of LUT result image: The obviously larger pixels in the image represent the number of pixels within a 3×3 area centered on the connected component after connected component processing, which exceeds 6 pixels and is not processed; the rest are pixels after reading the LUT table.
[0039] Figure 4 Example 2 of LUT result image: The result image obtained by overlaying all frames;
[0040] Figure 5 Experimental data images before and after algorithm processing;
[0041] Figure 6 Centroid method test results Figure 1 ;
[0042] Figure 7 Centroid method test results Figure 2 ;
[0043] Figure 8 Random selection method detection results Figure 1 ;
[0044] Figure 9 Random selection method detection results Figure 2 ;
[0045] Figure 10 Maximum value method detection results Figure 1 ;
[0046] Figure 11 Maximum value method detection results Figure 2 . Detailed Implementation
[0047] The present invention will be further described below with reference to specific embodiments, and the advantages and features of the present invention will become clearer as a result of the description. However, these embodiments are merely exemplary and do not constitute any limitation on the scope of protection defined by the claims of the present invention.
[0048] Example 1. Construction of a detector for fast electron counting using Medipix2 data via LUT method
[0049] The core idea of LUTs is to "trade space for time." Here, time refers to the CPU clock cycles and logic gate delays required to compute a function's result; space refers to memory resources such as RAM, ROM, BRAM in an FPGA, or distributed RAM. The application steps of a LUT are: pre-calculate the output of a function under all possible input conditions and store these results in a table (array). When the output corresponding to a specific input is needed, real-time computation is no longer performed; instead, the corresponding result is directly "looked up" in the table based on the input value. Figure 1 A flowchart illustrating fast electron counting of Medipix2 data using the LUT method is presented. Based on... Figure 1 The functional modules involved in the process are described in detail.
[0050] 1. Lookup Table Module
[0051] Exhaustive calculation of all possible pixel combinations for a single electron in a 3×3 pixel matrix, totaling 512 (2 9 )kind.
[0052] Positioning methods under different conditions in a 3×3 pixel (512 possibilities) matrix:
[0053] a. Full Black Mode (No Signal): Outputs a completely black screen when there are no white dots.
[0054] b. Single-point mode (single electron single pixel response): The original position is retained when there is only one white point. That is, when there is exactly one pixel with a value of 1 in every 3×3 pixel image position, that point is used as the positioning result.
[0055] c. Centroid Mode: When there are 2-9 white dots, the centroid is calculated and only the centroid position is retained. That is, when the number of values of 1 in each 3×3 pixel image position exceeds 20% of the 3×3 pixel image, the centroid method is used for positioning calculation. The final positioning position is set to 1 (white dot), and all other positions are set to 0 (black dot). The specific method for calculating the centroid coordinates is as follows:
[0056] In a binary image, each connected region (set of white pixels) contains N valid pixels, and the coordinates of each pixel are (x, y). i , y i ), where i=1,2,...,N, sum the coordinate components of each coordinate component in the 3×3 matrix and calculate the average to obtain the centroid coordinates; the centroid coordinates include the x-coordinate. and ordinate ,in,
[0057] The x-coordinate of the centroid is:
[0058] The ordinate of the centroid is:
[0059] The results of 3×3 are shown in the table below. Figure 2 The left side shows a partial example (ap) of all possible pixel combinations for a single electron in a 3×3 pixel matrix, and the right side shows the output after centroid localization. For example, when there are 3 white dots arranged in an L-shape within a 3×3 window ( Figure 2 b) Calculate the centroid according to the above formula. The sum of the horizontal coordinates is 0+1+1=2, and the horizontal coordinate of the centroid is 2 / 3≈0.67. The sum of the vertical coordinates is 0+0+1=1, and the vertical coordinate of the centroid is 1 / 3≈0.34. After rounding, the centroid result of the matrix diagram is (1,0).
[0060] For matrix graph ad, the calculated centroids are all at position (1,0); for matrix graph eh, the calculated centroids are all at position (0,0); for matrix graph il, the calculated centroids are all at position (1,1); for matrix graph mp, the calculated centroids are all at position (0,1).
[0061] Based on the above algorithm, 512 pattern images and their corresponding coordinates are pre-calculated, forming a lookup table, which is then stored in system memory. For cases where the actual matrix range formed by the number of pixel clusters exceeds a 3×3 matrix (when there are too many white points (≥10)), the error does not exceed 2% of the total number of pixel clusters and is considered normal image data error; the system does not process this error.
[0062] 2. Medipix2 (Hybrid Pixel Detector) Detector Data Collection
[0063] The primary task of the Medipix2 (hybrid pixel detector) is to collect electron beam images from a 120kV transmission electron microscope. The detector frame rate is set to 800-1000fps to ensure that there is no overlap between single-electron responses.
[0064] 3. Image preprocessing module
[0065] (1) Defect pixel removal
[0066] Medipix2 experimental image data characteristics: only shape, no grayscale, some bad pixels are always bright, these features need to be removed as defective pixels.
[0067] A. Identification of defective pixels:
[0068] ① Boundary defect identification: Preset a fixed range of defect areas in the image edge region.
[0069] ② Fixed-position dead pixels: The original image data contains constantly lit dividing lines between chips caused by hardware structural features, and the pixel positions that make up these dividing lines are fixed.
[0070] ③ Statistical anomaly detection of some bad pixels: For anomalies in bright field images, identify pixels that are too dark (below the mean - 2 times the standard deviation) or too bright (above the mean + 2 times the standard deviation); for anomalies in dark field images, detect abnormal pixels whose values are greater than the sum of the mean and the standard deviation, detect obvious bad pixels with dark field values greater than 2, and detect constant bad pixels in the dark field image sequence whose standard deviation is 0 and whose mean is greater than 0.
[0071] B. After identifying the above defective pixels, a binary mask is generated (white represents good pixels and black represents bad pixels). The mask is then applied to the input image data to remove the defective pixels.
[0072] (2) Image data binarization
[0073] After removing the aforementioned defective pixels, the Connected Component Labeling (CCL) algorithm is used to calculate and obtain all connected components in the image (in an image, pixels that meet specific conditions and are connected to each other are identified and labeled as the same independent region).
[0074] Connected component labeling is a fundamental algorithm in digital image processing, primarily used to identify and label interconnected pixel regions in binary images. In this defective pixel removal system, this algorithm is used to detect clusters of adjacent defective pixels in an image.
[0075] The connected component labeling algorithm system uses an 8-connectivity adjacency rule, which means that a pixel is considered connected to its upper, lower, left, right, and four diagonal adjacent pixels. This broad connectivity definition can more effectively identify bad pixel clusters of various shapes.
[0076] The connected component labeling algorithm completes the labeling process through two scans: the first scan temporarily assigns labels and records equivalence relationships, and the second scan unifies the labels based on the equivalence relationships. Ultimately, each interconnected pixel cluster is assigned a unique identifier, facilitating subsequent feature analysis and processing.
[0077] After calculating connected component regions of various sizes using the connected component labeling algorithm, pixels with a size of 1 are removed as defective pixels, and the connected component data (connected component center coordinates, connected component size) is saved in memory. Finally, the cleaned image data is binarized.
[0078] Figure 5 These are images of the experimental data before and after algorithm processing. As you can see... Figure 5 It does not contain any independent pixels without any adjacent pixels; all pixels are pixel clusters with a size greater than or equal to 2, and all white pixels have a pixel value of 255. There are no pixels with other gray values.
[0079] 4. Matrix Filter Module
[0080] This module uses a matrix filter to traverse all connected component data in the image and calculates the centroid coordinates of the connected components.
[0081] The matrix filter in this invention refers to a mechanism that directly traverses the results of a connected component labeling algorithm, using a 3×3 square matrix as the basic processing unit. It leverages all connected component information already identified and labeled by the CCL algorithm to directly traverse and process these pre-generated connected component lists. Each window systematically scans the effective area of the image, centered on the current centroid coordinates. The traversal in this invention refers to using the matrix filter to filter image data and determining the shape of the signal clusters at the image position of each filter-sized matrix.
[0082] Specific data processing steps:
[0083] S41. Centroid localization: Calculate the centroid (geometric center) of each valid pixel cluster.
[0084] S42. Window Extraction: A matrix window of the corresponding size is extracted centered on each centroid to obtain the binary window pixel pattern. First, the precise centroid coordinates of each connected component are obtained using the CCL algorithm. Then, a local coordinate system is established centered on these centroids. Finally, the pixel data of the corresponding region is extracted from the original binary image to form a standardized window matrix for use by subsequent algorithms.
[0085] Suppose an L-shaped connected region is detected in a binary image, consisting of multiple adjacent white pixels. After processing with the CCL algorithm, the geometric centroid coordinates of this connected region are calculated to be (150, 200) in the image. These coordinates represent the center of mass of the shape.
[0086] The next step is to construct a 3×3 square analysis window centered at the centroid coordinates (150, 200). This window covers a rectangular area extending one pixel outward from the centroid, forming a local analysis unit containing 9 pixels.
[0087] 5. LUT Result Table Lookup Module
[0088] The mechanism for looking up the results table involves converting the binary pixel sequence within the window into a byte stream and performing a fast lookup in a hash table. The hash table, through a specific key-value mapping mechanism, enables fast pattern matching and result retrieval, serving as both the access interface and acceleration layer for the lookup table. This ensures near-constant time complexity lookups across a large number of predefined patterns. The lookup table, as the data layer, stores complete pattern mapping rules, including all predefined input-output correspondences; the hash table, as the index layer, establishes a fast mapping from pattern features to storage locations, optimizing access paths.
[0089] The specific lookup strategy is as follows: Using the connected component coordinates as the center, and a 3×3 matrix as the filtering range, the LUT result table is searched. When the matrix pixel count is 2 or 4, after outputting the result in the LUT lookup table, the coordinates of the positioning result are shifted left or right based on whether the generated random number is greater than 0.5. When the matrix pixel count is 3 or 5, the corresponding electron count positioning result, i.e., the centroid result in the LUT, is directly searched in the LUT result table. Assume there is a compact four-pixel square located in the upper left corner of the window, forming a 2×2 pixel cluster. If the pixel count is 4, random numbers are generated. Assuming the generated random number is 0.3, which is less than the threshold of 0.5, the original coordinates provided by the lookup table are directly applied to output the result.
[0090] When the number of pixels in the matrix is greater than 6, the source data is used without any processing.
[0091] 6. Result Image Sequence Output Module
[0092] After finding the electron counting localization result corresponding to the binary window pixel pattern, the algorithm overlays the processing window at the centroid coordinates. That is, the precise center point of each signal block has been calculated in the previous steps, and a fixed-size matrix region is determined based on this center point. Finally, the algorithm directly fills the predefined lookup table matrix result into this window region, completely covering the original pixel data in the region, which may contain noise or irregularities. Then, the electron counting localization result matrix directly overwrites the source data, sets all result pixel values to 1, and outputs the result image sequence.
[0093] The following is a specific embodiment of the present invention. Assume the algorithm identifies a signal and calculates its centroid to be located at coordinates (10, 10) in the image. In the original image, the matrix within the 3×3 window containing the centroid (10, 10) is:
[0094] [0,255,255];
[0095] [0, 0,255];
[0096] [0, 0, 0].
[0097] The algorithm inputs the matrix into a lookup table and finds the corresponding output result. The result in the lookup table is as follows:
[0098] [0, 0,255];
[0099] [0, 0, 0];
[0100] [0, 0, 0].
[0101] After finding the result, the region from (9,9) to (11,11) in the source data at centroid (10,10) is directly overwritten with the result matrix of the lookup table. Simultaneously, all pixel values with a signal are set to 1 (for standardization). Therefore, the final matrix result at centroid (10,10) is as follows:
[0102] [0, 0, 1];
[0103] [0, 0, 0];
[0104] [0, 0, 0].
[0105] The source data mentioned in this invention refers to the original image matrix after preprocessing and binarization.
[0106] Example 2. Implementation of Fast Electron Counting on Medipix2 Data Using LUT Method
[0107] 1. Detection process: Based on the pre-generated result table of 512 patterns, the corresponding output pattern is found by using a hash table according to the white dot distribution pattern within a 3×3 window.
[0108] 2. Key parameters: white dot count classification threshold (2 or 4 points, 3 or 5 points, 6-9 points), 50% probability offset mechanism, pattern matching accuracy.
[0109] 3. Test results as follows Figure 3 , Figure 4 .
[0110] Figure 3 The result image is a single frame. Some obvious pixel clusters and larger connected components have not been processed. Apart from that, there are individual pixels that do not form connected components. Figure 4 The resulting image after overlaying all frames clearly shows some of the edges of the pins. Among them, some large, unprocessed pixel clusters with relatively high brightness can still be seen in the un-obscured pixels.
[0111] 4. Calculating SNR (Signal-to-Noise Ratio): SNR (Signal-to-Noise Ratio) is the ratio of signal to noise in an image. SNR calculation methods are based on the temporal characteristics of image sequences, evaluating image quality by separating signal and noise components. The core idea is to estimate the noise level using the differences between consecutive frames and estimate the signal strength through frame averaging. SNR values can objectively quantify the ability of various image processing algorithms to suppress noise while preserving effective signal, providing important quantitative basis for algorithm optimization and selection.
[0112] In this embodiment, the SNR calculation steps are as follows: (1) Noise component extraction: ① Calculate the absolute difference between adjacent frames of the original image sequence; ② Obtain N-1 frame difference image sequence (N is the total number of frames); ③ Average the difference image sequence over time to generate an average noise image; ④ Calculate the pixel mean of the average noise image as the noise baseline value. (2) Signal component extraction: ① Average the processed image sequence over time; ② Generate an average signal image; ③ Calculate the pixel mean of the average signal image as the signal reference value; (3) SNR calculation. Divide the signal reference value by the noise reference value to obtain the final SNR value.
[0113] Suppose we have a sequence of 3 images, each 2×2 pixels, used to demonstrate the SNR calculation process. The original image sequence records the detection of a weak signal, and the pixel values represent the detected signal strength.
[0114] For example, the original image sequence is as follows: • Frame 1: Pixel values [10, 12; 8, 11]; • Frame 2: Pixel values [11, 13; 9, 12]; • Frame 3: Pixel values [12, 14; 10, 13].
[0115] ① Noise component extraction Differential image sequence generation: • Difference 1 (Frame 2 - Frame 1): Absolute value is [1, 1; 1, 1]; • Difference 2 (Frame 3 - Frame 2): Absolute value is [1, 1; 1, 1].
[0116] The average of the two difference images is calculated over time. Average noise image = ([1,1;1,1] + [1,1;1,1]) ÷ 2 = [1,1;1,1].
[0117] Calculate the mean of all pixels in the average noisy image: Noise reference value = (1+1+1+1) ÷ 4 = 1.0.
[0118] ② Signal component extraction Suppose the image sequence after algorithm optimization is as follows: • Process frame 1: pixel values [15, 17; 13, 16]; • Process frame 2: pixel values [16, 18; 14, 17]; • Process frame 3: pixel values [17, 19; 15, 18].
[0119] The processed image sequence is averaged over time. Average signal image = ([15,17;13,16] + [16,18;14,17] + [17,19;15,18]) ÷ 3.
[0120] Calculation result = [16,18;14,17] Calculate the mean value of all pixels in the average signal image: Signal reference value = (16+18+14+17) ÷ 4 = 16.25.
[0121] ③ Calculation of signal-to-noise ratio results Divide the signal reference value by the noise reference value: SNR = 16.25 ÷ 1.0 = 16.25.
[0122] Comparative Examples Other common electron counting algorithms include the centroid algorithm, the random selection method, and the maximum value method: 1. Center of mass method Input image data such as Figure 5 ; Detection process: A 3×3 window is cropped with each centroid coordinate as the center, the geometric center position of all white points within the window is calculated, and only the center point is retained in the output image; Key parameters: window size 3×3, centroid coordinates are the processing anchor point, output is a single point marker; Test results as follows Figure 6 , Figure 7 .
[0123] Figure 6 This is the result image for a single frame. The image contains no clusters of pixels; all connected components are individual pixels. Partial pin shapes can be observed.
[0124] Figure 7 This is the result image after all frames are superimposed. The edges of some of the pins are clearly visible, with the unobstructed pixels appearing relatively neat.
[0125] 2. Random selection method Input image data such as Figure 5 ; Detection process: Within a 3×3 window of each centroid, a white dot position is randomly selected as the representative point for output; Key parameters: uniform random distribution, with equal probability selection of effective points within the window; Test results as follows Figure 8 , Figure 9 .
[0126] Figure 8 This is the result image for a single frame. The image contains no clusters of pixels; all connected components are individual pixels. Partial pin shapes can be observed.
[0127] Figure 9 This is the result of overlaying all frames. The edges of some of the pins are clearly visible, with the unobstructed pixels appearing relatively disordered.
[0128] 3. Maximum value method Input image data such as Figure 5 ; Detection process: Locate the position of the pixel intensity maximum within the centroid window, and retain only the strongest signal point; Key parameters: Intensity comparison criteria, first occurrence principle (take the first when multiple values have the same maximum value); Test results as follows Figure 10 , Figure 11 .
[0129] Figure 10 This is the result image for a single frame. The image contains no clusters of pixels; all connected components are individual pixels. Partial pin shapes can be observed. Figure 11 This is the result after overlaying all frames. The edges of some of the bobbin tips are clearly visible.
[0130] The operating speed, SNR (signal-to-noise ratio), and other common electronic counting algorithm results of various technical solutions are compared in Table 1 below:
[0131] Table 1. Comparison of running time and SNR of four different methods for electronic counting
[0132] Center of mass 0.0285 0.141280 LUT 0.0065 0.186003 Random selection 0.0035 0.141278 Maximum value 0.0098 0.141280
[0133] Technical performance evaluation: Compared with traditional centroid, random selection and maximum value algorithms, LUT not only obtains the best image signal-to-noise ratio results, but also significantly shortens the data processing time compared with the centroid method widely used in the industry, improving its processing speed by 4.4 times.
Claims
1. A method for fast electron counting of 2D data from an electronic detector Medipix2 by LUT method, characterized in that, The method includes the following steps: S11. Pre-calculate the centroid localization result table of pixel clusters in a 3×3 matrix binary image, and obtain the centroid localization result table of 512 pixel combination patterns; S12. The centroid positioning result table is built into memory; S13. Collect experimental image data; S14. Preprocess the image data; S15. The matrix filter traverses the image data and calculates the centroid location of each effective pixel cluster of the 3×3 matrix; S16. Locate the centroid positioning results table and overwrite the source data; S17. Output the resulting image.
2. The method according to claim 1, characterized in that, The centroid positioning strategy for the 512 pixel combination modes described in S11 is as follows: (1) All Black Mode: Outputs all black when there are no white dots; (2) Single-point mode: When there is only one white dot, the original position is retained; (3) Centroid mode: Calculate the centroid and retain only the centroid position when there are 2-9 white points; (4) Dense mode: Keep the original state when there are too many white spots.
3. The method according to claim 2, characterized in that, The centroid coordinate algorithm of the centroid mode is: in each connected domain in a two-dimensional image, assuming that the area contains N valid pixel points, the coordinates of each pixel point are (x i , y i ), wherein i=1,2,...,N, The x-coordinate of the centroid is: , The ordinate of the centroid is: .
4. The method according to claim 1, characterized in that, The experimental image data mentioned in S13 refers to the data collected by the Medipix hybrid pixel detector.
5. The method according to claim 1, characterized in that, The preprocessing of image data in S14 includes defect pixel removal and image data binarization.
6. The method according to claim 1, characterized in that, The centroid positioning described in S15 includes: S61. Centroid Coordinate Calculation: Calculate the centroid coordinates of the effective pixel clusters in each connected component; S62. Window Extraction: Extract a matrix window of the corresponding size centered on each centroid coordinate to obtain a binary window pixel pattern.
7. The method according to claim 1, characterized in that, The search strategy for finding the centroid positioning result table in S16 is as follows: convert the binary pixel sequence in the window into a byte stream, use the connected component positioning coordinates as the center, and a 3×3 matrix as the filtering range to search the LUT result table: when the number of matrix pixels is 2 or 4, after outputting the result in the LUT lookup table, select the positioning result coordinates to shift left or right based on whether the generated random number is greater than 0.5; when the number of matrix pixels is 3 or 5, directly search the LUT result table and output the corresponding electronic counting positioning result.
8. The method according to claim 1, characterized in that, The process for overwriting source data in S16 is as follows: S81 coordinate mapping: The processing window uses the centroid as the anchor point to map the coordinates of the centroid center of the output connected region to the corresponding position in the output image. For overlapping regions, subsequent processing overwrites previous results to ensure that each connected region is processed independently. S82 pixel assignment: Writes the processing result into the corresponding area of the output image; S83 value range unification: ultimately unifies all valid pixels to a single intensity value of 1; S84 generates an output image of the same size as the input, where pixel values represent the optimized signal locations.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the method for rapid electron counting of 2D data of the electron detector Medipix2 using the LUT method as described in any one of claims 1-8.
10. An electronic device, characterized in that, The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the method for rapid electron counting of 2D data of the electron detector Medipix2 using the LUT method as described in any one of claims 1-8.