Sampling method of focusing field of view and related equipment
By using effective pixel points of a panoramic image for clustering processing in the focus field sampling method, the target clustering center is determined as the field sampling point, which solves the problems of poor adaptability and low sampling efficiency in the prior art, and achieves efficient and accurate field sampling.
Patent Information
- Application Number
- CN202510013675.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-05
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2045-01-05
AI Technical Summary
In the prior art, the sampling method of the focus field of view is difficult to be applied to photographing objects of different image shapes, and there are problems such as poor adaptability, complex sampling method, low sampling efficiency and poor sampling accuracy.
By obtaining the panoramic image of the target object, filtering effective pixel points based on preset pixel thresholds, building a cluster data set, and using the clustering algorithm to determine the target cluster center as the field of view sampling point, and determining the focus height of the field of view sampling point.
A universal field sampling method suitable for different image shapes is realized, which significantly reduces the complexity of field sampling and improves the efficiency and accuracy of field sampling.
Smart Images

Figure CN119421055B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of field of view processing technology, and in particular to a sampling method for a focused field of view and related equipment. Background Art
[0002] Since the field of view of an electron microscope is limited, a single shot can only cover a small part of the object. Therefore, the entire object needs to be divided into multiple fields of view, each of which needs to be photographed separately, and then the images of these fields of view are stitched together into a complete scanned image. However, since there are many fields of view, it is not only time-consuming but also inefficient to accurately focus on each field of view separately. Therefore, the usual operation is to sample a certain number of fields of view from all fields of view for focus, obtain the focus height of these fields of view, and then use the fitting method to estimate the focus height of other fields of view.
[0003] In the sampling method of the focused field of view provided in the related art, if the image corresponding to the photographed object is a regular image, a regular dotting method is generally used directly (sampling a certain number of fields of view is called sampling of the focused field of view, also known as dotting); if the image corresponding to the photographed object is an irregular image, the panoramic image is generally first identified to find different connected areas, and then the image is divided according to the contour area, position distribution, etc. of each connected area to obtain multiple area blocks, and the center point of each area block is determined as the field of view sampling point. The sampling method of the focused field of view provided in the related art is difficult to be applied to photographed objects of different image shapes at the same time, has poor adaptability, and is not universal. In addition, the method provided by the related art has the problems of complex sampling method, low sampling efficiency, and poor sampling accuracy.
[0004] With respect to the above-mentioned problems in the related technologies, no effective solutions have been proposed yet. Summary of the invention
[0005] The sampling method for the focused field of view and the related equipment provided by the embodiments of the present invention at least solve the problems that the sampling method in the related art has poor adaptability and is difficult to apply to photographing objects of different image shapes, and has the problems of complex sampling methods, low sampling efficiency and poor sampling accuracy.
[0006] In order to solve the above problem, one aspect of an embodiment of the present invention provides a method for sampling a focus field of view, including:
[0007] Obtain a panoramic image of the target object, filter multiple valid pixel points from the panoramic image based on a preset pixel threshold, and construct a clustering data set; wherein the elements in the clustering data set are pixel positions corresponding to the valid pixel points;
[0008] Select clustering pixels that meet the target field of view sampling quantity from multiple valid pixels, use the pixel positions corresponding to the clustering pixels as the initial clustering centers, and perform clustering processing on each element in the clustering data set based on the clustering algorithm to determine the target clustering center;
[0009] The pixel point corresponding to the target cluster center is determined as the field of view sampling point, and the focus height of the field of view sampling point is determined.
[0010] In some of the embodiments, before the step of selecting clustered pixel points satisfying the target field of view sampling quantity from a plurality of valid pixel points, the method further comprises:
[0011] A target pixel point that satisfies the preset number of data set elements is randomly sampled from multiple valid pixel points, the target pixel point is used as the updated valid pixel value, and the pixel position corresponding to the target pixel point is used as the element in the clustering data set.
[0012] In some embodiments, the step of taking the pixel position corresponding to the cluster pixel point as the initial cluster center and performing clustering processing on each element in the cluster data set based on the clustering algorithm to determine the target cluster center includes:
[0013] For each element in the clustered data set, the distance between the element and each initial cluster center is calculated, and the element is assigned to the initial cluster center closest to it to obtain multiple intermediate clusters;
[0014] Determine the actual cluster centers of multiple intermediate clusters, and determine the center point distance between the actual cluster centers and the initial cluster centers, and determine whether to continue iterative calculation according to the center point distance and the center point distance threshold;
[0015] If the center point distance between the current actual cluster center and the cluster center in the previous iterative calculation is less than or equal to the center point distance threshold, the iterative calculation is stopped and the current actual cluster center is determined as the target cluster center.
[0016] In some of these embodiments, the method further comprises:
[0017] Get the iterative calculation times threshold. If the current iterative calculation times meets the iterative calculation times threshold, stop the iterative calculation and determine the current actual cluster center as the target cluster center.
[0018] In some of the embodiments, the step of determining actual cluster centers of the plurality of intermediate clusters includes:
[0019] Calculate the mean pixel position corresponding to all elements in each intermediate cluster, and use the mean pixel position as the actual clustering center of the intermediate cluster.
[0020] In some of these embodiments, the method further comprises:
[0021] The magnification of the shooting device corresponding to the panoramic image is obtained, and the number of target field of view samples is determined according to the magnification; wherein the number of target field of view samples does not exceed the square root of the total number of fields of view corresponding to the panoramic image.
[0022] In some embodiments, the pixel point corresponding to the target cluster center is determined as a field of view sampling point, and the step of determining the focus height of the field of view sampling point includes:
[0023] Determine whether there is a valid pixel point at the position corresponding to the target cluster center;
[0024] If it exists, the valid pixel point is used as the field of view sampling point; if it does not exist, the element closest to the target cluster center is found in the target cluster to which the target cluster center belongs, and the valid pixel point corresponding to the element is used as the field of view sampling point.
[0025] In some embodiments, the step of selecting a plurality of valid pixels from the panoramic image based on a preset pixel threshold further includes:
[0026] Binarize the panoramic image to obtain a binary image;
[0027] Determine the pixels with pixel values of 0 or 255 in the binary image as valid pixels.
[0028] In order to solve the above problem, one aspect of an embodiment of the present invention provides a sampling device for a focus field of view, comprising:
[0029] A data processing module is used to obtain a panoramic image of the target object, filter multiple valid pixel points from the panoramic image based on a preset pixel threshold, and construct a cluster data set; wherein the elements in the cluster data set are pixel positions corresponding to the valid pixel points;
[0030] A clustering module is used to select clustering pixels that meet the target field of view sampling quantity from multiple valid pixels, use the pixel positions corresponding to the clustering pixels as the initial clustering centers, and perform clustering processing on each element in the clustering data set based on the clustering algorithm to determine the target clustering center;
[0031] The field of view sampling point determination module is used to determine the pixel point corresponding to the target cluster center as the field of view sampling point and determine the focus height of the field of view sampling point.
[0032] In order to solve the above-mentioned problem, one aspect of an embodiment of the present invention provides an electronic device, including: a processor, and a memory storing a program, wherein the program includes instructions, and when the instructions are executed by the processor, the processor executes any of the above-mentioned sampling methods for the focus field of view.
[0033] In order to solve the above problem, one aspect of an embodiment of the present invention provides a non-transitory machine-readable medium storing computer instructions, where the computer instructions are used to enable a computer to execute any of the above-mentioned methods for sampling a focus field of view.
[0034] Beneficial effects of the embodiments of the present invention: by acquiring a panoramic image of a target object, a plurality of valid pixel points are screened from the panoramic image based on a preset pixel threshold, and a clustering data set is constructed; wherein the elements in the clustering data set are pixel positions corresponding to the valid pixel points; clustering pixel points that meet the target field of view sampling quantity are selected from the plurality of valid pixel points, the pixel positions corresponding to the clustering pixel points are used as the initial clustering centers, and clustering processing is performed on each element in the clustering data set based on a clustering algorithm to determine the target clustering center; the pixel point corresponding to the target clustering center is determined as the field of view sampling point, and the focus height of the field of view sampling point is determined The method overcomes the problems that the sampling method in the related art is difficult to apply to photographed objects of different image shapes, and has the problems of complex sampling methods, low sampling efficiency and poor sampling accuracy. It realizes the screening of effective pixel points from the panoramic image of the target object, and then directly performs clustering processing based on the pixel positions of the effective pixel points, so as to obtain the pixel points corresponding to the target clustering center as the field of view sampling points, and provides a universal field of view sampling method applicable to different image shapes, achieves the technical effect of expanding the applicable scenarios of the field of view sampling method, significantly reducing the complexity of field of view sampling, and improving the efficiency and accuracy of field of view sampling.
[0035] The details of one or more embodiments of the invention are set forth in the following drawings and description so that other features, objects, and advantages of the invention are more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other embodiments can be obtained based on these drawings without creative work.
[0037] Figure 1 It is a main flow chart of a method for sampling a focused field of view according to an embodiment of the present invention.
[0038] Figure 2 It is a schematic diagram of a binary image obtained by binarizing a panoramic image according to an embodiment of the present invention.
[0039] Figure 3 It is a schematic diagram of clustering results after clustering based on binary images according to an embodiment of the present invention.
[0040] Figure 4 It is a schematic diagram of determining field of view sampling points for an image with a regular ROI area according to an embodiment of the present invention.
[0041] Figure 5 It is a schematic diagram of determining field of view sampling points for an image with an irregular ROI area according to an embodiment of the present invention.
[0042] Figure 6 It is a main framework schematic diagram of a sampling device for a focused field of view according to an embodiment of the present invention.
[0043] Figure 7 It is a schematic structural diagram of the electronic device of the present invention. DETAILED DESCRIPTION
[0044] Embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments of the present invention are only for exemplary purposes and are not intended to limit the scope of protection of the present invention.
[0045] Pathological slice scanning is an important medical diagnostic technology. By taking pictures of case slices through an electron microscope, the fine structure of cells and tissues can be observed, thereby diagnosing diseases. However, due to the limited field of view of the electron microscope, a single shot can only cover a small part of the slice, so the entire slice needs to be divided into multiple fields of view, each of which is photographed separately, and finally the pictures of these fields of view are stitched into a complete scanned image. In the process of microscopic photography, focusing is a very important step. Poor focus will cause blurred images and affect the accuracy of diagnosis. However, since the surface of each field of view may not be completely flat, the focus height of different fields of view may be different. Pathological slices usually contain hundreds or thousands of fields of view. If each field of view is accurately focused separately, it will not only take a long time, but also be inefficient. Therefore, the usual operation is to sample a certain number of fields of view from all fields of view for focus, obtain the focus height of these fields of view, and then use the fitting method to estimate the focus height of other fields of view.
[0046] In the related art, the sampling method for the focused field of view of regular images, especially for images with regular ROI (Region of Interesting), usually adopts a regular sampling method. However, due to the characteristics of the photographed object and the influence of the sample placement, regular images / regular areas rarely appear in actual scenes. As for the sampling method for irregular images, the related art generally first identifies the panoramic image, finds different connected areas, and then divides the image according to the contour area and position of each connected area to obtain multiple area blocks, and determines the center point of each area block as the field of view sampling point. However, since this method needs to consider many factors, for example, in the process of re-dividing multiple irregular connected areas into area blocks with the sampling number, it is necessary to combine the area size, contour, position distribution and other factors of each connected area to obtain multiple representative area blocks, which makes it difficult to achieve accurate and fast field of view sampling. In summary, the sampling method for the focused field of view provided in the related art is difficult to be applied to photographed objects of different image shapes at the same time, has poor adaptability, and is not universal. In addition, the method provided by the related art has the problems of complex sampling method, low sampling efficiency and poor sampling accuracy.
[0047] In order to solve the above problems, an embodiment of the present invention provides a method for sampling a focus field of view, such as Figure 1 As shown, the sampling method of the focus field mainly includes:
[0048] Step S101, obtaining a panoramic image of the target object, screening multiple valid pixels from the panoramic image based on a preset pixel threshold, and constructing a cluster data set; wherein the elements in the cluster data set are pixel positions corresponding to the valid pixels.
[0049] Among them, the target objects provided by the embodiments of the present invention are mainly pathological sections. In the process of taking pictures of pathological sections by electron microscope, due to the limited field of view of the electron microscope, a single picture can only cover a small part of the slice, so the whole slice needs to be divided into multiple fields of view. However, if each field of view is accurately focused separately, it is not only time-consuming but also inefficient. Therefore, a certain number of fields of view are sampled from all fields of view for focusing (i.e., sampling for the focused fields of view), the focusing heights of these fields of view are obtained, and then the focusing heights of other fields of view are estimated using the fitting method.
[0050] According to a specific implementation of an embodiment of the present invention, a panoramic image of the entire pathological slice can be captured by a low-resolution shooting device, so as to quickly obtain overview information of the entire slice sample. Then, effective pixels are directly screened out from the grayscale image corresponding to the panoramic image by a preset pixel threshold, so as to effectively remove background noise and other non-interested areas in the panoramic image, and ensure the accuracy of subsequent processing. Through the above settings, the use of a low-resolution shooting device here can significantly reduce the amount of data and speed up the processing speed without affecting the accuracy of subsequent sampling of the focused field of view. At the same time, the above-mentioned preset pixel threshold can be flexibly set, for example, adjusted according to the characteristics of the image or experimental requirements, so as to better adapt to different types of samples and application scenarios. At the same time, the adjustability of the preset pixel threshold enables this step to adapt to different types of samples and application scenarios, enhancing the versatility and adaptability of the method.
[0051] In some of the embodiments, the method further includes: obtaining a magnification of a shooting device corresponding to the panoramic image, and determining a target field of view sampling number based on the magnification; wherein the target field of view sampling number does not exceed the square root of a total field of view number corresponding to the panoramic image.
[0052] Because shooting equipment with different magnifications (such as microscopes and cameras) have different focal depths and field sizes. Specifically, high-magnification microscopes have a smaller focal depth and require more focused fields of view to ensure the clarity of the entire image area; low-magnification microscopes have a larger focal depth, and the number of focused fields of view can be reduced accordingly. By dynamically adjusting the number of target field of view samples according to the magnification of the microscope, it not only helps to ensure that the subsequently determined field of view sampling points are representative, but also avoids excessive focused fields of view leading to increased processing time and possible data redundancy and waste of computing resources. By reasonably determining the number of target field of view samples, it helps to improve the overall processing efficiency. In addition, different application scenarios may require different numbers of focused fields of view. By dynamically adjusting the number of target field of view samples according to the magnification of the microscope, it can ensure that the subsequent clustering algorithm can show good robustness in different scenarios, and can also avoid the overfitting phenomenon of the clustering algorithm.
[0053] In some of the embodiments, the step of screening out multiple valid pixel points from the panoramic image based on a preset pixel threshold also includes: binarizing the panoramic image to obtain a binary image; and determining that the pixel points with pixel values of 0 or 255 in the binary image are valid pixel points.
[0054] It should be noted that the binarization process provided in the embodiment of the present invention is a process of converting a grayscale image into a binary image. The binarization process can be implemented in a variety of ways. On the one hand, we can directly use the threshold-based binarization method, such as the global threshold method (using a fixed threshold to segment the image), the adaptive threshold method (dynamically adjusting the threshold according to the characteristics of the local area of the image (such as using the average value or Gaussian weighted average value of the local area as the threshold), and then converting each pixel in the image to 0 (black) or 255 (white) according to the fixed threshold or adaptive threshold to obtain a binary image. On the other hand, we can also use a binarization algorithm to achieve binarization processing, such as: Otsu's method (a method for automatically determining the optimal threshold, which finds the optimal threshold by maximizing the inter-class variance), Canny edge detection (a multi-stage edge detection algorithm that can detect the edges in the image and convert it into a binary image), watershed algorithm (a morphological-based image segmentation method that can divide the image into multiple regions and convert these regions into binary images), etc. However, since different binarization processing schemes are suitable for different scenarios and needs, we can select a suitable binarization processing method according to the specific application scenario and image characteristics to determine the effective pixels.
[0055] Through the above settings, the amount of image data after binarization is significantly reduced, which reduces the amount of calculation and storage requirements and speeds up the processing speed. In addition, binarization can enhance the algorithm's anti-interference ability and reduce misjudgments caused by factors such as lighting changes and imaging quality. Then, by setting a suitable preset pixel threshold, it can ensure that effective pixels can be stably identified under different conditions.
[0056] Step S102, clustering pixels that meet the target field of view sampling quantity are selected from multiple valid pixels, the pixel positions corresponding to the clustering pixels are used as initial clustering centers, and each element in the clustering data set is clustered based on a clustering algorithm to determine the target clustering center.
[0057] Among them, the clustered pixel points provided in the embodiment of the present invention must first meet the requirement that the number is consistent with the target field of view sampling number (it can be understood that the number of initial clustering centers can be dynamically adjusted according to the target field of view sampling number to adapt to the needs of different scenes and ensure the robustness of the clustering algorithm), and secondly, the clustered pixel points are randomly selected from multiple valid pixel points.
[0058] According to a specific implementation of an embodiment of the present invention, it is also possible to determine the ROI area corresponding to multiple valid pixel points, and select distance pixel points that meet the target field of view sampling quantity and are distributed as evenly as possible from the ROI area. This helps to improve the initial accuracy of clustering and improve the accuracy of the final clustering results. The evenly distributed initial clustering centers help to better cover the entire ROI area, which can reduce the risk of the clustering algorithm falling into a local optimal solution and increase the possibility of finding a global optimal solution.
[0059] In some of the embodiments, before the step of selecting clustered pixel points that meet the target field of view sampling quantity from multiple valid pixel points, the method further includes: randomly sampling target pixel points that meet the preset number of data set elements from multiple valid pixel points, using the target pixel points as the updated valid pixel values, and using the pixel positions corresponding to the target pixel points as the elements in the clustered data set.
[0060] By randomly sampling from multiple valid pixels to obtain target pixels that meet the preset number of data set elements, the size of the clustering data set can be significantly reduced, which helps to reduce the computational complexity of the clustering algorithm and improve the efficiency of clustering processing.
[0061] Among them, the operation of randomly sampling the target pixel from multiple valid pixels can, on the one hand, reduce the impact of noise points on the clustering results. Even if there are some abnormal points or noise points in the original clustering data set, the probability of these points being selected will be reduced through random sampling, thereby improving the robustness of the clustering results. On the other hand, it can ensure that the elements in the clustering data set are evenly distributed in space. Even if the valid pixels in the original clustering data set are unevenly distributed, random sampling can balance this unevenness to a certain extent and improve the adaptability of the clustering algorithm.
[0062] In some of the embodiments, the above-mentioned step of using the pixel position corresponding to the cluster pixel point as the initial cluster center and clustering each element in the cluster data set based on the clustering algorithm to determine the target cluster center includes: for each element in the cluster data set, calculating the distance between the element and each initial cluster center, and assigning the element to the initial cluster center closest to obtain multiple intermediate clusters; determining the actual cluster centers of the multiple intermediate clusters, and determining the center point distance between the actual cluster center and the initial cluster center, and judging whether to continue the iterative calculation based on the center point distance and the center point distance threshold; if the center point distance between the current actual cluster center and the cluster center in the previous iterative calculation is less than or equal to the center point distance threshold, stopping the iterative calculation, and determining the current actual cluster center as the target cluster center.
[0063] The embodiment of the present invention provides a method for using the pixel positions of pixel points in an image as clustering elements, and adopts a K-means algorithm to perform specific clustering operations. By gradually optimizing the cluster centers and setting iteration termination conditions, unnecessary calculation amounts can be significantly reduced, thereby improving the overall efficiency of the algorithm. Reasonable iteration termination conditions are set to accelerate the convergence speed of the algorithm, shorten the processing time, and improve the field of view sampling efficiency.
[0064] According to a specific implementation of an embodiment of the present invention, by calculating the distance between each element in the clustering data set and each initial cluster center, and assigning the element to the initial cluster center with the closest distance, it can be ensured that each element is assigned to the most suitable cluster, thereby improving the accuracy of clustering; in each iteration, the actual cluster center of the intermediate cluster is recalculated and compared with the initial cluster center to ensure continuous optimization of the cluster center and gradually approach the optimal solution. By setting a center point spacing threshold, it can be ensured that the algorithm stops iterating after a certain accuracy requirement is met. When the center point spacing between the current actual cluster center and the cluster center calculated in the previous iteration is less than or equal to the center point spacing threshold, the algorithm stops iterating to prevent the algorithm from falling into overfitting and ensure that the clustering results have good generalization ability.
[0065] In some of the embodiments, the method further includes: obtaining an iterative calculation times threshold, and if the current iterative calculation times satisfies the iterative calculation times threshold, stopping the iterative calculation, and determining the current actual cluster center as the target cluster center.
[0066] By setting the iterative calculation number threshold, you can ensure that the algorithm terminates after reaching the maximum number of iterations, prevent infinite loops caused by certain reasons, and improve the stability of the algorithm. The iteration number threshold can be used as a bottom-line constraint to ensure that the algorithm completes the calculation within the predetermined time, avoid unnecessary waste of computing resources, prevent the algorithm from overfitting on certain clustering data sets, and ensure that the clustering results have good generalization capabilities.
[0067] According to a specific implementation of an embodiment of the present invention, since the k-means algorithm adopts a greedy strategy in the iteration process, each step attempts to find the current optimal solution. However, this strategy may cause the algorithm to fall into a local optimal solution and fail to reach the global optimal solution. In order to overcome this problem, you can try to use different initial clustering centers (that is, multiple random samplings are performed from multiple valid pixels to obtain multiple batches of clustered pixel points, and the pixel positions corresponding to the multiple batches of clustered pixel points are used as the initial clustering centers of the multiple batches) for multiple runs, or combine other optimization algorithms to improve the performance of the k-means algorithm.
[0068] In some of the embodiments, the step of determining the actual cluster centers of the plurality of intermediate clusters includes: calculating the mean pixel position corresponding to all elements in each intermediate cluster, and using the mean pixel position as the actual cluster center of the intermediate cluster.
[0069] By calculating the mean of the pixel positions corresponding to all elements in each intermediate cluster, it can be ensured that the cluster center of each cluster is a stable point, ensuring the stability and reliability of the cluster center and reducing fluctuations. At the same time, the mean calculation method can ensure that the cluster center represents the average position of all elements in the cluster, which is highly representative. This representativeness makes the clustering results more accurate and can better reflect the true distribution of the data. The mean calculation method is simple and easy, reduces the computational complexity, improves the execution efficiency of the algorithm, and is easy to understand and implement; and the mean calculation method can also effectively reduce the impact of noise points, adapt to different data distributions, and improve the robustness and stability of the algorithm.
[0070] Step S103, determining the pixel point corresponding to the target cluster center as the field of view sampling point, and determining the focus height of the field of view sampling point.
[0071] Based on the target cluster center determined in the above steps, which is a representative pixel position in the ROI area corresponding to the panoramic image, the pixel corresponding to the target cluster center is directly used as the field of view sampling point, and then the focus height of the field of view sampling point is determined, which can more accurately reflect the focus requirements of the entire ROI area, thereby improving the focus accuracy. Having representative field of view sampling points can ensure the comprehensiveness and effectiveness of the focus strategy, reduce the amount of calculation and processing time, and improve the field of view focusing speed, thereby improving the efficiency and accuracy of pathological slice scanning.
[0072] In some of the embodiments, the pixel point corresponding to the target cluster center is determined as the field of view sampling point, and the step of determining the focus height of the field of view sampling point includes: judging whether there is a valid pixel point at the position corresponding to the target cluster center; if so, using the valid pixel point as the field of view sampling point; if not, searching for the element closest to the target cluster center in the target cluster to which the target cluster center belongs, and using the valid pixel point corresponding to the element as the field of view sampling point.
[0073] If there is no pixel point at the position corresponding to the target cluster center, by finding the element closest to the target cluster center, it can be ensured that the field of view sampling point is still representative and the focus error caused by the hole can be reduced.
[0074] Through the above settings, the optimized target cluster center (i.e., the center of the focus field) is a valid pixel point, which can improve the focus accuracy, avoid focusing on background noise or unimportant areas, and reduce the focus error caused by selecting invalid pixels (relative to valid pixels). At the same time, the optimized target cluster center is a valid pixel point, which also ensures that there must be an ROI area in the focus field, so that the subsequent focus process can lock the effective focus area more quickly and improve the focus efficiency. By accurately focusing on representative field of view sampling points, more detail information can be retained, ensuring the clarity and detail richness of the image, and obtaining clearer and higher-quality images to enhance the user's visual experience.
[0075] The above-mentioned sampling method of the focused field of view provided by the embodiment of the present invention obtains a panoramic image of the target object, screens multiple valid pixel points from the panoramic image based on a preset pixel threshold, and constructs a clustering data set; wherein the elements in the clustering data set are pixel positions corresponding to the valid pixel points; clustering pixel points that meet the target field of view sampling quantity are selected from the multiple valid pixel points, and the pixel positions corresponding to the clustering pixel points are used as initial clustering centers, and clustering processing is performed on each element in the clustering data set based on a clustering algorithm to determine the target clustering center; the pixel point corresponding to the target clustering center is determined as the field of view sampling point, and the pixel point corresponding to the target clustering center is determined. The technical means of determining the focus height of the field of view sampling point overcomes the problems in related technologies that the sampling method is difficult to apply to photographed objects of different image shapes, and the sampling method is complex, the sampling efficiency is low, and the sampling accuracy is poor. It realizes the screening of effective pixel points from the panoramic image of the target object, and then directly performs clustering processing based on the pixel positions of the effective pixel points, so that the pixel points corresponding to the obtained target clustering centers are used as the field of view sampling points. The field of view sampling method suitable for different image shapes achieves the technical effect of expanding the applicable scenarios of the field of view sampling method, significantly reducing the complexity of field of view sampling, and improving the efficiency and accuracy of field of view sampling.
[0076] The embodiment of the present invention further provides a sampling method of the focused field of view, which is applied to the sampling scenario of the focused field of view of pathological slices with regular ROI areas and irregular ROI areas. Optionally, the sampling method provided by the embodiment of the present invention mainly includes:
[0077] 1. Determine the pixel positions of valid pixels and sample the valid pixels to obtain a clustering data set.
[0078] 1. Screen valid pixels. Obtain a panoramic image of the pathological section and perform binarization on the panoramic image. It can be determined that the pixels with a pixel value of 0 in the binary image are valid pixels, that is, all the pixels in the ROI area are valid pixels, that is, the total number of valid pixels screened is n.
[0079] 2. Extract the pixel positions of valid pixels and obtain a pixel position set recorded as: ,in, is the position vector of the effective pixel point, are the pixel positions of the ith valid pixel in the image, that is, the index values of the row and column where the valid pixel is located in the image matrix, and n is the total number of valid pixels.
[0080] 3. Sample valid pixels to obtain a set of sampled locations (i.e., the above clustering data set): , the number of samples is m, which is a configurable parameter, for example, the number of samples is set to 1000. Since clustering the pixel positions of all valid pixels requires a large amount of computing resources and affects the low clustering efficiency, it is not necessary to cluster all valid pixels, but only to sample part of them. In the process of sampling the clustered data set from all valid pixels, the sampling is performed randomly. It can be understood that the ROI area corresponding to the cluster elements relative to the valid pixels obtained after sampling only reduces the pixel density inside the ROI area, and does not affect the outline of the ROI area, so it does not affect the final clustering effect.
[0081] Second, the clustering data set obtained after sampling (the elements in the clustering data set are the pixel positions of m valid pixels) is clustered using the k-means algorithm, and each target cluster center point obtained is the field of view sampling point. The specific steps include:
[0082] (1) Set the number of target field of view samples k. The number of focused fields of view is determined by the magnification of the shooting device (such as an electron microscope); the higher the magnification, the smaller the focal depth, the higher the required focusing accuracy, the greater the number of fields of view, and the greater the number of focused fields of view. For example, for a 10x scope, 9 sampling points can be set, that is, the number of target field of view samples is 9. According to long-term practical experience in clustering, the maximum value of k should not exceed the square root of the total number of fields of view N corresponding to the panoramic image, that is, .
[0083] (2) From the clustering data set (i.e., the position vectors of the valid pixels after the m groups are screened) and k groups of position vectors are randomly selected and named as the initial cluster centers.
[0084] (3) For clustering datasets For each element in , the distance from each element to each initial cluster center is calculated respectively, and each element is assigned to the initial cluster center closest to it to obtain multiple intermediate clusters.
[0085] Among them, the distance between each element and the initial cluster center can be expressed by Euclidean distance, which is expressed as:
[0086]
[0087] In the above formula, They are the coordinates of the two pixels whose distance is calculated, one of which is the pixel corresponding to the initial cluster center.
[0088] As shown in the following formula, each element in the clustering data set is assigned one by one to the cluster closest to it. is the middle cluster to which the ith element belongs, is the i-th element, is the jth intermediate cluster, for arrive The second-order norm of is the Euclidean distance.
[0089]
[0090] (4) After all elements in the clustering data set are assigned, the cluster centers corresponding to the k intermediate clusters are updated, that is, the actual cluster centers of the intermediate clusters are determined. The actual cluster center is defined as the mean pixel coordinates of all elements in the cluster.
[0091] (5) Compare the actual cluster center with the k cluster centers calculated last time. If the cluster center changes (the center point distance between the two cluster centers is greater than the center point distance threshold), go to step (3) above; otherwise, go to step (6).
[0092] (6) When all cluster centers no longer change or the current number of iterative calculations meets the iterative calculation threshold, the iterative calculation is stopped and the clustering results are output, and the current actual cluster center is determined as the target cluster center.
[0093] (7) Optimize the target cluster center to obtain the optimized target cluster center. Calculate the Euclidean distance of all elements of each target cluster center except the center. The effective pixel point corresponding to the element with the closest distance is the optimized target cluster center (i.e., the center of the focus field). Since the optimized target cluster center has effective pixels, it is ensured that there is a ROI area in the focus field.
[0094] In order to more intuitively illustrate the clustering results of the embodiment of the present invention, taking the irregular ROI image corresponding to the pathological section as an example, the clustering results are as follows: Figure 3 As shown in the figure, points of different shapes and colors represent different clusters. It can be seen that multiple clusters are finally formed by clustering, and the field of view where the cluster center point of each cluster is located is the field of view obtained by sampling. Figure 3It can also be seen that the sampled field of view is evenly distributed in the irregular ROI area. When the number of points is specified (i.e., the number of target field of view points is specified), the field of view points obtained by clustering the above scheme represent the entire ROI area well.
[0095] According to a specific implementation of an embodiment of the present invention, based on the above method, images with regular ROI regions (such as liquid-based cell scanning images, such as Figure 4 ), and images with irregular ROI areas (such as tissue scan images, such as Figure 5 ), Figure 4 , Figure 5 The blue dots in the figure are the determined field of view sampling points. It can be seen that the field of view adoption method provided in the embodiment of the present invention is applicable to different image shapes, that is, it has universality and adaptability, and the efficiency and accuracy of field of view sampling are high.
[0096] The above method has at least the following technical effects: 1. A field sampling design scheme based on the pixel position of effective pixels is adopted to cluster, avoiding the complex process of forward division of ROI area, and designing a method for automatic clustering division of ROI area. 2. The pixel position is used as the input of the clustering algorithm, instead of the pixel value as the input of the clustering algorithm in the traditional image processing scheme. 3. The effective pixels are sampled, which further improves the processing efficiency and reduces the amount of calculation without affecting the clustering effect.
[0097] Based on the above-mentioned method for sampling the focused field of view provided by the embodiment of the present invention, the embodiment of the present invention also provides a device for sampling the focused field of view, such as Figure 6 As shown, the sampling device 600 of the focus field includes:
[0098] The data processing module 601 is used to obtain a panoramic image of the target object, filter multiple valid pixels from the panoramic image based on a preset pixel threshold, and construct a cluster data set; wherein the elements in the cluster data set are pixel positions corresponding to valid pixels.
[0099] The preset pixel threshold can be flexibly set, for example, adjusted according to the characteristics of the image or experimental requirements, so as to better adapt to different types of samples and application scenarios. At the same time, the adjustability of the preset pixel threshold enables this step to adapt to different types of samples and application scenarios, thereby enhancing the versatility and adaptability of the method.
[0100] Through the above settings, the pixel positions of valid pixels that meet the preset pixel threshold are selected to construct a clustering data set as the input of the subsequent clustering algorithm, which helps to determine representative field of view sampling points through clustering processing, significantly reduces the complexity of field of view sampling, and improves the efficiency and accuracy of field of view sampling.
[0101] In some of the embodiments, the above-mentioned sampling device 600 for the focused field of view also includes a target field of view sampling number determination module, which is used to: obtain the magnification of the shooting device corresponding to the panoramic image, and determine the target field of view sampling number according to the magnification; wherein the target field of view sampling number does not exceed the square root of the total field of view number corresponding to the panoramic image.
[0102] By dynamically adjusting the number of target field of view samples according to the magnification of the shooting device, it helps to ensure that the field of view sampling points determined subsequently are representative, and also avoids excessive focus fields that increase processing time and possible data redundancy and waste of computing resources. By reasonably determining the number of target field of view samples, it helps to improve overall processing efficiency. In addition, different application scenarios may require different numbers of focus fields of view. By dynamically adjusting the number of target field of view samples according to the magnification of the shooting device, it can ensure that the subsequent clustering algorithm can show good robustness in different scenarios and avoid overfitting of the clustering algorithm.
[0103] In some of the embodiments, the data processing module 601 is further used to: perform binarization processing on the panoramic image to obtain a binary image; and determine that the pixels with a pixel value of 0 or 255 in the binary image are valid pixels.
[0104] Through the above settings, the amount of image data after binarization is significantly reduced, which reduces the amount of calculation and storage requirements and speeds up the processing speed. In addition, binarization can enhance the algorithm's anti-interference ability and reduce misjudgments caused by factors such as lighting changes and imaging quality. Then, by setting a suitable preset pixel threshold, it can ensure that effective pixels can be stably identified under different conditions.
[0105] The clustering module 602 is used to select clustering pixels that meet the target field of view sampling quantity from multiple valid pixels, use the pixel positions corresponding to the clustering pixels as the initial clustering centers, and perform clustering processing on each element in the clustering data set based on the clustering algorithm to determine the target clustering center.
[0106] Among them, the clustered pixel points provided in the embodiment of the present invention must first meet the requirement that the number is consistent with the target field of view sampling number (it can be understood that the number of initial clustering centers can be dynamically adjusted according to the target field of view sampling number to adapt to the needs of different scenes and ensure the robustness of the clustering algorithm), and secondly, the clustered pixel points are randomly selected from multiple valid pixel points.
[0107] According to a specific implementation of an embodiment of the present invention, it is also possible to determine the ROI area corresponding to multiple valid pixel points, and select distance pixel points that meet the target field of view sampling quantity and are distributed as evenly as possible from the ROI area. This helps to improve the initial accuracy of clustering and improve the accuracy of the final clustering results. The evenly distributed initial clustering centers help to better cover the entire ROI area, which can reduce the risk of the clustering algorithm falling into a local optimal solution and increase the possibility of finding a global optimal solution.
[0108] In some of the embodiments, the above-mentioned sampling device 600 for the focused field of view also includes a clustered data set updating module. Before the step of selecting clustered pixel points that meet the target field of view sampling quantity from multiple valid pixel points, the above-mentioned clustered data set updating module is used to: randomly sample from multiple valid pixel points to obtain target pixel points that meet the preset number of data set elements, use the target pixel points as the updated valid pixel values, and use the pixel positions corresponding to the target pixel points as the elements in the clustered data set.
[0109] By randomly sampling from multiple valid pixels to obtain target pixels that meet the preset number of data set elements, the size of the clustering data set can be significantly reduced, which helps to reduce the computational complexity of the clustering algorithm and improve the efficiency of clustering processing.
[0110] In some of the embodiments, the clustering module 602 is further used to: for each element in the clustering data set, calculate the distance between the element and each initial cluster center, and assign the element to the initial cluster center with the closest distance to obtain multiple intermediate clusters; determine the actual cluster centers of the multiple intermediate clusters, and determine the center point distance between the actual cluster centers and the initial cluster centers, and determine whether to continue the iterative calculation based on the center point distance and the center point distance threshold; if the center point distance between the current actual cluster center and the cluster center in the previous iterative calculation is less than or equal to the center point distance threshold, stop the iterative calculation, and determine the current actual cluster center as the target cluster center.
[0111] The embodiment of the present invention provides a method for using the pixel positions of pixel points in an image as clustering elements, and adopts a K-means algorithm to perform specific clustering operations. By gradually optimizing the cluster centers and setting iteration termination conditions, unnecessary calculation amounts can be significantly reduced, thereby improving the overall efficiency of the algorithm. Reasonable iteration termination conditions are set to accelerate the convergence speed of the algorithm, shorten the processing time, and improve the field of view sampling efficiency.
[0112] In some of the embodiments, the clustering module 602 is further used to: obtain an iterative calculation times threshold, and if the current iterative calculation times meets the iterative calculation times threshold, stop the iterative calculation and determine the current actual cluster center as the target cluster center.
[0113] By setting the iterative calculation number threshold, you can ensure that the algorithm terminates after reaching the maximum number of iterations, prevent infinite loops caused by certain reasons, and improve the stability of the algorithm. The iteration number threshold can be used as a bottom-line constraint to ensure that the algorithm completes the calculation within the predetermined time, avoid unnecessary waste of computing resources, prevent the algorithm from overfitting on certain clustering data sets, and ensure that the clustering results have good generalization capabilities.
[0114] In some of the embodiments, the clustering module 602 is further used to calculate the mean pixel position corresponding to all elements in each intermediate cluster, and use the mean pixel position as the actual cluster center of the intermediate cluster.
[0115] By calculating the mean of the pixel positions corresponding to all elements in each intermediate cluster, it can be ensured that the cluster center of each cluster is a stable point, ensuring the stability and reliability of the cluster center and reducing fluctuations. At the same time, the mean calculation method can ensure that the cluster center represents the average position of all elements in the cluster, which is highly representative. This representativeness makes the clustering results more accurate and can better reflect the true distribution of the data. The mean calculation method is simple and easy, reduces the computational complexity, improves the execution efficiency of the algorithm, and is easy to understand and implement; and the mean calculation method can also effectively reduce the impact of noise points, adapt to different data distributions, and improve the robustness and stability of the algorithm.
[0116] The field of view sampling point determination module 603 is used to determine the pixel point corresponding to the target cluster center as the field of view sampling point, and determine the focus height of the field of view sampling point.
[0117] Based on the target cluster center determined by the above module as the representative pixel position in the ROI area corresponding to the panoramic image, the pixel corresponding to the target cluster center is directly used as the field of view sampling point, and then the focus height of the field of view sampling point is determined, which can more accurately reflect the focus requirements of the entire ROI area, thereby improving the focus accuracy. Having representative field of view sampling points can ensure the comprehensiveness and effectiveness of the focus strategy, reduce the amount of calculation and processing time, and increase the field of view focusing speed, thereby improving the efficiency and accuracy of pathological slice scanning.
[0118] In some of the embodiments, the field of view sampling point determination module 603 is further used to: determine whether there is a valid pixel point at the position corresponding to the target cluster center; if so, use the valid pixel point as the field of view sampling point; if not, search for the element closest to the target cluster center in the target cluster to which the target cluster center belongs, and use the valid pixel point corresponding to the element as the field of view sampling point.
[0119] Through the above settings, the optimized target cluster center (i.e., the center of the focus field) is a valid pixel point, which can improve the focus accuracy, avoid focusing on background noise or unimportant areas, and reduce the focus error caused by selecting invalid pixels (relative to valid pixels). At the same time, the optimized target cluster center is a valid pixel point, which also ensures that there must be an ROI area in the focus field, so that the subsequent focus process can lock the effective focus area more quickly and improve the focus efficiency. By accurately focusing on representative field of view sampling points, more detail information can be retained, ensuring the clarity and detail richness of the image, and obtaining clearer and higher-quality images to enhance the user's visual experience.
[0120] The above-mentioned focused field of view sampling device provided by the embodiment of the present invention is used to obtain a panoramic image of the target object through a data processing module, and multiple valid pixel points are screened from the panoramic image based on a preset pixel threshold, and a clustering data set is constructed; wherein the elements in the clustering data set are the pixel positions corresponding to the valid pixel points; the clustering module is used to select clustering pixel points that meet the target field of view sampling quantity from multiple valid pixel points, and the pixel positions corresponding to the clustering pixel points are used as the initial clustering centers, and the elements in the clustering data set are clustered based on the clustering algorithm to determine the target clustering center; the field of view sampling point determination module is used to determine the pixel points corresponding to the target clustering center as the field of view sampling point, and determine the focus height of the field of view sampling point. It is realized that by screening the valid pixel points from the panoramic image of the target object, and then directly performing clustering processing based on the pixel positions of the valid pixel points, the pixel points corresponding to the obtained target clustering center are used as the field of view sampling points, and a universal field of view sampling method applicable to different image shapes is provided, which achieves the technical effect of expanding the applicable scenarios of the field of view sampling method, significantly reducing the complexity of field of view sampling, and improving the efficiency and accuracy of field of view sampling.
[0121] An embodiment of the present invention further provides a non-transitory machine-readable medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute the method of the embodiment of the present invention.
[0122] The embodiment of the present invention further provides a computer program product, including a computer program, wherein the computer program is used to make the computer perform the method of the embodiment of the present invention when executed by a processor of the computer. The computer program product should be understood as a software product that mainly implements the above method of the present application through a computer program.
[0123] An embodiment of the present invention further provides an electronic device, comprising: at least one processor; and a memory in communication with the at least one processor. The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the electronic device executes the method of the embodiment of the present invention.
[0124] like Figure 7 As shown, the electronic device includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 to a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0125] Multiple components in the electronic device are connected to the I / O interface 705, including: an input unit 706, an output unit 707, a storage unit 708, and a communication unit 709. The input unit 706 can be any type of device that can input information to the electronic device, and the input unit 706 can receive input digital or character information, and generate key signal input related to user settings and / or function control of the electronic device. The output unit 707 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 708 can include but is not limited to a disk, an optical disk. The communication unit 709 allows the electronic device to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, and / or a wireless communication transceiver, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0126] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a CPU, a graphics processing unit (GPU), various special artificial intelligence (AI) computing units, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above. For example, in some embodiments, the method embodiments of the present invention may be implemented as a computer program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on an electronic device via ROM 702 and / or a communication unit 709. In some embodiments, the computing unit 701 may be configured to perform the above-described method in any other appropriate manner (e.g., by means of firmware).
[0127] The computer programs for implementing the methods of the embodiments of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer programs are executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer programs may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0128] In the context of an embodiment of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or apparatus. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable signal medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, or infrared systems, devices, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0129] It should be noted that the term "including" and its variations used in the embodiments of the present invention are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present invention are illustrative rather than restrictive. Those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as "one or more".
[0130] The information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0131] The various steps described in the method implementation methods provided in the embodiments of the present invention may be performed in different orders and / or in parallel. In addition, the method implementation methods may include additional steps and / or omit the steps shown. The scope of protection of the present invention is not limited in this respect.
[0132] The term "embodiment" in this specification refers to specific features, structures or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. The various embodiments in this specification are described in a related manner, and the same or similar parts between the various embodiments refer to each other. In particular, for the device, equipment, and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment.
[0133] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the attached claims.
Claims
1. A method for sampling a focus field, characterized in that: include: Acquire a panoramic image of the target object, filter out multiple valid pixel points from the panoramic image based on a preset pixel threshold, and construct a clustering data set; wherein the elements in the clustering data set are pixel positions corresponding to the valid pixel points; the step of filtering out multiple valid pixel points from the panoramic image based on the preset pixel threshold comprises: binarizing the panoramic image to obtain a binary image; determining the pixel points with pixel values of 0 or 255 in the binary image as the valid pixel points; Selecting clustered pixel points that meet the target field of view sampling quantity from the multiple valid pixel points, taking the pixel positions corresponding to the clustered pixel points as the initial cluster centers, and performing clustering processing on each element in the clustered data set based on a clustering algorithm to determine the target cluster center; the method further includes: obtaining the multiple of the shooting device corresponding to the panoramic image, and determining the target field of view sampling quantity according to the multiple; wherein the target field of view sampling quantity does not exceed the square root of the total field of view quantity corresponding to the panoramic image; Determine the pixel point corresponding to the target cluster center as the field of view sampling point, and determine the focus height of the field of view sampling point; wherein, the step of determining the pixel point corresponding to the target cluster center as the field of view sampling point and determining the focus height of the field of view sampling point includes: judging whether there is a valid pixel point at the position corresponding to the target cluster center; if there is, using the valid pixel point as the field of view sampling point; if not, searching for the element closest to the target cluster center in the target cluster to which the target cluster center belongs, and using the valid pixel point corresponding to the element as the field of view sampling point.
2. The method according to claim 1, characterized in that Before the step of selecting clustered pixel points satisfying the target field of view sampling quantity from the multiple valid pixel points, the method further comprises: A target pixel point satisfying a preset number of data set elements is obtained by randomly sampling from the multiple valid pixel points, the target pixel point is used as the updated valid pixel value, and the pixel position corresponding to the target pixel point is used as the element in the clustering data set.
3. The method according to claim 1, characterized in that The step of taking the pixel position corresponding to the cluster pixel point as the initial cluster center and performing clustering processing on each element in the cluster data set based on a clustering algorithm to determine the target cluster center includes: For each element in the clustering data set, the distance between the element and each of the initial clustering centers is calculated, and the element is assigned to the initial clustering center with the closest distance to obtain a plurality of intermediate clusters; Determine the actual cluster centers of the multiple intermediate clusters, and determine the center point distance between the actual cluster centers and the initial cluster centers, and determine whether to continue iterative calculation according to the center point distance and the center point distance threshold; If the center point distance between the current actual cluster center and the cluster center in the previous iterative calculation is less than or equal to the center point distance threshold, the iterative calculation is stopped, and the current actual cluster center is determined to be the target cluster center.
4. The method according to claim 3, characterized in that The method further comprises: Obtain an iterative calculation times threshold, if the current iterative calculation times meets the iterative calculation times threshold, stop the iterative calculation, and determine the current actual cluster center as the target cluster center.
5. The method according to claim 3, characterized in that: The step of determining the actual cluster centers of the plurality of intermediate clusters comprises: The mean value of the pixel positions corresponding to all elements in each intermediate cluster is calculated, and the mean value of the pixel positions is used as the actual clustering center of the intermediate cluster.
6. A sampling device for a focus field, characterized in that: include: A data processing module is used to obtain a panoramic image of a target object, filter a plurality of valid pixels from the panoramic image based on a preset pixel threshold, and construct a clustering data set; wherein the elements in the clustering data set are pixel positions corresponding to the valid pixels; the data processing module is also used to: perform binarization processing on the panoramic image to obtain a binary image; determine that the pixels with a pixel value of 0 or 255 in the binary image are valid pixels; A clustering module, used to select clustering pixel points that meet the target field of view sampling number from the multiple valid pixel points, use the pixel position corresponding to the clustering pixel point as the initial clustering center, and perform clustering processing on each element in the clustering data set based on a clustering algorithm to determine the target clustering center; the device also includes a target field of view sampling number determination module, used to obtain the multiple of the shooting device corresponding to the panoramic image, and determine the target field of view sampling number according to the multiple; wherein the target field of view sampling number does not exceed the square root of the total field of view number corresponding to the panoramic image; The field of view sampling point determination module is used to determine the pixel point corresponding to the target cluster center as the field of view sampling point, and determine the focus height of the field of view sampling point; wherein the field of view sampling point determination module is also used to: determine whether there is a valid pixel point at the position corresponding to the target cluster center; if so, use the valid pixel point as the field of view sampling point; if not, search for the element closest to the target cluster center in the target cluster to which the target cluster center belongs, and use the valid pixel point corresponding to the element as the field of view sampling point.
7. An electronic device comprising: A processor, and a memory storing a program, wherein the program comprises instructions, and when the instructions are executed by the processor, the processor executes the method according to any one of claims 1 to 5.
8. A non-transitory machine-readable medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-5.
Citation Information
Patent Citations
Automatic focusing method for ultrasonic elastography
CN102940510A
Pathological image scanning focus classification method based on k-means clustering
CN105654111A