Hair follicle organoid image detection method, device, equipment and readable storage medium
Patent Information
- Application Number
- CN202611097814.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2046-07-23
AI Technical Summary
但是,由于毛囊类器官在发育过程中同时存在主体结构、毛芽及球部结构,不同结构之间形态尺度差异巨大,依赖固定参数的方法难以适应跨阶段、多尺度的结构变化,导致对毛囊类器官全发育周期的检测能力不足
[0017]本申请实施例通过获取毛囊类器官的明场图像对应的培养阶段信息;根据培养阶段信息确定明场图像对应的至少一种目标结构类型,并针对每个目标结构类型,从预训练的多个实例分割模型中选取匹配的目标分割模型,其中,目标结构类型的类型包括主体结构、毛芽结构和球部结构;通过每个目标结构类型对应的每个目标分割模型,基于明场图像输出每个目标结构类型的结构掩码图像;对每个结构掩码图像执行与对应的目标结构类型相匹配的结构检测操作,得到每个目标结构类型对应的检测子结果;基于至少一种目标结构类型对应的检测子结果,生成毛囊类器官对应的检测结果;其中,结构检测操作的类型至少包括针对主体结构,在对应的结构掩码图像中进行的多个主体实例的形态参数检测操作,或者针对毛芽结构,在对应的结构掩码图像中进行的多个毛芽实例的形态参数检测操作以及对多个毛芽实例进行的空间分布检测操作,或者针对球部结构进行的多个球部实例的尺度检测操作。以此,能够通过阶段自适应多结构协同处理机制,实现不同发育阶段下主体结构、毛芽结构和球部结构各自所需分割与检测策略的动态适配。具体来说,本申请通过引入培养阶段信息作为分割策略选择的先验条件,使系统能够预先获知当前样本所处的发育阶段,并据此确定该阶段实际需要检测的目标结构类型(例如早期仅需主体、中期需主体与毛芽、后期需球部结构等),进而针对每种目标结构类型独立调用经特定结构数据微调的专用分割模型,避免对所有结构一刀切处理所导致的毛芽漏检、分割错误等问题;在此基础上,本申请进一步针对不同目标结构类型的几何与空间特性设计差异化的结构检测操作,主体结构执行形态参数检测以量化整体轮廓属性,毛芽结构同时执行形态参数检测与空间分布检测以刻画嵌套场景下的聚集与散布模式,球部结构执行尺度检测以捕捉细长延伸与分叉形态的特征,从而使各类型结构的检测操作与其自身的生物学形态规律相匹配,解决了统一处理方法无法适应多结构共存与动态演化特征的问题。综上,本申请能够针对毛囊类器官在不同发育阶段呈现的差异化结构组成与形态特征分别采用最优的分割模型与检测策略,从而有效提升对毛囊类器官全发育周期的准确检测能力。
Smart Images

Figure CN122597430B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image detection technology, and in particular to a method, apparatus, device, and readable storage medium for detecting images of hair follicle organoids. Background Technology
[0002] Hair follicle organoids are three-dimensional cell aggregates formed in vitro, which can be used for regenerative medicine research, drug screening, and exploration of skin and hair regeneration mechanisms. During their development, hair buds and slender, Y-shaped bulbous structures will appear successively inside the main structure. Therefore, it is necessary to perform accurate instance segmentation and structural quantification of multiple targets such as the main body, hair buds, and bulbous structures in bright field images to assess their developmental status, thereby providing reliable data support for drug efficacy evaluation, developmental monitoring, and phenotypic analysis.
[0003] In related technologies, general image analysis software is typically used to identify and segment images of hair follicle organoids. For example, tools based on fixed thresholds and morphological operations are used to extract cell or organoid regions. This method binarizes the image using a preset grayscale threshold to separate the foreground and background. Subsequently, morphological opening operations are combined to remove minor noise, closing operations are used to fill internal holes in the target, and connected component analysis is used to extract independent regions. However, because hair follicle organoids simultaneously possess a main structure, a hair bud, and a bulbous structure during development, the morphological scale differences between these structures are enormous. Methods relying on fixed parameters are difficult to adapt to cross-stage, multi-scale structural changes, resulting in insufficient detection capability for the entire developmental cycle of hair follicle organoids. Summary of the Invention
[0004] This application proposes a method, apparatus, device, and readable storage medium for detecting images of hair follicle organoids, which can improve the accuracy of detecting hair follicle organoids throughout their entire developmental cycle.
[0005] To achieve the above objectives, a first aspect of this application proposes a method for detecting images of hair follicle organoids, the method comprising: Obtain culture stage information corresponding to bright-field images of hair follicle organoids; Based on the cultivation stage information, at least one target structure type corresponding to the bright field image is determined, and for each target structure type, a matching target segmentation model is selected from multiple pre-trained instance segmentation models. The target structure types include main structure, bud structure and spherical structure. Based on the bright-field image, output a structure mask image for each target structure type using the segmentation model corresponding to each target structure type. Perform a structure detection operation that matches the corresponding target structure type on each structure mask image to obtain the detection sub-result for each target structure type; Based on the detection sub-results corresponding to the at least one target structure type, the detection results corresponding to the hair follicle organoids are generated. The types of structure detection operations include at least the morphological parameter detection operation of multiple main body instances in the corresponding structure mask image for the main body structure, or the morphological parameter detection operation of multiple bud instances in the corresponding structure mask image for the bud structure and the spatial distribution detection operation of the multiple bud instances, or the scale detection operation of multiple spherical instances for the spherical structure.
[0006] Accordingly, a second aspect of this application provides a detection device for images of hair follicle organoids, the device comprising: The acquisition module is used to acquire culture stage information corresponding to bright-field images of hair follicle organoids; The selection module is used to determine at least one target structure type corresponding to the bright field image based on the cultivation stage information, and for each target structure type, select a matching target segmentation model from multiple pre-trained instance segmentation models, wherein the target structure types include main structure, bud structure and spherical structure. The output module is used to output a structure mask image for each target structure type based on the bright field image, using each target segmentation model corresponding to each target structure type. The detection module is used to perform a structure detection operation on each structure mask image that matches the corresponding target structure type, and obtain the detection sub-result corresponding to each target structure type; A generation module is used to generate a detection result corresponding to the hair follicle organoid based on the detection sub-results corresponding to the at least one target structure type; The types of structure detection operations include at least the morphological parameter detection operation of multiple main body instances in the corresponding structure mask image for the main body structure, or the morphological parameter detection operation of multiple bud instances in the corresponding structure mask image for the bud structure and the spatial distribution detection operation of the multiple bud instances, or the scale detection operation of multiple spherical instances for the spherical structure.
[0007] In some implementations, the target segmentation model includes a main structure segmentation model, a bud structure segmentation model, and a spherical structure segmentation model. The selection module is further configured to: When the culture stage information indicates that the hair follicle organoid is in an early stage, the target structure type is determined to correspond to the main structure, and the main structure segmentation model corresponding to the main structure is selected from the multiple instance segmentation models, wherein the main structure segmentation model is configured with a first detection scale parameter; When the culture stage information indicates that the hair follicle organoid is in the early to mid-stage, the target structure type is determined to be the main structure, and the main structure segmentation model corresponding to the main structure is selected from the multiple instance segmentation models. The main structure segmentation model is configured with a second detection scale parameter, which is greater than the first detection scale parameter. When the culture stage information indicates that the hair follicle organoid is in the intermediate stage, the target structure type is determined to correspond to the main structure and the hair bud structure, and the main structure segmentation model corresponding to the main structure and the hair bud structure segmentation model corresponding to the hair bud structure are selected from the multiple instance segmentation models. When the culture stage information indicates that the hair follicle organoid is in a late stage, the target structure type is determined to correspond to the main structure and the bulbous structure, and the main structure segmentation model corresponding to the main structure and the bulbous structure segmentation model corresponding to the bulbous structure are selected from the multiple instance segmentation models.
[0008] In some embodiments, the target segmentation model includes a main structure segmentation model, a bud structure segmentation model, and a spherical structure segmentation model; the structure mask image includes at least one of a main structure mask image, a bud structure mask image, and a spherical structure mask image; and the output module is further configured to: When the target structure type is a main structure, the main structure segmentation model outputs a main structure mask image containing at least one main entity instance based on the bright field image. When the target structure type is a bud structure, the bud structure segmentation model outputs an initial structure mask image containing at least one bud instance based on the bright field image. Based on the size relationship between the bud area of each bud instance in the initial structure mask image and a preset bud area threshold, the bud instances in the initial structure mask image are filtered to obtain the corresponding bud structure mask image. When the target structure type is a spherical structure, the spherical structure segmentation model outputs a corresponding probability map based on the bright field image, and generates a spherical structure mask image containing at least one spherical instance based on the instance probability value corresponding to each pixel contained in the probability map.
[0009] In some implementations, the output module is further configured to: A first comparison result is obtained by comparing the instance probability value corresponding to each pixel in the probability map with a preset first probability threshold. When the first comparison result indicates that the probability value of the instance corresponding to the first pixel of the target exists in the probability map is greater than the first probability threshold, the first pixel of the target is determined as a seed pixel, and at least one seed region is generated based on multiple seed pixels; A second comparison result is obtained by comparing the instance probability value corresponding to each pixel in the probability map with a preset second probability threshold, wherein the second probability threshold is less than the first probability threshold; When the second comparison result indicates that the probability value of the instance corresponding to the second pixel of the target exists in the probability map is greater than the second probability threshold, the second pixel of the target is determined as a candidate pixel, and a candidate region is generated based on multiple candidate pixels; In the candidate region, the watershed algorithm is executed with all seed regions as initial labels to obtain the sphere instance corresponding to each seed region; Generate a corresponding spherical structure mask image based on the spherical instance corresponding to each seed region.
[0010] In some embodiments, the type of the structural mask image includes a main structure mask image, a bud structure mask image, and a bulb structure mask image. The detection device for the hair follicle organoid image further includes a correction module for: When the culture stage information indicates that the hair follicle organoid is in the intermediate or late stage, a target structure mask image is determined based on the culture stage information, wherein the target structure mask image is the hair bud structure mask image corresponding to the intermediate stage or the bulb structure mask image corresponding to the late stage. For each substructure instance in the target structure mask image, calculate the overlap area between the substructure instance and each main instance in the main structure mask image, and determine the main instance with the largest overlap area as the parent instance of the corresponding substructure instance; For each substructure instance, the overlap ratio is obtained based on the ratio between the overlapping area corresponding to the parent instance and the area of the substructure instance; For each substructure instance, when the overlap ratio is greater than a preset retention threshold, the substructure instance is determined as the target substructure instance corresponding to the parent instance, and a corrected structure mask image is generated based on multiple target substructure instances corresponding to the target structure mask image. When the overlap ratio is greater than or equal to a preset expansion threshold, and the target substructure instance has at least one target pixel that crosses the pixel boundary of the parent instance, the at least one target pixel of the target substructure instance is merged into the parent instance to obtain the corresponding target main body instance, and the main body structure mask image is corrected based on each target main body instance to obtain the corrected main body structure mask image.
[0011] In some embodiments, the detection module is further configured to: When the culture stage information indicates that the hair follicle organoid is in the intermediate stage, determine the main structure mask image and hair bud structure mask image corresponding to the intermediate stage; For each hair instance contained in the hair structure mask image, the hair instance pixel coordinates of each corresponding hair instance pixel are determined, and the hair centroid coordinates are calculated based on the average of the multiple hair instance pixel coordinates corresponding to each hair instance. For each bud instance contained in the bud structure mask image, calculate the target overlap area between each bud instance and at least one corresponding main instance. When the target overlap area is greater than a preset retention threshold, retain the corresponding bud instance as a target bud instance. The hair bud screening and retention ratio is calculated based on the ratio between the first number of multiple target hair bud instances corresponding to the hair bud structure mask image and the second number of multiple hair bud instances contained in the hair bud structure mask image. Based on the main structure mask image, the area of the main instance of the multiple main instances is determined, and the bud density is calculated based on the first quantity and the area of the main instance. For each target hair instance, calculate the centroid distance between the corresponding target centroid coordinates and the adjacent target centroid coordinates of each adjacent target hair instance, and determine the minimum centroid distance from the multiple centroid distances corresponding to multiple adjacent target hair instances as the nearest neighbor distance of the current target hair instance. Based on the nearest neighbor distances corresponding to the multiple target hair bud instances, calculate the mean centroid distance, standard deviation of centroid distance, maximum centroid distance, and minimum centroid distance; Based on the first quantity, the hair bud screening retention ratio, the hair bud density, the mean centroid distance, the standard deviation of the centroid distance, the maximum centroid distance, and the minimum centroid distance, a detection sub-result corresponding to the hair bud structure is generated.
[0012] In some embodiments, the structural mask image is a spherical structure mask image, and the detection device for the hair follicle organoid image further includes an update module for: When the culture stage information indicates that the hair follicle organoid is in the late stage, for each spherical instance in the spherical structure mask image, the corresponding morphological skeleton is extracted, and the corresponding average thickness is calculated based on the area of the spherical instance corresponding to the current spherical instance and the skeleton length of the morphological skeleton. Obtain the minimum bounding ellipse corresponding to each spherical instance, and calculate the aspect ratio of each spherical instance based on the minimum bounding ellipse; Determine the number of adjacent skeleton pixels of each skeleton pixel in the morphological skeleton corresponding to each sphere instance, and determine the skeleton pixels with a number of one adjacent skeleton pixels as the skeleton endpoints of the sphere instance; For each spherical instance, the two farthest skeleton endpoints are determined as the two end skeleton endpoints of the spherical instance; For each spherical instance, an end cap region is constructed with each end skeleton endpoint as the center and the average thickness as the radius, and the region in the spherical instance other than the end cap region is defined as the side region. For each spherical instance in the spherical structure mask image, obtain the neighboring spherical instances that are adjacent to the current spherical instance; For each spherical instance, when the aspect ratio of the current spherical instance and at least one of the adjacent spherical instances is greater than or equal to a preset aspect ratio threshold, and the end cap region corresponding to the current spherical instance is adjacent to the end cap region corresponding to the adjacent spherical instance, and the end cap region corresponding to the current spherical instance is not adjacent to the side region corresponding to the adjacent spherical instance, and the end cap region corresponding to the adjacent spherical instance is not adjacent to the side region corresponding to the current spherical instance, the current spherical instance and the adjacent spherical instance are merged into one spherical instance; The spherical structure mask image is updated based on the merged multiple spherical instances to generate an updated spherical structure mask image.
[0013] In some embodiments, the structural mask image is a spherical structure mask image, and the detection device for the hair follicle organoid image further includes a replacement module for: When the culture stage information indicates that the hair follicle organoid is in the late stage, for each spherical instance in the spherical structure mask image, the corresponding morphological skeleton is extracted, and the total number of skeleton endpoints and the number of bifurcation points of the morphological skeleton are determined. The bifurcation point is a skeleton pixel in the morphological skeleton with a number of adjacent skeleton pixels greater than or equal to three. When the total number of skeleton endpoints is three and the number of bifurcation points is one, the spherical instance is determined as the spherical instance to be cut, and each skeleton branch and its corresponding branch length are determined on the morphological skeleton, with the bifurcation point as the starting point and each skeleton endpoint as the ending point. When at least two first skeleton branches in the morphological skeleton have a branch length greater than or equal to a preset length threshold, and the ratio between the longer first branch and the shorter second branch of the at least two first skeleton branches is less than or equal to a preset proportion threshold, skeleton branches to be retained and skeleton branches to be cut are determined from the two first skeleton branches. The preset length threshold is determined based on the larger value between a preset minimum absolute length threshold and a reference threshold. The reference threshold is calculated based on the product of a preset relative length proportion and the length of the shortest branch among the multiple skeleton branches. On the retained skeleton branch, select a starting segment skeleton point close to the bifurcation point, and determine the local tangent direction of the retained skeleton branch at the bifurcation point based on the starting segment skeleton point, and determine the local tangent direction as the initial cutting direction; The step length is accumulated along the skeleton branch to be cut from the bifurcation point to the end skeleton endpoint of the skeleton branch to be cut. When the accumulated length reaches the target branch length corresponding to the second skeleton branch, the current skeleton pixel is determined as a candidate cutting point. Centered on the candidate cutting point, the initial cutting direction is rotated within a preset angle range with a preset step size to obtain multiple candidate cutting directions. For each candidate cutting direction, the cutting direction is extended bidirectionally to the mask boundary of the current sphere instance to be cut to form a candidate cutting line. A preset kerf thickness is applied to the candidate cutting line to obtain a kerf band. The pixel area covered by the kerf band is removed from the instance mask of the current sphere instance to be cut to obtain the remaining mask area. For each spherical instance to be cut, connected component analysis is performed on the remaining mask region to obtain multiple spherical sub-instances. In the spherical structure mask image, the spherical instance to be cut is replaced with the multiple spherical sub-instances. Based on the multiple spherical sub-instances corresponding to each spherical instance to be cut, the spherical structure mask image is updated to obtain an updated spherical structure mask image.
[0014] In some embodiments, the structural mask image is a spherical structural mask image, and the detection module is further configured to: When the culture stage information indicates that the hair follicle organoid is in a late stage, determine the bulb structure mask image corresponding to the late stage. For each sphere instance contained in the sphere structure mask image, the corresponding morphological skeleton is extracted, and the skeleton endpoints and bifurcation points of the morphological skeleton are determined based on the number of adjacent skeleton pixels of each skeleton pixel on the morphological skeleton. For each spherical instance, starting from each skeleton endpoint, the nearest target bifurcation point is determined along the morphological skeleton, and the branch length corresponding to each skeleton endpoint is determined based on the current skeleton endpoint and the target bifurcation point. Branches with branch lengths less than a preset branch length threshold are deleted to obtain the pruned morphological skeleton. For each spherical instance, Euclidean distance transformation is performed on the structural mask image corresponding to the spherical instance to obtain the distance value of each pixel to the nearest mask boundary, and the pixel with the largest distance value is determined as the geometric center pixel of the spherical instance; For each spherical instance, on the trimmed morphological skeleton, starting from the geometric center pixel, determine the longest continuous path between the skeleton endpoints, and determine the continuous path as the main axis; On the main axis, a set of morphological skeleton points adjacent to the geometric center pixel is determined, and the local tangent direction of the geometric center pixel is determined based on the set of morphological skeleton points. According to the direction orthogonal to the local tangent direction, a search is performed from the geometric center pixel to the boundary of the current sphere instance to obtain two target boundary points. Based on the distance between the two target boundary points, the candidate cross section thickness of the geometric center pixel is obtained, and the next candidate cross section thickness is calculated based on the updated set of morphological skeleton points. Repeat the step of calculating multiple candidate cross-sectional thicknesses based on the updated morphological skeleton point set until the preset number of updates is reached, and select the largest target cross-sectional thickness from the multiple candidate cross-sectional thicknesses. Based on the number of multiple spherical instances contained in the spherical structure mask image, the number of target skeleton pixels corresponding to the trimmed morphological skeleton of each spherical instance, the number of principal axis pixels corresponding to the principal axis, and the target cross-sectional thickness, the detection sub-result corresponding to the spherical structure is obtained.
[0015] Accordingly, a third aspect of the present application provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method for detecting hair follicle organoid images according to any one of the embodiments of the first aspect of the present application.
[0016] Accordingly, a fourth aspect of the embodiments of this application proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method for detecting hair follicle organoid images according to any one of the embodiments of the first aspect of this application.
[0017] This application embodiment obtains the culture stage information corresponding to the bright-field image of hair follicle organoids; determines at least one target structure type corresponding to the bright-field image based on the culture stage information, and selects a matching target segmentation model from multiple pre-trained instance segmentation models for each target structure type. The target structure types include main structures, bud structures, and bulb structures. Using each target segmentation model corresponding to each target structure type, a structure mask image for each target structure type is output based on the bright-field image. A structure detection operation matching the corresponding target structure type is performed on each structure mask image to obtain a detection sub-result corresponding to each target structure type. Based on the detection sub-result corresponding to at least one target structure type, a detection result corresponding to the hair follicle organoid is generated. The structure detection operation types include, at least, for the main structure, morphological parameter detection of multiple main instances in the corresponding structure mask image; for the bud structure, morphological parameter detection of multiple bud instances in the corresponding structure mask image and spatial distribution detection of multiple bud instances; or for the bulb structure, scale detection of multiple bulb instances. In this way, a stage-adaptive multi-structure collaborative processing mechanism can be used to dynamically adapt the segmentation and detection strategies required for the main structure, bud structure and spherical structure at different developmental stages. Specifically, this application introduces information about the developmental stage as a priori condition for segmentation strategy selection, enabling the system to know in advance the developmental stage of the current sample and determine the target structure type that actually needs to be detected at that stage (e.g., only the main body is needed in the early stage, the main body and buds are needed in the middle stage, and the spherical structure is needed in the later stage). Then, a dedicated segmentation model finely tuned with specific structural data is independently called for each target structure type, avoiding problems such as missed buds and segmentation errors caused by a one-size-fits-all approach to all structures. On this basis, this application further designs differentiated structure detection operations for the geometric and spatial characteristics of different target structure types. The main body structure performs morphological parameter detection to quantify the overall contour attributes, the bud structure performs morphological parameter detection and spatial distribution detection simultaneously to characterize the aggregation and dispersion patterns in nested scenes, and the spherical structure performs scale detection to capture the features of slender extension and bifurcation morphology. Thus, the detection operations of each type of structure are matched with their own biological morphological laws, solving the problem that a unified processing method cannot adapt to the coexistence and dynamic evolution characteristics of multiple structures. In summary, this application can employ the optimal segmentation model and detection strategy for the differentiated structural composition and morphological characteristics of hair follicle organs at different developmental stages, thereby effectively improving the accurate detection capability of hair follicle organs throughout their entire developmental cycle. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of the architecture of the hair follicle organoid image detection system provided in the embodiments of this application; Figure 2This is a flowchart of the method for detecting hair follicle organoid images provided in the embodiments of this application; Figure 3 This is a schematic diagram of the functional modules of the hair follicle organoid image detection device provided in the embodiments of this application; Figure 4 This is a schematic diagram of the hardware structure of the computer device provided in the embodiments of this application. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0020] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0022] This application provides a method, apparatus, device, and readable storage medium for detecting images of hair follicle organoids, which can improve the accuracy of detecting the entire developmental cycle of hair follicle organoids.
[0023] The method, apparatus, device, and readable storage medium for detecting hair follicle organoid images provided in this application are specifically described through the following embodiments. First, the system for detecting hair follicle organoid images in this application is described.
[0024] Please refer to Figure 1 In some embodiments, this application provides a detection system for images of hair follicle organoids, including a terminal 11 and a server 12.
[0025] In some implementations, terminal 11 can be used to acquire and input bright-field images of hair follicle organs, control user interaction, and display and verify the detection results locally. For example, it can be a high-performance computer equipped with an image acquisition card, a dedicated microscopic image workstation, a portable laptop, or an industrial tablet computer.
[0026] Specifically, terminal 11 can receive digital image files from a bright-field microscope through its image input and information parsing unit, and parse the culture stage information corresponding to the image from the image file name or associated experimental record file. Then, it encapsulates the original image and stage information according to a predetermined communication protocol and sends it to server 12 as the basis for stage judgment in the subsequent multi-stage segmentation process. At the same time, terminal 11 can also receive multi-type structure mask images and quantitative analysis results returned by server 12 through its visualization module, and overlay different types of masks with different colors on the original bright-field image. At the same time, it marks the instance-level confidence level next to the minimum bounding rectangle of each instance for experimental personnel to visually verify and evaluate the quality.
[0027] In some implementations, the server 12 can be used to perform core computationally intensive tasks on bright-field images of hair follicle organoids, including multi-stage instance segmentation, structured segmentation post-processing, geometric feature extraction and spatial distribution statistical analysis. For example, it can be a locally deployed high-performance computing server, a GPU-accelerated workstation, or a cloud-based elastic computing cluster or containerized inference service and other hardware devices.
[0028] Furthermore, the server 12 can automatically select a combination of segmentation models and parameter configurations that match the current developmental stage based on the cultivation stage information uploaded by the terminal 11 through its multi-stage instance segmentation unit. It can call the main structure segmentation model, bud structure segmentation model, or spherical structure segmentation model finely tuned by hair follicle organoid data to output the corresponding structural mask images. The post-segmentation processing unit performs area filtering, parent-child structure attribution determination, mask expansion, and end-to-end merging operations based on end caps and disjoint-set data structures on various masks to obtain the final instance mask with reasonable topological relationships. The server 12 can also perform Euclidean distance transformation, skeleton extraction and pruning, principal axis longest path search, and maximum cross-sectional thickness measurement on the spherical structure mask through the skeleton and geometric feature analysis unit. The bud spatial distribution statistics unit performs centroid screening, density calculation, and nearest neighbor distance statistics on the bud instances inside the main structure. Finally, it summarizes all category masks, geometric parameters, and spatial statistical indicators and returns them to the terminal 11.
[0029] In some implementations, terminal 11 can encode the parsed original bright-field image and culture stage information into a structured request data packet, and initiate an analysis task call to server 12 using communication protocols such as HTTP or gRPC. After receiving the request, server 12 executes all calculation processes in the claims, including multi-stage instance segmentation, structured post-processing, geometric feature extraction, and spatial distribution statistics, based on the stage information. It packages the generated multi-class mask images (PNG format) and comma-separated value files containing the number, area, skeleton length, maximum cross-sectional thickness, bud density, and nearest neighbor distance statistics of various structures into response data and returns it to terminal 11. After receiving the response data, terminal 11 uses a local visualization module to overlay and render the mask images, quantitative reports, and original images on the display interface, and provides instance-level confidence annotations for user verification. This achieves a collaborative working mode of terminal 11 data acquisition and display, and server 12 calculation and analysis, which fully leverages the convenience of terminal 11 in image acquisition and human-computer interaction, and utilizes the powerful computing power of server 12 to complete complex deep learning inference and geometric calculation tasks.
[0030] The method for detecting hair follicle organoid images in this application can be illustrated through the following embodiments.
[0031] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent will be obtained first. Furthermore, the collection, use, and processing of this data will comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user will be obtained through pop-ups or redirects to confirmation pages. Only after obtaining the user's separate permission or consent will the necessary user-related data for the normal operation of the embodiments of this application be obtained.
[0032] In this embodiment, the description will focus on the detection device for hair follicle organoid images, which can be integrated into a computer device. See [link to relevant documentation]. Figure 2 , Figure 2 This is a flowchart illustrating the steps of the hair follicle organoid image detection method provided in this application embodiment. Taking the hair follicle organoid image detection device specifically integrated into a terminal or server as an example, the specific process when the processor on the terminal or server executes the program instructions corresponding to the hair follicle organoid image detection method is as follows: Step 101: Obtain the culture stage information corresponding to the bright-field image of the hair follicle organoid.
[0033] In some implementations, in order to achieve precise matching between segmentation strategies and developmental states in the structural analysis of hair follicle organoids, thereby overcoming the technical obstacle that a single model or fixed parameters cannot take into account the morphological differences at different stages, preset culture stage labels can be directly read from image files or associated records as the basis for process scheduling. This allows subsequent processing to select dedicated models and parameters according to stages, thereby avoiding detection mismatch problems caused by ignoring the laws of structural evolution.
[0034] Among them, hair follicle organoids can be three-dimensional cell aggregates formed spontaneously by hair follicle stem cells under in vitro culture conditions, such as multicellular spherical or heteromorphic complexes exhibiting developmental characteristics such as hair buds and bulb structures, which can be used to characterize in vitro regeneration models of skin appendages.
[0035] Among them, bright-field images can be grayscale images acquired under a conventional transmission optical microscope, such as two-dimensional projection images of hair follicle organs obtained using bright-field illumination.
[0036] The cultivation stage information can be time attribute data stored or associated with the bright field image, such as the number of cultivation days obtained from the image file name, experimental record table, or external CSV file.
[0037] In some implementations, the brightfield image can be a two-dimensional grayscale image acquired using transmitted brightfield illumination for hair follicle organoids. Meanwhile, the culture stage information can be pre-recorded numerical labels representing the number of days the organoid has been cultured in vitro. In some implementations, the culture stage information can be directly parsed from the image file name. For example, if the image file is stored according to naming conventions such as "day10_sample1.tif", "day57_control.tif", or "day122_treated.tif", the number of days can be extracted using regular expression matching or string parsing.
[0038] Alternatively, the culture stage information can be read from the accompanying experimental record sheet or a separate external comma-separated value file. Each row in this CSV file corresponds to an image identifier and its corresponding culture day. The culture day 'd' can be obtained by performing a lookup using the image identifier. Once the culture stage information is successfully obtained, it is used as input for subsequent multi-stage segmentation strategy selection.
[0039] In some implementations, culture stage information can also be obtained through metadata carried within the image itself. Specifically, during the acquisition of bright-field microscopy images, the image acquisition software can automatically record the acquisition timestamp. The difference between this timestamp and the initial inoculation time of the organoid (which can be pre-entered into the system as a fixed parameter) can be converted to obtain the culture days. This avoids the problem of losing stage information due to manual recording errors or file renaming. For example, if the image acquisition software records the acquisition date "2026-06-17 14:30:00" in the Exchangeable Image File Format (EXIF) header of the image file, and the experimenter pre-sets the initial inoculation date as "2026-04-01 09:00:00", the system can automatically calculate the culture days as 77 days by calculating the time difference between the two, thus accurately entering the mid-stage fractionation process. In this way, the automatic acquisition and entry of culture stage information can be achieved without increasing the additional operational burden on the experimenter, thereby improving the automation level and data traceability of the entire analysis process.
[0040] Step 102: Determine at least one target structure type corresponding to the bright field image based on the cultivation stage information, and select a matching target segmentation model from multiple pre-trained instance segmentation models for each target structure type. The target structure types include main structure, bud structure and spherical structure.
[0041] In some implementations, to avoid false detections and computational redundancy caused by indiscriminate processing of all structures, the type of target structure to be segmented in the current bright-field image can be determined by using the culture stage information as the input condition for strategy selection. Then, a target segmentation model matching the type can be selected from multiple dedicated models to achieve precise alignment between the segmentation process and the actual developmental process of organoids.
[0042] The target structure type can be an anatomical unit category with different developmental time and morphological characteristics to be identified and segmented in the bright field image of hair follicle organs, such as the main structure, hair bud structure and bulb structure.
[0043] The instance segmentation model can be a general neural network architecture, such as Cellpose, StarDist, or Mask R-CNN, used to distinguish each independent target in an image by pixel-level numbering and output its individual mask. This model is pre-trained and can accurately segment instances at the corresponding incubation stage.
[0044] The target segmentation model can be a special segmentation model obtained by fine-tuning the parameters of a specific type of main structure, bud structure or bulb structure based on a general instance segmentation model. For example, the main segmentation model or bud segmentation model fine-tuned by hair follicle organoid data can be used to output a high-quality instance mask corresponding to a certain type of structure.
[0045] The main structure can be the overall three-dimensional cell aggregate outline region of hair follicle organs in bright-field images, such as a large-scale connected region that is circular or irregularly elliptical, which can serve as the parent carrier to which the hair bud structure and bulb structure are attached.
[0046] Among them, the hair bud structure can be a small-scale outward protrusion formed by the surface of the main structure during the middle stage of development of hair follicle organs. Its directionality is relatively weak and its boundaries are relatively sharp.
[0047] Among them, the bulbous structure can be a slender strip or a Y-shaped bulging shape formed by the extension of hair buds in the later stage of development of hair follicle organs. It has strong directionality and is prone to multi-point adhesion, which can be used to characterize the entry of hair follicle organs into the mature development stage.
[0048] In some implementations, at least one target structure type corresponding to the bright-field image is determined based on the cultivation stage information. Specifically, this can be achieved by comparing the cultivation day 'd' with multiple preset cultivation time thresholds to determine the developmental stage level of the current image. In this embodiment, three thresholds are preset. , , exemplarily take =10 days =50 days =90 days. Based on the relationship between d and the above threshold, the developmental stages are divided into four levels: the early stage is d< The early and middle stages are ≤d≤ The intermediate stage is <d≤ The later stage is d> Different developmental stages correspond to different combinations of target structure types: In the early and early-middle stages, hair follicle organs only have a main structure, without the formation of hair buds or bulbils; therefore, the target structure type is determined only as the main structure. In the middle stage, hair buds begin to protrude outward from the surface of the main structure; at this time, the target structure type is determined as both the main structure and the hair bud structure. In the late stage, the bulbils have developed into elongated strips and coexist with the main structure; at this time, the target structure type is determined as both the main structure and the bulbils. By determining these stages, the structural category that needs to be segmented in the current bright-field image can be identified.
[0049] Furthermore, after determining the target structure type, a matching target segmentation model can be selected from multiple pre-trained instance segmentation models for each target structure type. Specifically, the multiple instance segmentation models include at least: a main structure segmentation model for segmenting the overall contour region of hair follicle organs; a hair bud structure segmentation model for segmenting small-scale protruding structures; and a bulbous structure segmentation model for segmenting elongated or bifurcated bulbous structures. All three models can be obtained by fine-tuning their parameters using their respective structure type annotation data, based on a general cell instance segmentation network (e.g., Cellpose).
[0050] Specifically, in the early stage, a main structure segmentation model can be selected and configured with a first detection scale parameter (for example, a smaller target diameter, such as 150 pixels); in the mid-early stage, a main structure segmentation model can be selected and configured with a second detection scale parameter (for example, a larger target diameter, such as 520 pixels), which is greater than the first detection scale parameter; in the mid-stage, both the main structure segmentation model and the bud structure segmentation model can be selected; and in the late stage, both the main structure segmentation model and the spherical structure segmentation model can be selected. It should be noted that the above thresholds and parameter values are illustrative examples and can be adaptively adjusted according to the microscope magnification, image resolution, and experimental system in practical applications.
[0051] For example, when determining the target structure type, in addition to the hard segmentation method based on the number of cultivation days and a preset threshold, a fuzzy stage division mechanism can also be used. Specifically, when the number of cultivation days is close to the threshold boundary (e.g., Within ±5 days, the system does not uniquely determine a specific stage level. Instead, it simultaneously activates the structural type combination of two adjacent stages and performs segmentation separately. The optimal output is then selected through instance-level confidence comparison or a fusion strategy. For example, when d=48 days and At 50 days, the system simultaneously performs segmentation into early-mid stage (main body only) and mid-mid stage (main body + buds). If the average confidence score of the main body segmentation result is greater than the preset confidence threshold, while the average confidence score of all instances in the bud detection result is lower than the preset confidence threshold, the system determines that the current stage is still in the early-mid stage and discards the bud results. Conversely, if the average confidence score of the main body segmentation result is greater than the preset confidence threshold, and the average confidence score of all instances in the bud detection result is also higher than the preset confidence threshold, the bud results are retained. This method avoids the propagation of misjudgments caused by a single hard threshold division and improves the robustness of the segmentation strategy selection.
[0052] By using the above methods, we can avoid generating false alarms by ineffective segmentation of buds or spherical structures that have not yet appeared in the early stage, and also avoid missing key substructures due to misjudgment of structure type in the later stage. This provides an accurate and pure input basis for subsequent targeted structured post-processing, geometric measurement and spatial statistics that only exist in the current stage.
[0053] In some implementations, to achieve adaptive switching of segmentation model type and scale parameters throughout the entire developmental cycle of hair follicle organs and avoid missed detections or adaptation failures due to fixed models and single receptive fields at different volume spans, the culture stage information can be matched with a preset threshold range to determine the combination of structural categories to be segmented at the current stage and the corresponding main body segmentation scale level, so that both early small-volume subjects and mid-to-late-stage large-volume subjects can obtain suitable feature extraction sensitivity. For example, the target segmentation model type may include a main structure segmentation model, a hair bud structure segmentation model, and a spherical structure segmentation model. Step 102, "selecting a matching target segmentation model from multiple pre-trained instance segmentation models for each target structure type," may include: (102.1) When the information characterization of hair follicle organoids during the culture stage is in the early stage, the main structure corresponding to the target structure type is determined, and the main structure segmentation model corresponding to the main structure is selected from multiple instance segmentation models. The main structure segmentation model is configured with the first detection scale parameter. (102.2) When the information characterization of hair follicle organoids during the culture stage is in the early to mid-stage, the target structure type is determined as the main structure, and the main structure segmentation model corresponding to the main structure is selected from multiple instance segmentation models. The main structure segmentation model is configured with a second detection scale parameter, which is greater than the first detection scale parameter. (102.3) When the information representation of hair follicle organoids in the culture stage is in the middle stage, determine the main structure and hair bud structure corresponding to the target structure type, and select the main structure segmentation model corresponding to the main structure and the hair bud structure segmentation model corresponding to the hair bud structure from multiple instance segmentation models. (102.4) When the information representation of hair follicle organoids in the culture stage is in the later stage, determine the main structure and bulb structure corresponding to the target structure type, and select the main structure segmentation model corresponding to the main structure and the bulb structure segmentation model corresponding to the bulb structure from multiple instance segmentation models.
[0054] The early stage can be the initial developmental period when the number of culture days is less than the first preset threshold. At this time, the organoids are small in size, have relatively smooth boundaries, and only have the main structure. This can be used to trigger the small-scale main segmentation process.
[0055] Among them, the main structure segmentation model can be a special model obtained by fine-tuning the parameters of the main structure annotation data based on the general instance segmentation network architecture. For example, the segmentation network fine-tuned based on Cellpose can be used to output the instance mask of the main structure from the bright field image.
[0056] The first detection scale parameter can be a receptive field control parameter for small-volume targets configured for the main structure segmentation model, such as a smaller preset target diameter, which can be used to improve the detection sensitivity of small-sized main structures.
[0057] The early to mid-stage can be a transitional period between the first and second preset thresholds in terms of the number of cultivation days. At this time, the main body volume has increased significantly but the substructure has not yet been formed, which can be used to trigger the large-scale main body segmentation process.
[0058] The second detection scale parameter can be a receptive field control parameter configured for the main structure segmentation model that is suitable for large-volume targets. For example, a larger preset target diameter, whose value is greater than the first detection scale parameter, can be used to expand the feature coverage of the model for large-sized main structures.
[0059] The intermediate stage can be a development period in which the number of cultivation days is greater than the second preset threshold and not greater than the third preset threshold. At this time, the main structure volume is stable and the surface begins to show outward protruding hair bud morphology, which can be used to trigger the joint segmentation process of the main structure and hair bud structure.
[0060] Among them, the bud structure segmentation model can be a special model obtained by fine-tuning the parameters based on the general instance segmentation network architecture and using bud structure annotation data. For example, a small target segmentation network fine-tuned based on Cellpose can be used to segment instance masks of bud structures from bright field images.
[0061] The later stage can be the developmental maturity period when the number of cultivation days exceeds the third preset threshold. At this time, the spherical structure has developed into a slender strip or a forked shape and coexists with the main body. It can be used to trigger the joint segmentation process of the main body structure and the spherical structure.
[0062] Among them, the spherical structure segmentation model can be a special model obtained by fine-tuning the parameters based on the general instance segmentation network architecture and using the spherical structure annotation data. It can be used to output a probability map from the bright field image to assist in the initial segmentation of complex topological structures.
[0063] In some implementations, when the culture stage information indicates that the hair follicle organoid is in an early stage, i.e., the culture days d are less than a first preset threshold. (For example =10 days), the hair follicle organoid has a relatively small volume, a relatively smooth boundary, and only a main structure, with no hair bud or bulb structure formed yet. Therefore, it is determined that the target structure type corresponds to the main structure, and a main structure segmentation model fine-tuned with main structure annotation data is selected from a plurality of instance segmentation models. To meet the detection requirement for early small-volume targets, the main structure segmentation model is configured with a first detection scale parameter, which includes a relatively small preset target diameter (illustratively, d_L1=150 pixels), and is matched with a corresponding probability threshold and flow field threshold, so as to improve the detection sensitivity for small-sized main structures.
[0064] Further, when the main structure segmentation model adopting the first detection scale parameter outputs an invalid result (that is, there is no instance in the output mask or the area of all instances is 0), the system automatically falls back to the re-segmentation process adopting the second detection scale parameter, so as to ensure reliable output for early small targets with different volumes.
[0065] Specifically, when the culture stage information indicates that the hair follicle organoid is in the early-to-mid stage, that is, the culture days d are between the first preset threshold and the second preset threshold (for example, 10 days ≤ d ≤ 50 days), the volume of the main structure has increased significantly but no substructure has been formed yet. Therefore, it is determined that the target structure type is still the main structure, and the main structure segmentation model is also selected, but the model is configured with a second detection scale parameter. The second detection scale parameter includes a relatively large preset target diameter (for example, d_L2=520 pixels), whose value is greater than the target diameter corresponding to the first detection scale parameter, so as to adapt to the main structure that has grown in the early-to-mid stage. Through the differentiated configuration of using the small-scale parameter in the early stage and switching to the large-scale parameter in the early-to-mid stage, it can be ensured that the same main structure segmentation model can obtain appropriate receptive field matching at different development stages with a large span of main structure volumes.
[0066] Further, when the culture stage information indicates that the hair follicle organoid is in the middle stage, that is, the culture days d are between the second preset threshold and the third preset threshold (for example, 50 days < d ≤ 90 days), the hair bud structure starts to protrude outward from the surface of the main structure, and the main structure and the hair bud structure coexist. Therefore, it is determined that the target structure type corresponds to the main structure and the hair bud structure, and the main structure segmentation model and the hair bud structure segmentation model fine-tuned with hair bud structure annotation data are selected at the same time. The main structure segmentation model is still configured with the second detection scale parameter to adapt to the grown main structure, and the hair bud structure segmentation model can be configured with independent parameters suitable for small-scale targets (for example, target diameter d_S=30 pixels, probability threshold τ_S=0.2, flow field threshold f_S=0.8), so as to realize sensitive detection of small-volume hair buds.
[0067] In some implementations, when the culture stage information indicates that the hair follicle organoid is in a later stage, i.e., the culture period d is greater than a third preset threshold. (For example, d>90 days), at this point, the spherical structure has developed into a slender strip or bifurcation shape and coexists with the main body. Therefore, the target structure type can be determined to correspond to the main body structure and the spherical structure. At the same time, the main body structure segmentation model and the spherical structure segmentation model finely adjusted by the spherical structure annotation data are selected. The main body structure segmentation model is further configured with the second detection scale parameters, while the spherical structure segmentation model can be used to output the probability map for dual-threshold composite segmentation.
[0068] For example, in the early stages of subject segmentation, in addition to using a fixed first detection scale parameter, the scale parameter can be dynamically adjusted based on the global statistical features of the image. Specifically, before loading the subject structure segmentation model, foreground region detection can be performed on the bright field image, the area distribution of all connected components in the image can be calculated, and the lower quartile can be taken as an adaptive target diameter reference value. When this reference value is greater than a preset minimum area threshold, the reference value is weighted and fused with the preset value of the first detection scale parameter to obtain the actual target diameter, thereby introducing image adaptive correction capability on the basis of fixed parameters. In this way, the matching accuracy of the scale parameter can be further optimized when there are batch-to-batch differences in subject volume in the early stages.
[0069] By using the above methods, we can avoid missing small-volume entities in the early stages due to excessively large scale parameters, and also avoid over-segmentation of large-volume entities or missing substructures due to excessively small scale parameters in the middle and later stages. This provides an accurate and clean mask source for subsequent targeted structured post-processing that only applies to the actual target structure types at the current stage.
[0070] Step 103: Using the segmentation model corresponding to each target structure type, output the structure mask image of each target structure type based on the bright field image.
[0071] In some implementations, in order to adapt differentiated mask generation paths to the unique morphological complexity and imaging contrast of different target structure types in hair follicle organs, and to avoid the failure of main body detection, false alarm of hair bud, or failure of bulb adhesion segmentation due to the use of a single segmentation output method, instance masks can be directly output for the main structure, area filtering can be applied to the hair bud structure on the basis of its initial segmentation, and the bulb structure can be segmented by a combination of double threshold and watershed algorithm based on probability map, so as to obtain initial mask results with clear instance boundaries and reasonable topology for different structure categories.
[0072] The structure mask image can be a binary or pixel-level labeled image with instance numbers output for a certain target structure type. For example, each connected region in the main structure mask image corresponds to a main instance and is assigned a unique number, or each region in the spherical structure mask image corresponds to a spherical instance. The structure mask image can be used to characterize the position, contour and instance affiliation of various structures in the image space.
[0073] In some implementations, a corresponding target segmentation model can be invoked to perform inference on the bright-field image based on at least one determined target structure type. For example, when the target structure type is a main structure, a main structure segmentation model can be invoked to perform instance segmentation inference on the bright-field image. This model directly outputs a main structure mask image containing at least one main instance, with each main instance assigned a unique number to distinguish different main connected regions.
[0074] For example, when the target structure type is a bud structure, the bud structure segmentation model can be called to perform instance segmentation inference on the bright field image to obtain an initial structure mask image containing at least one bud instance. Then, the pixel area of each bud instance in the initial structure mask image is calculated and compared with a preset bud area threshold (exemplarily 3000 pixels). Bud instances with an area smaller than the threshold are judged as noise and removed. The remaining instances are renumbered consecutively to obtain the final bud structure mask image.
[0075] Furthermore, when the target structure type is a spherical structure, a spherical structure segmentation model can be invoked to infer the bright-field image. This model outputs a probability map of the same size as the input image. The value of each pixel in this probability map represents the prediction confidence that the pixel belongs to the spherical structure category (this confidence can be the logit value output by the model, or the probability value mapped by the sigmoid function). Subsequently, a spherical structure mask image containing at least one spherical instance is generated based on this probability map. Since spherical structures have a slender shape and multi-point adhesion characteristics, the mask generation process preferably adopts a composite segmentation method combining double thresholding and watershed algorithms, which will be described in detail in subsequent steps. When multiple target structure types exist simultaneously at a certain stage (such as the main structure and bud structure in the intermediate stage, or the main structure and spherical structure in the late stage), the segmentation models can be called in parallel or in a preset order. The structure mask images output by each model are independent of each other and are used for subsequent structured post-processing and quantitative analysis.
[0076] By using the above methods, various structures can obtain initial masks with clear boundaries and accurate instance distinctions under their respective suitable segmentation paths, thereby providing a reliable mask input foundation for subsequent operations such as parent-child attribution determination, end-to-end merging, Y-shaped cutting, and geometric feature measurement.
[0077] In some implementations, to adapt differentiated mask generation strategies to the different morphological complexities and imaging contrasts of the three types of structures—main body, bud, and bulb—in hair follicle organs, and to avoid missed detections of the main body, false alarms of the bud, or failure to separate bulb adhesions due to the use of a single segmentation output method, instance masks can be directly output for the main body structure. For the bud structure, noise filtering is performed based on an area threshold on its initial segmentation. For the bulb structure, a composite segmentation is performed using a probability map with dual-threshold seed extraction and a watershed algorithm. This allows for obtaining initial mask results with clear instance boundaries and reasonable topology for different structural categories. For example, the type of structural mask image may include at least one of a main body structure mask image, a bud structure mask image, and a bulb structure mask image. Step 103 may include: (103.1) When the target structure type is a main structure, the main structure mask image containing at least one main entity instance is output based on the bright field image through the main structure segmentation model; (103.2) When the target structure type is a bud structure, the bud structure segmentation model outputs an initial structure mask image containing at least one bud instance based on the bright field image, and filters the bud instances in the initial structure mask image based on the size relationship between the bud area of each bud instance in the initial structure mask image and the preset bud area threshold to obtain the corresponding bud structure mask image. (103.3) When the target structure type is a spherical structure, the corresponding probability map is output based on the bright field image through the spherical structure segmentation model, and a spherical structure mask image containing at least one spherical instance is generated based on the instance probability value corresponding to each pixel contained in the probability map.
[0078] The main structure mask image can be a pixel-level binary label image with instance numbers output for the main structure. Each connected region corresponds to a main structure instance and is assigned a unique number. It can be used to characterize the overall outline, position and distinguishing relationship between instances of the main structure.
[0079] Among them, the bud structure mask image can be a pixel-level marker image with instance number output after filtering the bud instances obtained from the initial segmentation according to the area threshold. It removes noise areas with an area smaller than the preset threshold and can be used to characterize the position and contour information of the real bud structure that is retained.
[0080] The spherical structure mask image can be a pixel-level labeled image with instance numbers generated after the probability map output by the spherical segmentation model is extracted by double threshold seed and watershed segmentation, with each region corresponding to a spherical instance.
[0081] The probability map can be a grayscale image of the same size as the input image, output by the spherical structure segmentation model. The value of each pixel in the probability map represents the prediction confidence that the pixel belongs to the spherical structure category.
[0082] In some implementations, when the target structure type is a main structure, the bright-field image can be input into a main structure segmentation model fine-tuned with main structure annotation data. This model is based on a general cell instance segmentation network (e.g., Cellpose). After inference, the model outputs a probability map of each pixel belonging to the main structure category and the corresponding instance flow field information. After flow field clustering, a pixel-level mask for each main instance is obtained, and each instance is assigned a unique number, thereby generating a main structure mask image containing at least one main instance. Before model inference, it is preferable to perform preprocessing operations on the bright-field image, including grayscale normalization and optional Gaussian smoothing, to suppress noise interference introduced during image acquisition. The target diameter, probability threshold, and flow field threshold parameters of the main structure segmentation model can be dynamically configured according to the current developmental stage. For example, a smaller target diameter (e.g., 150 pixels) can be used in the early stage to improve the detection sensitivity of small targets, while a larger target diameter (exemplarily 520 pixels) can be switched in the mid-early and later stages to adapt to the grown main structure.
[0083] Furthermore, when the target structure type is a bud structure, the bright-field image can be input into a bud structure segmentation model fine-tuned with bud structure annotation data. This model is configured with independent parameters suitable for small-scale targets (e.g., target diameter 30 pixels, probability threshold 0.2, flow field threshold 0.8). After inference, the model outputs an initial structure mask image containing at least one bud instance, and each bud instance is assigned a unique number. Subsequently, based on the relationship between the bud area of each bud instance in the initial structure mask image and a preset bud area threshold, the bud instances in the initial structure mask image are filtered to obtain the corresponding bud structure mask image. Specifically, the total number of pixels contained in each bud instance can be counted as the bud area of that instance. When this area is less than the preset bud area threshold (e.g., 3000 pixels), the instance can be identified as noise or a false target generated by the segmentation model and removed from the mask; when the area is greater than or equal to the threshold, the instance can be identified as a real bud structure and retained. After completing the above determination for all bud instances, the remaining instances can be renumbered sequentially to generate the final bud structure mask image.
[0084] Furthermore, when the target structure type is a spherical structure, the bright-field image can be input into a spherical structure segmentation model fine-tuned by the spherical structure annotation data. This model does not directly output the final instance mask, but instead outputs a probability map of the same size as the input image. The value of each pixel in this probability map represents the prediction confidence that the pixel belongs to the spherical structure category. This confidence can be a value in the logit real domain, or a probability value mapped to the [0,1] interval by the sigmoid function. Subsequently, a spherical structure mask image can be generated based on the instance probability value of each pixel in this probability map. Due to the slender shape and multi-point adhesion characteristics of the spherical structure, its mask generation preferably adopts a composite segmentation method combining dual thresholds and watershed algorithm: First, the pixels with instance probability values greater than the first probability threshold (for example, corresponding to a logit value of 3.41, which is about 0.97 after sigmoid mapping) in the probability map are extracted as seed pixels and form seed regions. At the same time, the pixels with instance probability values greater than the second probability threshold (for example, corresponding to a logit value of 1.06, which is about 0.74 after sigmoid mapping) and the second probability threshold is less than the first probability threshold are extracted as candidate pixels and form candidate regions. Then, the watershed algorithm is executed in the candidate regions with the seed regions as initial labels to obtain the spherical instance corresponding to each seed region. Finally, a spherical structure mask image containing at least one spherical instance is generated.
[0085] For example, in the area filtering process of bud structures, in addition to using a fixed preset bud area threshold, an adaptive area threshold mechanism based on global image statistical features can be introduced. Specifically, the area values of all bud instances in the initial structure mask image are extracted to form an area distribution set. The median and interquartile range of this set are calculated, and the adaptive threshold is set to the median plus 1.5 times the interquartile range. Only bud instances with an area greater than this adaptive threshold are retained. In this way, the filtering intensity can be automatically adjusted between batches of images with different magnifications or resolutions, avoiding over-filtering or under-filtering problems caused by scale changes in cross-batch applications with a fixed threshold.
[0086] By using the above methods, all three types of structures can obtain an initial mask with accurate instance differentiation and clear boundaries under their respective adapted segmentation paths. This provides a pure and topologically reasonable mask input foundation for subsequent operations such as parent-child structure attribution, end-to-end merging, Y-shaped cutting, and geometric feature measurement.
[0087] In some implementations, to separate and extract high-confidence seed regions and candidate foreground regions and guide the watershed algorithm to complete accurate instance segmentation when direct segmentation of the spherical structure is prone to oversegmentation or undersegmentation due to its elongated shape and multiple adhesions, a seed region can be formed by extracting high-confidence pixels from the probability map using a first probability threshold as a reliable anchor point. A candidate region containing the complete structural outline can be generated by expanding the seed region using a second probability threshold lower than the first threshold. The watershed algorithm is then executed within the candidate region using the seed region as the initial label, thereby guiding the accurate delineation of adjacent target boundaries based on the high-confidence anchor points. For example, "generating a spherical structure mask image containing at least one spherical instance based on the instance probability value corresponding to each pixel contained in the probability map" in (103.3) may include: (103.3.1) The first comparison result is obtained by comparing the instance probability value corresponding to each pixel in the probability map with a preset first probability threshold; (103.3.2) When the instance probability value corresponding to the first pixel of the target exists in the probability map of the first comparison result is greater than the first probability threshold, the first pixel of the target is determined as a seed pixel, and at least one seed region is generated based on multiple seed pixels; (103.3.3) Based on the comparison between the instance probability value corresponding to each pixel in the probability map and the preset second probability threshold, a second comparison result is obtained, wherein the second probability threshold is less than the first probability threshold; (103.3.4) When the probability value of the instance corresponding to the second pixel of the target in the probability map of the second comparison result is greater than the second probability threshold, the second pixel of the target is determined as a candidate pixel, and a candidate region is generated based on multiple candidate pixels; (103.3.5) In the candidate region, the watershed algorithm is executed with all seed regions as initial labels to obtain the ball instance corresponding to each seed region; (103.3.6) Generate the corresponding spherical structure mask image based on the spherical instance corresponding to each seed region.
[0088] The first probability threshold can be a preset probability threshold value used to filter high-confidence foreground pixels. Its value is higher than the conventional segmentation threshold, for example, it can be 0.97. It can be used to extract the most reliable seed pixels from the probability map to form a seed region.
[0089] The seed pixel can be a pixel in the probability map whose corresponding instance probability value is greater than the first probability threshold, such as a high-confidence position located in the central region inside the spherical structure. It can be used as the initial growth starting point of the watershed algorithm.
[0090] The seed region can be a connected region formed by multiple adjacent seed pixels after connected component analysis, that is, each independent region obtained after performing connected component labeling on pixels that meet the high threshold.
[0091] The second probability threshold can be a preset probability threshold value used to define the range of candidate foregrounds. Its value is lower than the first probability threshold and higher than the background noise level, for example, it can be 0.74.
[0092] Candidate pixels can be pixels whose corresponding instance probability value in the probability map is greater than the second probability threshold. Their coverage includes the seed pixel and the surrounding structural edge pixels with lower confidence. They can be used together to form the execution boundary of the watershed algorithm.
[0093] The candidate region can be a binary connected range consisting of all candidate pixels, which includes at least one seed region and low-confidence background or edge pixels surrounding the seed region. It can be used to define the effective area of the watershed algorithm to exclude noise interference outside the high-probability region.
[0094] The initial label can be a different number assigned to each seed region before the watershed algorithm is executed. For example, each seed region is assigned a unique integer value as the initial identifier of its corresponding sphere instance, which can be used to instruct the watershed algorithm to flood the candidate region boundary from these high-confidence seed positions.
[0095] In some implementations, a probability map output by the spherical structure segmentation model can be obtained. The value of each pixel in this probability map represents the prediction confidence that the pixel belongs to the spherical structure category (this confidence can be a value in the logit real domain, or a probability value mapped to the [0,1] interval using the sigmoid function). When the probability map is in the logit domain, a preset first probability threshold is configured accordingly in the logit domain (exemplarily τ_high≈3.41); when the probability map has been mapped to the probability domain, the first probability threshold is configured accordingly in the probability domain (corresponding to σ(3.41)≈0.97). The instance probability value of each pixel in the probability map is compared one by one with the first probability threshold, and the comparison result for each pixel is recorded, i.e., whether the instance probability value of the pixel is greater than the first probability threshold, thus obtaining the first comparison result.
[0096] Furthermore, all pixels with instance probability values greater than a first probability threshold can be selected from the probability map as seed pixels. These seed pixels are located in high-confidence regions within the spherical structure. Subsequently, connected component analysis can be performed on all seed pixels to group adjacent seed pixels into the same connected region, with each connected region constituting a seed region. Optionally, after generating seed regions, morphological opening or closing operations can be performed on them to eliminate isolated noise, and seed regions with excessively small areas can be filtered out using minimum connected region filtering (e.g., a minimum connected region threshold N_seed can be set). Each remaining seed region corresponds to a high-confidence core region of a spherical instance.
[0097] For example, the instance probability value of each pixel in the probability map can be compared one by one with a preset second probability threshold (the second probability threshold is τ_low≈1.06 in the logit domain, corresponding to a probability domain σ(1.06)≈0.74; the second probability threshold is less than the first probability threshold), and the instance probability value of each pixel can be recorded as greater than the second probability threshold to obtain a second comparison result. The second probability threshold can be used to define the candidate foreground range of the spherical structure, and its value is lower than the first probability threshold to cover low-confidence areas such as the edge of the structure.
[0098] Next, all pixels with instance probability values greater than the second probability threshold can be selected from the probability map as candidate pixels. These candidate pixels include the seed pixel and its surrounding low-confidence edge pixels. The set of all candidate pixels is then used as the candidate region, which covers all pixel locations that may belong to the spherical structure, including the high-confidence core region and the low-confidence edge region.
[0099] In some implementations, the negative values of the probability graph (i.e. P(x,y), where P is a logit value, is used as the topological surface. Regions with higher probability values on this surface correspond to lower terrain; therefore, the seed region is located at the lowest point. The candidate region is used as the effective execution range of the watershed algorithm. Each seed region's unique number is used as an initial marker, and a watershed flooding process is performed within the candidate region: starting from the seed region, the algorithm gradually expands outwards according to the terrain gradient of the topological surface. When the expansion fronts from different seed regions meet, a watershed boundary is formed at the meeting point, thus dividing the candidate region into multiple segmented regions. Each segmented region corresponds to a spherical instance represented by a seed region. In this way, pixel-level segmentation results for the spherical instances corresponding to each seed region can be obtained.
[0100] Furthermore, the segmented regions of all obtained spherical instances can be aggregated, and each spherical instance is assigned a unique number to form a spherical structure mask image containing at least one spherical instance. This mask image is the same size as the input bright-field image, and the value of each pixel represents the spherical instance number to which that pixel belongs (0 for non-spherical regions). It should be noted that when the number of connected seeds generated by the first probability threshold is 0 (i.e., the seed region is empty), the dual-threshold segmentation is deemed to have failed, and the system can automatically trigger a fallback mechanism, reverting to a combined segmentation strategy of the main structure segmentation model and the tuft structure segmentation model.
[0101] By using the above methods, we can avoid undersegmentation caused by weak signal regions being eliminated due to excessively high thresholds, and also avoid oversegmentation caused by merging adjacent structures due to excessively low thresholds. This provides an initial spherical mask basis with accurate instance attribution and reasonable boundary positions for subsequent end-to-end merging repair and Y-shaped branch cutting processing.
[0102] In some implementations, to accurately determine whether a substructure truly belongs to a specific subject and to simultaneously correct boundary overflow issues caused by segmentation deviations when there is a nested dependency relationship between substructures such as buds or bulbs and the main structure in hair follicle organoids, this can be achieved by calculating the pixel-level overlap area between substructure instances and each subject instance, using the subject corresponding to the largest overlap area as the parent instance, and retaining valid substructures based on a comparison of the overlap ratio and a preset retention threshold. Simultaneously, by comparing the overlap ratio and a preset expansion threshold, overflowing pixels are incorporated into the subject mask to establish a clear parent-child topological relationship and complete the synchronous correction of the subject contour. For example, the type of structure mask image may include a main structure mask image, a bud structure mask image, and a bulb structure mask image. After step 103, the following may also be included: (A.1) When the culture stage information indicates that the hair follicle organoid is in the middle or late stage, the target structure mask image is determined based on the culture stage information, wherein the target structure mask image is the hair bud structure mask image corresponding to the middle stage or the bulb structure mask image corresponding to the late stage. (A.2) For each substructure instance in the target structure mask image, calculate the overlap area between the substructure instance and each main instance in the main structure mask image, and determine the main instance with the largest overlap area as the parent instance of the corresponding substructure instance; (A.3) For each substructure instance, the overlap ratio is obtained based on the ratio between the overlapping area of the parent instance and the area of the substructure instance; (A.4) For each substructure instance, when the overlap ratio is greater than the preset retention threshold, the substructure instance is determined as the target substructure instance corresponding to the parent instance, and a corrected structure mask image is generated based on multiple target substructure instances corresponding to the target structure mask image. (A.5) When the overlap ratio is greater than or equal to the preset expansion threshold and the target substructure instance has at least one target pixel that crosses the pixel boundary of the parent instance, at least one target pixel of the target substructure instance is merged into the parent instance to obtain the corresponding target main instance, and the main structure mask image is corrected based on each target main instance to obtain the corrected main structure mask image.
[0103] The target structure mask image can be a substructure mask image selected from the bud structure mask image or the spherical structure mask image based on the cultivation stage information during the intermediate or late stage. It can be used as the source of the substructure to be processed in the parent-child attribution determination process.
[0104] Here, a substructure instance can be each individual bud or sphere connected region marked in the target structure mask image, such as a bud instance or a sphere instance.
[0105] The overlapping area can be the number of pixels in the intersection between the pixel set of a substructure instance and the pixel set of a main instance.
[0106] The parent instance can be a specific subject instance that has the largest overlapping area with the current substructure instance among all subject instances, that is, the subject structure connected region with the most pixels intersecting with a certain bud instance, which can be used as the belonging carrier of the substructure.
[0107] The overlap ratio can be the ratio of the overlap area of the parent instance to the total area of the current child instance.
[0108] The preset retention threshold can be a preset minimum overlap ratio threshold value used to determine whether a substructure should be retained, for example, it can be 0.2.
[0109] The target substructure instance can be a substructure instance that is determined to be validly attributed to a certain parent instance under the condition that the overlap ratio is greater than a preset retention threshold.
[0110] The preset expansion threshold can be a preset overlap ratio threshold value used to determine whether the substructure triggers the main body mask expansion. It can be the same as or different from the preset retention threshold value, for example, it can be 0.2, 0.3, etc.
[0111] The target subject instance can be the subject structure instance obtained after incorporating the out-of-bounds pixels of the substructure into the parent instance mask, that is, the subject connected region after merging the bud regions that cross the original subject boundary.
[0112] In some implementations, depending on the determined developmental stage, the target structure mask image is a bud structure mask image during the middle stage and a spherical structure mask image during the later stage. Each connected region in the target structure mask image represents a substructure instance (bud instance or spherical instance), and parent-child attribution will be determined for each of these substructure instances subsequently.
[0113] Furthermore, the pixel set of each main entity instance in the main structure mask image can be obtained (each main entity instance is an independent connected region, assigned a unique number). For the i-th substructure instance in the target structure mask image, its pixel set is intersected with the pixel set of each main entity instance, and the number of pixels in the intersection is counted as the overlap area with the current main entity instance. After traversing all main entities, the main entity instance with the largest overlap area can be determined as the parent instance of the substructure instance. If the maximum overlap area is 0 (i.e., the substructure instance has no overlap with any main entity instance), the substructure instance is determined to be isolated noise and is directly removed.
[0114] Furthermore, the total number of pixels contained in the substructure instance itself can be used as the substructure area. The overlapping area corresponding to the parent instance is then divided by the substructure area, and the resulting ratio is the overlap ratio. This overlap ratio reflects the proportion of the substructure instance that lies within the main mask area of its parent instance.
[0115] In some implementations, the overlap ratio of each substructure instance can be compared with a preset retention threshold (exemplarily θ_keep = 0.2). When the overlap ratio is greater than the threshold, the substructure instance is determined to be validly belonging to its parent instance and is marked as a target substructure instance and retained; when the overlap ratio is less than or equal to the threshold, the substructure instance is determined to be a pseudo-target detached from the main body and is removed from the target structure mask image. After the above determination is performed on all substructure instances, all retained target substructure instances are renumbered consecutively to generate a corrected structure mask image.
[0116] In some implementations, for each retained target substructure instance, it can be further determined whether its overlap ratio is greater than or equal to a preset expansion threshold (exemplarily θ_union=0.2, the same value as the retention threshold in this embodiment, but other values can also be used without departing from the concept of this application). Simultaneously, it is checked whether there are pixels in the pixel set of the target substructure instance located outside the parent instance mask boundary (i.e., pixels in the substructure instance that do not belong to the parent instance pixel set). When both conditions are met, all pixels of the target substructure instance (including all pixels located inside and outside the parent instance boundary) are incorporated into the parent instance mask to obtain the expanded target main body instance. Through this mask expansion operation, the substructure boundary extension caused by segmentation deviation can be supplemented into the parent instance mask, achieving synchronous correction of the main body contour.
[0117] Furthermore, all the target subject instances after mask expansion can be recombined to form a corrected subject structure mask image. In the corrected subject structure mask image, the mask of each target subject instance includes the pixels of the original subject instance and the out-of-bounds pixels of the substructure instances belonging to that subject; and the target substructure instances in the generated corrected structure mask image are kept independently numbered, and can be combined with the corrected subject structure mask image to form a mask pair with a clear subject-substructure topological relationship for subsequent geometric feature extraction and spatial statistics.
[0118] By using the above methods, we can clarify the topological belonging relationship between the buds or spheres and the main body at the substructure level, and also repair the problem of incomplete main body outline caused by the extension of factor structure boundaries at the main structure level. This provides accurate parent range and clear substructure belonging input data for subsequent spatial statistics such as bud density and nearest neighbor distance.
[0119] In some implementations, to correct the problem of a spherical structure being incorrectly split into multiple independent instances after segmentation due to the fracture of a slender main trunk, and to restore the complete connectivity of the same spherical structure and avoid subsequent geometric measurements misclassifying artificial fragments as independent samples, the morphological skeleton of each spherical instance can be extracted and its aspect ratio and average thickness calculated. The endpoints of the skeleton at both ends of each instance can be located and end-cap regions can be constructed. Then, based on the criteria of end-caps being adjacent to each other and end-caps not being adjacent to sides, adjacent slender segments that meet the conditions can be merged using a disjoint-set data structure to achieve end-to-end splicing between fragments from the same origin. For example, the structural mask image can be a spherical structure mask image. After step 103, the following may also be included: (B.1) When the information characterization of hair follicle organoids in the culture stage is in the later stage, for each spherical instance in the spherical structure mask image, the corresponding morphological skeleton is extracted, and the corresponding average thickness is calculated based on the area of the spherical instance corresponding to the current spherical instance and the skeleton length of the morphological skeleton. (B.2) Obtain the minimum bounding ellipse corresponding to each spherical instance, and calculate the aspect ratio corresponding to each spherical instance based on the minimum bounding ellipse; (B.3) Determine the number of adjacent skeleton pixels of each skeleton pixel in the morphological skeleton corresponding to each sphere instance, and determine the skeleton pixels with a number of one adjacent skeleton pixels as the skeleton endpoints of the sphere instance. (B.4) For each spherical instance, the two skeleton endpoints that are furthest apart are determined as the two end skeleton endpoints of the spherical instance; (B.5) For each spherical instance, construct an end cap region with each end skeleton endpoint as the center and the average thickness as the radius, and define the region in the spherical instance other than the end cap region as the side region; (B.6) For each spherical instance in the spherical structure mask image, obtain the neighboring spherical instances that are adjacent to the current spherical instance; (B.7) For each spherical instance, when the aspect ratio of the current spherical instance and at least one of the adjacent spherical instances is greater than or equal to a preset aspect ratio threshold, and the end cap region corresponding to the current spherical instance is adjacent to the end cap region corresponding to the adjacent spherical instance, and the end cap region corresponding to the current spherical instance is not adjacent to the side region corresponding to the adjacent spherical instance, and the end cap region corresponding to the adjacent spherical instance is not adjacent to the side region corresponding to the current spherical instance, the current spherical instance and the adjacent spherical instance are merged into one spherical instance; (B.8) Update the spherical structure mask image based on the merged multiple spherical instances to generate an updated spherical structure mask image.
[0120] The morphological skeleton can be a one-pixel-wide centerline obtained by performing morphological thinning on the binary mask of the spherical structure. Each pixel is located at the center trajectory position inside the structure. It can be used to characterize the extension path of the spherical structure and provide a topological skeleton for subsequent endpoint and branch detection.
[0121] The average thickness can be estimated by dividing the pixel area of the sphere instance by the pixel length of its morphological skeleton and then multiplying by 2. It can be based on the pixel area of the sphere instance. (That is, the area of the spherical instance) and the length of the morphological skeleton. The calculation is as follows: .
[0122] The smallest circumscribed ellipse can be the circumscribed ellipse with the smallest area that surrounds all pixels of the current spherical instance. Its major and minor axes are aligned with the main and secondary extension directions of the structure. It can be used to characterize the slenderness of the instance by the ratio of its major and minor axis lengths.
[0123] The aspect ratio can be the ratio between the length of the major axis and the length of the minor axis of the smallest circumscribed ellipse. The larger the value, the closer the structure is to a slender strip. It can be used as a morphological basis for determining whether the current spherical instance belongs to a slender structure that may break.
[0124] Among them, the skeleton endpoint can be a skeleton pixel in the morphological skeleton whose number of adjacent skeleton pixels is 1, that is, the termination point located at both ends of the skeleton, which can be used to characterize the end position of the extension direction of the sphere instance.
[0125] Among them, the end skeleton endpoints can be the two endpoints with the largest Euclidean distance between each other among all the skeleton endpoints of a spherical instance.
[0126] The end cap region can be a region formed by drawing a circular area with the end skeleton endpoint as the center and the average thickness of the spherical instance as the radius, intersecting with the instance's own mask. It can be used to characterize the local geometry at both ends of the spherical instance.
[0127] The preset aspect ratio threshold can be a preset aspect ratio threshold value used to determine whether a spherical instance belongs to a slender structure, for example, it can be 3.0.
[0128] In some implementations, when the follicular organoid information representation is in a later stage, for each spherical instance in the spherical structure mask image, a morphological thinning algorithm (such as the Zhang-Suen parallel thinning algorithm) is used to peel away the mask edge pixels layer by layer until a one-pixel-wide centerline is obtained. This centerline is the morphological skeleton of the spherical instance. The total number of pixels contained in the morphological skeleton is counted as the skeleton length; simultaneously, the total pixel area of the spherical instance mask is counted, and the total area is divided by the skeleton length and then multiplied by 2 (i.e., average roughness = 2 × area / skeleton length) to obtain the average roughness estimate of the spherical instance.
[0129] Furthermore, for each spherical instance's binary mask, its minimum bounding ellipse can be calculated. This ellipse is the smallest ellipse that completely contains all pixels of the instance, and its principal axis is aligned with the extension direction of the spherical structure. The major and minor axes are extracted from the minimum bounding ellipse, and the aspect ratio of the instance is obtained by dividing the major axis by the minor axis. A larger aspect ratio indicates that the spherical instance is closer to a long, thin strip shape, and is more prone to fragmentation during segmentation.
[0130] In some implementations, for each skeleton pixel on the morphological skeleton, the number of its eight neighboring points that also belong to the skeleton pixel can be counted (i.e., the number of adjacent skeleton pixels). When the number of adjacent skeleton pixels is 1, the skeleton pixel is at the end of the skeleton and is determined as a skeleton endpoint; when the number of adjacent skeleton pixels is greater than or equal to 3, the skeleton pixel is at a fork in the skeleton and is determined as a fork point.
[0131] Specifically, the position coordinates of all skeleton endpoints of the current spherical instance can be obtained, the Euclidean distance between each pair of endpoints can be calculated, and the pair of endpoints with the largest distance can be selected as the two end skeleton endpoints of the instance, located at both ends of the extension direction of the spherical structure.
[0132] Furthermore, circular regions can be drawn with each of the two end skeleton endpoints as the center and the average thickness of the instance as the radius (for example, the minimum radius can be set to 3 pixels). The intersection of each circular region with the mask of the spherical instance itself can be calculated, and the intersection portion can be determined as the end cap region. The remaining portion of the spherical instance mask corresponding to the current spherical instance, excluding the two end cap regions, is determined as the side region.
[0133] In some implementations, for the current spherical instance, morphological dilation can be used to determine which other spherical instances are spatially adjacent to it. Specifically, the binary mask of the current spherical instance is dilated using a circular structuring element with a preset radius (e.g., 10 pixels), causing the mask boundary to expand uniformly outward. If the dilated region intersects with the mask of another spherical instance (i.e., at least one pixel overlaps), then that other spherical instance is determined to be an adjacent instance of the current spherical instance, and subsequent determination of whether to merge is based on the end cap and side contact conditions. For example, if two originally elongated spherical segments that were broken due to segmentation have a breakage distance of less than 10 pixels, they will intersect after dilation and be determined to be adjacent, thus entering the subsequent merging criterion detection; conversely, if two spherical instances are far apart (e.g., 50 pixels apart), they will not intersect after dilation and will not be considered adjacent, thus preventing erroneous merging. This morphological dilation method is simple and efficient, and can quickly filter out spatially adjacent candidate instance pairs, avoiding the need to calculate global pairwise distances for all instances, thus reducing computational complexity. At the same time, the value of the 10-pixel radius can be flexibly adjusted according to the image resolution and the actual size of the sphere to ensure the accuracy of proximity detection.
[0134] In some implementations, for each pair of adjacent instances (current instance i and adjacent instance j), it can be determined whether all merging conditions are met. Specific conditions may include: Condition 1: The aspect ratio of either spherical instance i or spherical instance j is greater than or equal to a preset aspect ratio threshold (exemplarily 3.0), meaning at least one is an elongated structure; Condition 2: The end cap region of spherical instance i and the end cap region of spherical instance j have pixel-level adjacent contact; Condition 3: The end cap region of spherical instance i and the side region of spherical instance j do not have adjacent contact; Condition 4: The end cap region of spherical instance j and the side region of spherical instance i do not have adjacent contact. When all four conditions are met simultaneously, that is, the end cap at one end of the skeleton of spherical instance i and the end cap at one end of the skeleton of spherical instance j are in direct contact with each other, and neither end cap contacts the other's side region, then spherical instance i and spherical instance j are determined to be two fragments of the same spherical structure resulting from segmentation and breakage, and the two are merged into one spherical instance. Alternatively, a disjoint-set data structure can be used to maintain the merging relationship of all instances. When the merging conditions are met, the disjoint-set merge operation is called to merge the sets to which the two instances belong, thereby efficiently handling chain merging scenarios between multiple instances.
[0135] In some implementations, after traversing all instance pairs and completing the disjoint-set union operation, the pixels of all original spherical instances belonging to the same disjoint-set root node can be merged into the same connected region, and the merged region can be assigned a new unique number to form an updated spherical structure mask image.
[0136] By using the above methods, we can avoid miscounting multiple fragments of the same slender spherical part as independent samples due to segmentation and breakage. We can also avoid erroneously merging non-slender adhesive structures caused by the contact between the end cap and the side. This provides spherical mask data with correct instance attribution and coherent boundaries for subsequent skeleton trimming, main axis extraction and maximum cross-sectional thickness measurement.
[0137] In some implementations, to accurately segment a spherical structure into multiple independent spherical parts when it is mistakenly merged into a single instance due to Y-shaped bifurcation and adhesion during the later stages of development, thus correctly restoring the instance attribution, the morphological skeleton of the instance to be determined can be extracted, and the total number of endpoints and bifurcation points can be counted. A cutting process is triggered when the total number of endpoints is three and the bifurcation point is unique. Then, a multi-stage cutting line search is performed based on the branch length from the bifurcation point to each endpoint using a long / short arm criterion, with rotational search and translational supplementation based on preserving the lateral tangent direction. Effective cutting is completed through kerf removal and connected component analysis, achieving accurate separation of adhered structures in complex bifurcation morphologies. For example, when the structural mask image is a spherical structure mask image, after step 103, the following may also be included: (C.1) When the information characterization of hair follicle organoids in the culture stage is in the later stage, for each spherical instance in the spherical structure mask image, the corresponding morphological skeleton is extracted, and the total number of skeleton endpoints and the number of bifurcation points of the morphological skeleton are determined. The bifurcation point is the skeleton pixel in the morphological skeleton with a number of adjacent skeleton pixels greater than or equal to three. (C.2) When the total number of skeleton endpoints is three and the number of bifurcation points is one, the spherical instance is determined as the spherical instance to be cut, and each skeleton branch and its corresponding branch length are determined on the morphological skeleton, with the bifurcation point as the starting point and each skeleton endpoint as the ending point. (C.3) When there are at least two first skeleton branches in the multiple skeleton branches of the morphological skeleton with branch lengths greater than or equal to a preset length threshold, and the ratio between the longer first branch and the shorter second branch is less than or equal to a preset proportion threshold, the skeleton branches to be retained and the skeleton branches to be cut are determined from the two first skeleton branches. The preset length threshold is determined based on the larger value between the preset minimum absolute length threshold and the reference threshold. The reference threshold is calculated based on the product of the preset relative length proportion and the length of the shortest branch among the multiple skeleton branches. (C.4) Select the starting segment skeleton point close to the bifurcation point on the retained skeleton branch, and determine the local tangent direction of the retained skeleton branch at the bifurcation point based on the starting segment skeleton point, and determine the local tangent direction as the initial cutting direction; (C.5) Accumulate the step length along the skeleton branch to be cut from the bifurcation point to the end skeleton endpoint of the skeleton branch to be cut. When the accumulated length reaches the target branch length corresponding to the second skeleton branch, the current skeleton pixel is determined as a candidate cutting point. (C.6) With the candidate cutting point as the center, the initial cutting direction is rotated within a preset angle range with a preset step size to obtain multiple candidate cutting directions. For each candidate cutting direction, the cutting direction is extended bidirectionally to the mask boundary of the current sphere instance to be cut to form a candidate cutting line. A preset kerf thickness is applied to the candidate cutting line to obtain a kerf band. The pixel area covered by the kerf band is removed from the instance mask of the current sphere instance to be cut to obtain the remaining mask area. (C.7) For each spherical instance to be cut, perform connected component analysis on the remaining mask region to obtain multiple spherical sub-instances. In the spherical structure mask image, replace the spherical instance to be cut with multiple spherical sub-instances. Based on the multiple spherical sub-instances corresponding to each spherical instance to be cut, update the spherical structure mask image to obtain the updated spherical structure mask image.
[0138] The total number of skeleton endpoints can be the total number of pixels in the morphological skeleton of a sphere instance whose adjacent skeleton pixels are 1.
[0139] The bifurcation point can be a skeleton pixel in the morphological skeleton with a number of adjacent skeleton pixels greater than or equal to 3, and it is located at the confluence of skeleton branches.
[0140] The number of bifurcation points can be the total number of bifurcation points in the morphological skeleton of a spherical instance.
[0141] Among them, the ball instance to be cut can be a ball instance with a total of 3 skeleton endpoints and 1 bifurcation point. Its topology conforms to the typical Y-shaped bifurcation feature, and it can be used as the processing object for subsequent branch length determination and cutting line search.
[0142] The branch length can be the path length from the bifurcation point along the morphological skeleton to a certain skeleton endpoint.
[0143] The preset length threshold can be a preset minimum absolute length threshold value used to determine whether a branch belongs to the long arm, for example, it can be set to 30 pixels.
[0144] The preset ratio threshold can be a preset maximum ratio threshold used to limit the degree of length difference between the two long arms, for example, it can be set to 2.0.
[0145] Among them, the skeleton branch to be retained can be the one selected from the two first skeleton branches that satisfy the long and short arm criterion and is not cut.
[0146] The skeleton branch to be cut can be the one selected from the two first skeleton branches that satisfy the long and short arm criterion and needs to be cut and separated.
[0147] The starting skeleton point can be a number of consecutive skeleton pixels selected on the side of the preserved skeleton branch near the bifurcation point, for example, 12 to 18 pixels. It can be used to fit the local direction of the preserved branch at the bifurcation point through principal component analysis.
[0148] The local tangent direction can be the direction of the first principal component obtained after performing principal component analysis on the initial skeleton point, which represents the extension direction of the preserved skeleton branch at the bifurcation point.
[0149] The initial cutting direction can be the tangent direction of the retained skeleton branch, which serves as the reference direction for cutting line search and can be used as the reference zero point for angle offset in subsequent rotation search.
[0150] The target branch length can be a target cumulative length value set when accumulating the step length from the bifurcation point to the end on the skeleton branch to be cut. It can be the same as the preset length threshold or determined proportionally according to the branch length. It can be used to determine the position of the candidate cutting point on the branch to be cut.
[0151] Among them, the candidate cutting point can be the skeleton pixel on the skeleton branch to be cut when the cumulative step size from the bifurcation point reaches the target branch length. It serves as the position reference point of the cutting line and can be used to determine the application position of the cutting line on the branch to be cut.
[0152] The preset angle range can be the angle interval for rotating the cutting direction relative to the initial cutting direction, for example, it can be 0° to 90°, and can be used to find cutting lines that can effectively separate branches among multiple candidate directions.
[0153] Among them, the candidate cutting line can be a line segment that extends bidirectionally from the candidate cutting point to the boundary of the mask of the sphere instance to be cut under a certain candidate cutting direction, and it represents the position and direction of a cutting attempt.
[0154] The preset kerf thickness can be a width parameter applied to the candidate cutting line, such as adaptively taking 1, 4 or 7 pixels, which can be used to form a kerf band with a certain width to eliminate the sticky pixels on both sides of the cutting line.
[0155] The remaining mask region can be the mask portion retained after removing the pixel region covered by the slit strip from the original instance mask of the sphere instance to be cut. It can be used to determine whether the cutting has produced more than two independent sub-instances through connected component analysis.
[0156] Here, a spherical sub-instance can be each independent connected region obtained after performing connected component analysis on the remaining mask region, representing each independent spherical unit separated from the original Y-shaped instance after a cutting attempt.
[0157] In some implementations, for each sphere instance in the sphere structure mask image, a morphological thinning algorithm can be used to extract its one-pixel-wide morphological skeleton. Each pixel on the skeleton is traversed, and the number of adjacent pixels in its eight-neighborhood that also belong to the skeleton is counted. When the number of adjacent skeleton pixels is 1, the pixel is a skeleton endpoint. When the number of adjacent skeleton pixels is greater than or equal to 3, the pixel is a bifurcation point. The total number of all skeleton endpoints and the total number of all bifurcation points are counted as the basis data for subsequent Y-type determination.
[0158] Furthermore, when the total number of skeletal endpoints, n_end, of a spherical instance is less than 3, the structure is determined not to have the topological feature of a Y-shaped branch. Specifically, since a Y-shaped structure requires at least three endpoints to form three branches, when the number of endpoints is insufficient, the instance is either a complete straight, slender structure (n_end=2) or a closed loop or isolated point structure (n_end=0 or 1). In this case, the instance does not meet the cutting trigger condition, no cutting operation is required, it is preserved as is, and the subsequent geometric feature analysis process proceeds directly.
[0159] Furthermore, when the total number of skeleton endpoints n_end of a certain spherical instance exceeds the preset maximum endpoint count threshold N_max (e.g., N_max=10), the instance is determined to have excessive fragmentation or abnormal bifurcation. For example, segmentation noise may cause the skeleton to generate numerous short, spiky branches, or segmentation errors may cause multiple independent structures to be glued together, forming a highly complex topology. Such instances exceed the reasonable processing range of Y-shaped cuts, and directly cutting them could easily lead to uncontrollable over-splitting. Therefore, these instances are determined to be invalid structures and deleted, and are not included in subsequent skeleton pruning and geometric feature analysis, thereby avoiding interference from abnormal data on the overall statistical results.
[0160] Furthermore, when the total number of skeleton endpoints of a spherical instance is equal to 3 and the number of bifurcation points is equal to 1, it can be determined that the spherical instance exhibits a typical Y-shaped bifurcation topology, and it is identified as the spherical instance to be cut. Then, using this unique bifurcation point B... Starting from the first point, trace along the skeleton towards the three skeleton endpoints to obtain three skeleton branch paths: path_1, path_2, and path_3. Calculate the length of each path using the 8-neighbor Euclidean distance accumulation method (horizontal or vertical step is counted as 1, diagonal step as 3). ), respectively serving as the branch length for each branch. , , .
[0161] Furthermore, the lengths of the three branches obtained can be... , , Each branch is filtered according to the long-arm criterion. Specifically, for each skeletal branch, a long-arm criterion threshold can be determined first, which is a preset minimum absolute length threshold. (For example, a value of 30 pixels) and the larger of the reference threshold, where the reference threshold can be a preset length ratio R_long (for example, a value of 1.6) and the shortest branch length among multiple skeleton branches. The product of these, i.e., the long-arm determination threshold, is max( ,R_long· ); when the branch length of a certain skeleton branch When it is greater than or equal to the long arm determination threshold, i.e. ≥max( ,R_long· When the skeleton branch is selected, it can be selected as the first skeleton branch (i.e., the long-arm candidate).
[0162] When the number of branches in the first skeleton is at least 2, select the two longest branches, and let their lengths be respectively... and ( ≥ ), calculate the ratio r= / When r ≤ the preset proportional threshold R_balance (for example, R_balance = 2.0), it indicates that the two branches are long arms of roughly equal length, satisfying the Y-shaped cutting condition, and can be cut and separated. Then, the shorter of these two long arms (length is...) The branch with the relatively shorter length is identified as the skeleton branch to be cut, path_cut. The other branch (with a length of...) is then... The branch to be cut and the branch to be kept are determined by the following steps: If two branches have the same length, one branch is designated as the branch to be cut (path_cut) and the other branch is designated as the branch to be kept (path_keep). This method uses explicit numerical judgment to determine the branches to be cut and the branches to be kept in the Y-shaped structure, laying the foundation for determining the subsequent cutting direction.
[0163] In some implementations, starting from the bifurcation point B, a predetermined number (e.g., 12 to 18) of skeleton pixels can be continuously selected along the morphological skeleton towards the end of the preserved skeleton branch path_keep as the initial segment skeleton point set Q. Principal component analysis (PCA) is performed on this point set Q to calculate its covariance matrix and extract the first principal component direction. This direction is the local tangent direction v_tangent of the preserved skeleton branch path_keep at the bifurcation point B, and can be used as the initial cutting direction for subsequent cutting line searches.
[0164] Furthermore, on the skeleton branch to be cut, path_cut, starting from the bifurcation point B, the step size can be accumulated pixel by pixel along the skeleton towards the end. When the accumulated length reaches the preset target branch length... When the target branch length is determined, the current skeleton pixel is identified as the candidate cut point P_cut. It can be the same as the preset length threshold L_min (for example, it can be 30 pixels), or it can be determined proportionally according to the total length of the branch to be cut, so that the candidate cutting point is located in the appropriate position of the branch to be cut.
[0165] In some implementations, the initial cutting direction v_init can be rotated gradually within a preset angle range (exemplarily 0° to 90°) with a preset step size Δθ (exemplarily 10°) centered on the candidate cutting point P_cut. Each rotation angle θ corresponds to a candidate cutting direction v_cut(θ). For each candidate cutting direction v_cut(θ), the line segment extending bidirectionally from the candidate cutting point P_cut along that direction and its opposite direction to the mask boundary of the sphere instance to be cut is the candidate cutting line L_cut. Subsequently, a preset kerf thickness w_cut is applied to the candidate cutting line (e.g., it can be adaptively tried with 1 pixel, 4 pixels, or 7 pixels), that is, with the candidate cutting line L_cut as the center line, w_cut / 2 is extended to both sides to form a kerf band S_cut with a certain width. All pixels covered by the kerf band S_cut are removed from the original instance mask M of the sphere instance to be cut, resulting in the remaining mask region M_remain=M\S_cut.
[0166] Furthermore, connected component labeling can be performed on the remaining mask region M_remain. If the number of connected components N_components ≥ 2, the cutting attempt is deemed valid. Further checks are made to ensure that the pixel area of each connected component is greater than or equal to the preset cutting sub-instance area threshold A_cut_min (exemplarily 20 pixels), and that the number of skeleton endpoints of each connected component satisfies endpoint count ≤ 2 (i.e., no new Y-shaped forks exist). When all the above conditions are met, the cutting is deemed valid. The original sphere instance to be cut is deleted from the sphere structure mask image. The multiple connected components obtained from the cutting are added to the sphere structure mask image as independent sphere sub-instances, and each sub-instance is assigned a new unique number, resulting in an updated sphere structure mask image.
[0167] Furthermore, if no effective cut is produced by trying all candidate cutting directions within the preset angle range, a supplementary search along the skeleton translation is performed. That is, the candidate cutting point P_cut is gradually translated along the shape skeleton of the skeleton branch to be cut towards the end skeleton endpoint with a preset step size step_px (e.g., 5 pixels). The maximum translation amount does not exceed the preset upper limit shift_max (e.g., 60 pixels). At each translation position, the local tangent direction of the skeleton branch at the current branching point is redefined and an angle rotation search is performed until an effective cut is obtained or the translation upper limit is reached. If no effective cut is obtained, the original instance is retained unchanged.
[0168] In some implementations, when the spherical instance to be cut has multiple branching points (i.e., the number of branching points N_branch > 1), an iterative cutting strategy can be adopted. Specifically, the above cutting process can be performed on each branching point separately. Each cut separates a Y-shaped branch. After the cutting is completed, the skeleton is re-extracted and the endpoint and branching point statistics are updated. The next branching point in the remaining structure is then judged and cut until all branching points have been processed or the remaining structure no longer meets the Y-shaped cutting condition. This iterative cutting method can handle complex spherical structures with multi-level branching, further expanding the applicability of the method.
[0169] The above methods can avoid miscutting of non-Y-shaped instances and improve the success rate of cutting in complex adhesion scenarios through multi-strategy search mechanism. In turn, it provides spherical mask data with correct instance attribution and topological independence for subsequent geometric feature measurements such as skeleton length and maximum cross-sectional thickness.
[0170] Step 104: Perform a structure detection operation that matches the corresponding target structure type on each structure mask image to obtain the detection sub-result corresponding to each target structure type.
[0171] In some implementations, in order to transform the pixel-level region information obtained from the segmentation mask into quantitative characterization data with developmental biological significance, and to provide a quantifiable analytical basis for subsequent inter-stage comparisons and inter-group statistics, differentiated measurement and statistical operations can be performed on the morphological and spatial characteristics of different target structure types. Specifically, morphological parameters are detected for the main structure, morphological and spatial distribution parameters are detected for the bud structure, and scale parameters are detected for the spherical structure, so as to extract key quantitative indicators closely related to their developmental state for each type of structure.
[0172] Among them, the detection sub-results can be a set of quantitative indicators obtained after performing structural detection operations on a single target structure type, such as the number of buds, density, nearest neighbor distance statistics and retention ratio output for bud structures, or the number of spheres, skeleton length and maximum cross-sectional thickness output for spherical structures.
[0173] In some implementations, differentiated structure detection operations can be performed based on the final determined target structure type and its corresponding structure mask image. When the target structure type is a main structure, morphological parameter detection operations can be performed on the main structure mask image: the number of main instances contained in the main structure mask image is counted, and the pixel area of each main instance (i.e., the total number of pixels contained in the instance) and the sum and average area of all main instances are calculated. The above statistics constitute the detection sub-result of the main structure, which is used to characterize the overall size and number of hair follicle organs.
[0174] For example, when the target structure type is a bud structure, morphological parameter detection and spatial distribution detection operations can be performed on the bud structure mask image: At the morphological parameter level, the number of bud instances contained in the bud structure mask image is counted, and the pixel area of each bud instance and its mean and standard deviation are calculated; at the spatial distribution level, the centroid coordinates of each bud instance (i.e., the mean of all pixel coordinates of that instance) are first calculated, and then, using the overlap area between the bud instance and the main structure mask as a filtering criterion, the overlap between the mask of that bud instance and all main instances in the main structure mask image is calculated for each bud instance. The overlapping area is divided by the area of the bud instance to obtain the overlap ratio. When the overlap ratio is greater than or equal to the preset retention ratio threshold (exemplarily 20%), the bud instance is determined as a valid target and retained; otherwise, it is determined as a pseudo-target detached from the main body and removed. Then, the bud density is calculated based on the target bud instance (i.e., the number of target buds divided by the area of the main instance and multiplied by the preset normalization coefficient). Based on the Euclidean distance between the centroids of each target bud, the nearest neighbor distance of each bud and its mean, standard deviation, minimum and maximum values are calculated. All the above morphological and spatial statistics together constitute the detection sub-result of the bud structure.
[0175] Furthermore, when the target structure type is a spherical structure, a scale detection operation can be performed on the spherical structure mask image: count the number of spherical instances contained in the spherical structure mask image, extract the morphological skeleton of each spherical instance and calculate the total number of skeleton pixels as the skeleton length, locate the geometric center through Euclidean distance transformation, search for the longest path on the pruned skeleton as the principal axis and scan along the principal axis at multiple points to obtain the maximum cross-sectional thickness, and finally output the total number of spherical instances, the skeleton length of each instance and the average skeleton length, the maximum cross-sectional thickness of each instance and the average value, etc. The above indicators together constitute the detection sub-result of the spherical structure.
[0176] It should be noted that the composition of the detection sub-results differs depending on the target structure type determined at different developmental stages. For example, in the early stage, since only the main structure is identified as the target structure type, morphological parameter detection is performed only on the main structure mask image to obtain the detection sub-results corresponding to the main structure (including the number of main structure instances and the area of each instance). In the intermediate stage, since both the main structure and the bud structure are identified as target structure types, corresponding detection operations are performed on the main structure mask image and the bud structure mask image respectively to obtain the main structure detection sub-results and the bud structure detection sub-results (including the total number of bud instances, bud area, bud selection and retention ratio, bud density, and nearest neighbor distance statistics). In the late stage, since both the main structure and the spherical structure are identified as target structure types, corresponding detection operations can be performed on the main structure mask image and the spherical structure mask image respectively to obtain the main structure detection sub-results and the spherical structure detection sub-results (including the total number of spherical instances, skeleton length, and maximum cross-sectional thickness).
[0177] The above methods enable the various structural masks obtained after segmentation to be transformed into multi-dimensional quantitative data with developmental biological significance, thereby providing a structured computational basis for subsequent cross-sample comparisons, drug treatment effect assessments, and developmental stage discrimination.
[0178] In some implementations, to distinguish real hairs from pseudo-targets detached from the subject and provide comparable spatial distribution indicators, the centroid coordinates of each hair instance can be calculated. Internal hair screening is performed using whether the centroid falls within the foreground region of the subject mask as a retention criterion. Then, based on the number of effective hairs and the centroid positions, statistical measures such as the mean and standard deviation of hair density and nearest neighbor distances are calculated to quantitatively characterize the spatial aggregation and dispersion of hairs. For example, step 104 may include: (104.a1) When the information characterization of hair follicle organoids during the culture stage is in the intermediate stage, determine the main structure mask image and hair bud structure mask image corresponding to the intermediate stage; (104.a2) For each hair instance contained in the hair structure mask image, determine the hair instance pixel coordinates of each corresponding hair instance pixel, and calculate the hair centroid coordinates based on the mean of multiple hair instance pixel coordinates corresponding to each hair instance. (104.a3) For each hair instance contained in the hair structure mask image, calculate the target overlap area between each hair instance and at least one corresponding main instance. When the target overlap area is greater than a preset retention threshold, retain the corresponding hair instance as a target hair instance. (104.a4) Calculate the hair bud screening retention ratio based on the ratio between the first number of multiple target hair bud instances corresponding to the hair bud structure mask image and the second number of multiple hair bud instances contained in the hair bud structure mask image. (104.a5) Based on the main structure mask image, determine the area of the main instances of the multiple main instances contained therein, and calculate the bud density based on the first quantity and the area of the main instances; (104.a6) For each target bud instance, calculate the centroid distance between the corresponding target centroid coordinates and the adjacent target centroid coordinates of each adjacent target bud instance, and determine the minimum centroid distance from the multiple centroid distances corresponding to multiple adjacent target bud instances as the nearest neighbor distance of the current target bud instance. (104.a7) Based on the nearest neighbor distances corresponding to multiple target hair bud instances, calculate the mean centroid distance, standard deviation of centroid distance, maximum centroid distance, and minimum centroid distance; (104.a8) Based on the first quantity, the retention ratio of hair buds, the hair bud density, the mean centroid distance, the standard deviation of centroid distance, the maximum centroid distance, and the minimum centroid distance, generate the detection sub-results corresponding to the hair bud structure.
[0179] The pixel coordinates of the bud instance can be the position coordinates of each pixel contained in a bud instance in the image coordinate system, specifically, it can be a set of binary mask foreground point coordinates represented by row and column indices.
[0180] Among them, the centroid coordinates of the hair bud can be the coordinates of the center point obtained by taking the arithmetic mean of all pixel coordinates of a certain hair bud instance, which can be used as a reference point for determining the ownership of the current hair bud instance.
[0181] The target bud instance can be any bud instance whose centroid coordinates are located within the foreground region of the main structure mask, among all bud instances.
[0182] The hair bud retention ratio can be the percentage obtained by dividing the first number of target hair bud instances by the second number of original hair bud instances. It can be used to reflect how much of the segmented hair buds are actually located inside the main structure.
[0183] The area of the main instance can be the total number of pixels contained in a main instance.
[0184] Among them, bud density can be used to characterize the abundance level of buds inside the main structure.
[0185] The centroid distance can be the Euclidean distance between the centroid coordinates of two target bud instances, which can be used to measure the spatial proximity between buds.
[0186] The nearest neighbor distance can be the minimum centroid distance between a given target bud instance and all other target bud instances, and it can be used to characterize the spatial interval between the bud and its nearest neighbor bud.
[0187] In some implementations, when the culture stage information characterizes the hair follicle organoids as being in the intermediate stage (culture days d satisfying the condition), <d≤ When performing segmentation, the corrected main structure mask image and the corrected bud structure mask image can be obtained from the segmentation results as input data for subsequent bud spatial distribution statistics.
[0188] Furthermore, for the i-th bud instance in the bud structure mask image, the set of position coordinates P_i={(x,y)|(x,y)∈bud instance i} of all pixels contained in this instance in the image coordinate system can be obtained, where the total number of pixels in this set is... Divide the sum of the x-coordinates of all pixels in the set by the total number of pixels. This gives us the row coordinates of the centroid; the sum of the column coordinates (y) of all pixels divided by the total number of pixels. The column coordinates of the centroid can be obtained, and the two together constitute the centroid coordinates of the hair bud instance.
[0189] Specifically, for the centroid coordinate c_i of each bud instance, the pixel value M_L_exp(c_i) of that coordinate position on the extended mask M_L_exp of the main structure can be checked. If M_L_exp(c_i) > 0, meaning the position belongs to the foreground region of a certain main instance, then the bud instance is determined to be inside the main structure and marked as a target bud instance and retained; if M_L_exp(c_i) = 0, meaning the position is in the background region of the main mask, then the bud instance is determined to be a pseudo-target detached from the main object and is discarded. Through this method, accurate screening of buds inside the main object can be achieved.
[0190] In some implementations, the total number of all hair bud instances in the original hair bud structure mask image can be counted as the second quantity N_total, and the total number of target hair bud instances retained after centroid screening can be counted as the first quantity N (i.e., the number of hair bud instances that satisfy M_L_exp(c_i)>0). The first quantity N is divided by the second quantity N_total and then multiplied by 100% to obtain the hair bud screening retention ratio ratio=(N / N_total)×100%. This ratio reflects how much of the segmented hair buds are actually located inside the main structure.
[0191] In some implementations, the total number of all foreground pixels in the main structure mask image can be counted as the main instance area A. The first number N of target hair bud instances is divided by the main instance area A and then multiplied by a preset normalization coefficient (exemplarily 10). 6 ), thus obtaining the bud density ρ=N / (A / 10 6 (Unit: buds / megapixel), this indicator is called bud density (buds / megapixel), which can be used to characterize the abundance level of buds inside the main structure.
[0192] Furthermore, for the i-th target bud instance, its centroid coordinate c_i can be compared with the centroid coordinates c_j (j≠i) of all other target bud instances to calculate the Euclidean distance D_ij, resulting in a distance set {D_i1,D_i2,...,D_iN} (where the diagonal element D_ii is set to +∞ to avoid its own comparison). The minimum value in this set is taken as the nearest neighbor distance NND_i=min_{j≠i}D_ij for the i-th target bud instance. When the number of target bud instances N=1, there are no other bud instances that form a distance pair with it, and its nearest neighbor distance can be defined as a preset maximum distance constant or marked as an invalid value.
[0193] Furthermore, the nearest neighbor distances {NND_1,NND_2,...,NND_N} of all target bud instances can be constructed into a numerical sequence. The arithmetic mean of this sequence is calculated as the centroid distance mean μ_NND=(1 / N)·ΣNND_i, and the standard deviation of this sequence is calculated as the centroid distance standard deviation σ_NND. The maximum value NND_max and the minimum value NND_min in the sequence are then extracted. These four statistics (mean μ_NND, standard deviation σ_NND, maximum value NND_max, and minimum value NND_min) together describe the spatial clustering and dispersion of buds within the host.
[0194] In some implementations, the aforementioned nine indicators—the first number N of target bud instances, the bud selection and retention ratio, the bud density ρ, the mean nearest neighbor distance μ_NND, the standard deviation of the nearest neighbor distance σ_NND, the maximum nearest neighbor distance NND_max, the minimum nearest neighbor distance NND_min, and the list of pixel areas of each target bud instance and their average values (i.e., bud area and average bud area)—can be summarized to form the detection sub-result corresponding to the bud structure. Among these, N, ratio, ρ, μ_NND, σ_NND, NND_max, NND_min, bud area, and average bud area together constitute the complete set of output indicators for the bud structure. Optionally, the distribution range of the centroid coordinates of each bud instance (i.e., the smallest bounding rectangle size of the centroid on the image plane) can be further statistically analyzed and included as a supplementary spatial distribution parameter in the bud structure detection sub-result to provide a more comprehensive characterization of the bud development state.
[0195] The above methods can solve the problem of distinguishing between nested substructures and external noise. They also quantitatively characterize the aggregation and discrete distribution patterns of hair buds within the main body through multidimensional spatial statistical indicators, thus providing a repeatable spatial quantitative basis for evaluating the effects of drug treatments and comparing developmental differences between different culture conditions.
[0196] In some implementations, the geometric center can be located by distance transformation, short branches can be removed by pruning the skeleton, and the longest continuous path can be searched on the pruned skeleton starting from the geometric center as the principal axis. Then, normal scanning can be performed point by point along the principal axis to obtain multiple sets of candidate cross-sectional thicknesses and the maximum value can be taken to obtain stable and repeatable geometric quantization results on slender and irregular structures. For example, the structural mask image can be a spherical structure mask image, and step 104 may include: (104.b1) When the information characterization of hair follicle organoids during the culture stage is in the late stage, determine the mask image of the bulbous structure corresponding to the late stage; (104.b2) For each sphere instance contained in the sphere structure mask image, extract the corresponding morphological skeleton, and determine the skeleton endpoints and bifurcation points of the morphological skeleton based on the number of adjacent skeleton pixels of each skeleton pixel on the morphological skeleton. (104.b3) For each spherical instance, starting from each skeleton endpoint, determine the nearest target bifurcation point along the morphological skeleton, and determine the branch length corresponding to each skeleton endpoint based on the current skeleton endpoint and the target bifurcation point, and delete branches whose branch length is less than the preset branch length threshold to obtain the trimmed morphological skeleton. (104.b4) For each spherical instance, perform Euclidean distance transformation on the structure mask image corresponding to the spherical instance to obtain the distance value of each pixel to the nearest mask boundary, and determine the pixel with the largest distance value as the geometric center pixel of the spherical instance; (104.b5) For each sphere instance, on the trimmed morphological skeleton, starting from the geometric center pixel, determine the longest continuous path between the skeleton endpoints, and determine the continuous path as the main axis; (104.b6) Determine the set of morphological skeleton points adjacent to the geometric center pixel on the principal axis, and determine the local tangent direction of the geometric center pixel based on the morphological skeleton point set. Search from the geometric center pixel to the boundary of the current sphere instance according to the direction orthogonal to the local tangent direction to obtain two target boundary points. Based on the distance between the two target boundary points, obtain the candidate cross section thickness of the geometric center pixel, and calculate the next candidate cross section thickness based on the updated morphological skeleton point set. (104.b7) Repeat the step of calculating multiple candidate cross-sectional thicknesses based on the updated morphological skeleton point set until the preset number of updates is reached, and select the largest target cross-sectional thickness from the multiple candidate cross-sectional thicknesses. (104.b8) Based on the number of multiple spherical instances contained in the spherical structure mask image, the number of target skeleton pixels corresponding to the trimmed morphological skeleton of each spherical instance, the number of principal axis pixels corresponding to the principal axis, and the target cross-sectional thickness, the detection sub-results corresponding to the spherical structure are obtained.
[0197] The number of adjacent skeleton pixels can be the number of adjacent points of a skeleton pixel in the eight-neighbor area centered on a certain skeleton pixel on the morphological skeleton. For example, the number of adjacent points corresponding to an endpoint is 1, and the number of adjacent points corresponding to a bifurcation point is greater than or equal to 3.
[0198] The target bifurcation point can be the first bifurcation point encountered during the inward tracing of the morphological skeleton from a certain skeleton endpoint, that is, a skeleton pixel with a number of adjacent skeleton pixels greater than or equal to 3. It can be used to define the termination position of the branch where the endpoint is located, and to calculate the branch length of the branch to determine whether to prune it.
[0199] The geometric center pixel can be the pixel with the largest distance value among all pixels inside the mask after performing Euclidean distance transformation on the binary mask of the spherical instance, that is, the pixel located at the center of the deepest part of the structure.
[0200] The main axis can be the longest continuous path between the two skeleton endpoints, starting from the geometric center pixel, on the trimmed morphological skeleton.
[0201] The candidate cross section thickness can be the Euclidean distance between two boundary points obtained by bidirectional scanning from the geometric center pixel to the sphere mask boundary along the local normal direction at a certain position on the principal axis. It can be used as a measurement value of the sphere diameter at that position.
[0202] The preset update count can be a predetermined number of times to repeatedly perform normal scan measurements by moving sampling points along the extension direction on the main axis. Specifically, it can be moving along the main axis with a fixed step size and measuring the cross-sectional thickness point by point until the set number of sampling points is reached. It can be used to control the sampling density of the cross-sectional thickness measurement to cover different sections of the sphere.
[0203] The target cross-sectional thickness can be the thickness value obtained by taking the maximum value among all candidate cross-sectional thicknesses, which can represent the maximum width of the spherical structure in the direction perpendicular to the principal axis.
[0204] In some implementations, when it is determined that the current hair follicle organoid is in a late stage (culture days d are greater than a third preset threshold) When performing segmentation, the spherical structure mask image after end-to-end merging and cutting updates is obtained from the segmentation results and used as input data for subsequent skeleton and geometric feature analysis.
[0205] Furthermore, for the binary mask M of each sphere instance in the sphere structure mask image, a morphological thinning algorithm can be used to extract its one-pixel-wide morphological skeleton SK. For each pixel p on the morphological skeleton SK, the number of its eight neighboring pixels N_neighbor(p) that also belong to the morphological skeleton is counted. When N_neighbor(p) = 1, the pixel is marked as a skeleton endpoint; when N_neighbor(p) ≥ 3, the pixel is marked as a bifurcation point.
[0206] Specifically, for each skeleton endpoint e, we can trace inward along the morphological skeleton SK from that endpoint until we encounter the first bifurcation point b. This bifurcation point b is the nearest target bifurcation point corresponding to endpoint e, and the skeleton path length between endpoint e and target bifurcation point b is the branch length corresponding to that endpoint. When the branch length Less than the preset branch length threshold When the value is 10 pixels, the branch is determined to be a spur or a short branch, and the branch is removed from the morphological skeleton SK. After performing the above operation on all endpoints, a pruned morphological skeleton with short branches removed can be obtained. .
[0207] Furthermore, for the binary mask M of the sphere instance, its Euclidean distance transform (EDT) can be calculated. That is, for each foreground pixel p within the mask, its Euclidean distance to the nearest background pixel is calculated. The larger the distance value D(p), the deeper the pixel is into the structure. All foreground pixels can be traversed, and the pixel p with the largest distance value can be selected. =argmax_p D(p) is the geometric center pixel of this sphere instance.
[0208] Furthermore, the skeletal structure after trimming can be further refined. Above, with the geometric center pixel p Starting from point P, determine the longest continuous path between the skeleton endpoints, and define this continuous path as the principal axis L of the sphere instance. If the geometric center pixel p... If the path is located at a bifurcation point, calculate the length of each path that passes through the endpoints of the bifurcation point and select the longest path as the main axis L.
[0209] On the principal axis L, select pixel p at the geometric center. A set of consecutive skeleton pixels within a predetermined neighborhood of the center (exemplarily a radius of 5 pixels) constitutes a morphological skeleton point set Q. Principal component analysis (PCA) is performed on this point set Q to calculate its covariance matrix, and the direction of the first principal component is extracted as the geometric center pixel p. Local tangent direction at the location , local tangent direction Rotate 90° to obtain the normal direction v⊥. From the geometric center pixel p... Starting from the normal direction v⊥ and its opposite direction, scan pixel by pixel to the boundary of the sphere instance mask, and record the coordinates of the boundary points in both directions. and Calculate the Euclidean distance T_local between two boundary points. That is, the geometric center pixel p The candidate cross-sectional thickness is determined at the specified location. Then, the center position is moved one end along the main axis L by a preset step size (e.g., 1 pixel), the morphological skeleton point set Q is updated, and the above normal scan process is repeated to obtain the candidate cross-sectional thickness at the next location.
[0210] In some implementations, the distance can be from the geometric center pixel p along the main axis L. The algorithm moves pixel by pixel towards both ends, repeating normal scanning and cross-sectional thickness measurement at each position until the total number of moves along the principal axis reaches a preset update count K (e.g., 10 times, i.e., taking 5 sampling points from the geometric center to both ends along the principal axis), or until it reaches the endpoint of the principal axis. The candidate cross-sectional thicknesses measured at all sampling positions are then compiled into a sequence. Take the maximum value in the sequence. The target cross-sectional thickness is used as an example of the spherical part.
[0211] In some implementations, the following three core metrics of all sphere instances can be summarized: the total number of sphere instances N_bulb, the pruned morphological skeleton of each instance, and so on. Number of pixels (i.e., skeleton length) The three indicators—the standard deviation of the skeleton length and the standard deviation of the target cross-sectional thickness T for each instance, and the standard deviation of the target cross-sectional thickness T for each instance—constitute the complete output indicator set for the spherical structure. Optionally, the standard deviation of the skeleton length and the standard deviation of the target cross-sectional thickness for each instance can be further calculated to reflect the degree of variation within the population. In addition, the principal axis length L_axis, area A, and perimeter P for each spherical instance can be calculated, and the average coarseness d_i = 2·A / L_skel can be calculated based on the area A and the skeleton length L_skel. These can be included in the detection sub-results as supplementary geometric parameters for the developmental state of the spherical structure to provide a more comprehensive characterization of the spherical morphology.
[0212] For example, besides measuring the maximum cross-sectional thickness by scanning the multi-point normal along the principal axis and taking the maximum value, the maximum distance method using the central axis transformation can also be used. Specifically, for the binary mask M of each spherical instance, a central axis transformation can be performed to obtain a one-pixel-wide central axis skeleton SK_med and the distance value d(p) from each central axis pixel to the nearest mask boundary. Taking the maximum value of d(p) on the central axis skeleton SK_med, d_max = max_{p∈SK_med} d(p), then the maximum cross-sectional thickness T of the spherical instance is T = 2·d_max. It should be noted that the distance value from each pixel on the central axis skeleton to the boundary represents the radius of the inscribed circle of the structure at that location. Taking the maximum distance value on the morphological skeleton and multiplying it by 2 gives the maximum diameter of the inscribed circle of the structure at that location, which is also the maximum cross-sectional thickness.
[0213] In some implementations, when measuring the maximum cross-sectional thickness, in addition to point-by-point uniform sampling along the principal axis L, an adaptive sampling strategy based on skeleton distance transformation can also be used. Specifically, this can be achieved on the trimmed skeleton. At each pixel location p, the Euclidean distance transform value D(p) reflects the local width information from that location to the boundary. When the D(p) value at a certain location changes significantly compared to its neighboring locations (e.g., the rate of change exceeds a preset threshold), it indicates that the location is in the expansion or contraction region of the spherical structure. In this case, the sampling density is increased at that location and in its neighborhood; while in regions where the width change is gradual, sparse sampling is maintained. Through this adaptive sampling method, the cross-sectional thickness variation of different segments of the spherical structure can be captured more accurately without increasing the total number of samples, thus improving the reliability of the maximum cross-sectional thickness T measurement.
[0214] In some implementations, the cross-sectional thickness of the spherical structure can also be obtained by solving for the minor axis length of the minimum circumscribed ellipse. Specifically, for each spherical instance, its minimum circumscribed ellipse can be calculated, and the minor axis length of this ellipse can be directly extracted as a measure of the cross-sectional thickness. Compared to the method of scanning the normal point by point along the principal axis L and taking the maximum value, the minor axis of the minimum circumscribed ellipse provides an estimate of the average width of the entire structure. The two methods complement each other and can be selected or combined according to actual needs in different application scenarios.
[0215] By using the above methods, we can avoid the deviation of the main axis direction caused by burrs and short branches. We can also overcome the problem of insufficient representativeness of single-point measurement on slender and irregular structures by sampling at multiple points and taking the maximum value. This provides a stable and reliable geometric quantitative basis for subsequent comparison of developmental status across samples and culture stages and evaluation of drug treatment effects.
[0216] Step 105: Based on the detection sub-results corresponding to at least one target structure type, generate the detection results corresponding to hair follicle organoids; The types of structure detection operations include at least the morphological parameter detection operation of multiple main body instances in the corresponding structure mask image for the main body structure, or the morphological parameter detection operation of multiple bud instances in the corresponding structure mask image for the bud structure and the spatial distribution detection operation of multiple bud instances, or the scale detection operation of multiple spherical instances for the spherical structure.
[0217] In some implementations, in order to aggregate the detection sub-results corresponding to all target structural types of current hair follicle organoids and organize the output according to a preset format, the quantitative indicators of various structures can be presented collaboratively within the same framework, thereby providing a structured data output foundation for phenotypic database construction and high-throughput drug efficacy evaluation.
[0218] Among them, the morphological parameter detection operation can be a calculation process that extracts basic geometric attributes such as the number of instances and pixel area from a binary mask of the main structure or the bud structure. For example, it can count the number of instances and the total area of the main structure, or count the number of instances and the average area of the bud.
[0219] Among them, the spatial distribution detection operation can be a process of quantitatively describing the spatial arrangement characteristics of hair buds within the main body by using spatial statistical indicators such as nearest neighbor distance and density, targeting the centroid coordinate set of hair bud structure. For example, it can calculate the mean and standard deviation of the nearest neighbor distance of hair buds, hair bud density, and the screening and retention ratio.
[0220] Among them, the scale detection operation can be a process of extracting geometric scales such as the number of instances, skeleton length and maximum cross-sectional thickness by using a binary mask for the spherical structure through skeleton analysis and normal scanning. For example, it can count the number of spherical instances, the total skeleton length of each instance and the target cross-sectional thickness value, which can be used to characterize developmental maturity indicators such as the extension length and expansion degree of the spherical structure.
[0221] In some implementations, the sub-results obtained after performing structural detection operations on various target structures can be summarized and organized according to a preset format to form a complete detection result corresponding to the bright-field image of the hair follicle organoid. The detection result includes at least the category identifier of the target structure type and the corresponding quantitative index data for each category. It may also include the mask image file path for each structure instance, the storage path of the visualization overlay, and the parameter configuration record during the detection process. When the detection result involves multiple target structure types (e.g., the main structure and bud structure in the intermediate stage, or the main structure and bulb structure in the late stage), the detection sub-results corresponding to each type of structure can be grouped and stored in the corresponding field column of the same data structure or the same CSV report, so that downstream analysis modules or users can perform cross-category correlation queries and comparisons. The final generated detection result can be output as a structured data file (e.g., a comma-separated value file) or simultaneously as a visualization report to support subsequent statistical analysis, drug effect assessment, and the construction of a standardized phenotypic database.
[0222] Specifically, the morphological parameter detection operation for the main structure may include: obtaining the ID and pixel set of all main instances in the main structure mask image, and counting the total number of main instances; for each main instance, calculating the total number of pixels it contains as the area, and calculating the sum of areas, average area and standard deviation of areas based on the areas of all main instances; and using the above-mentioned number of main instances and each area statistic as the detection sub-result of the main structure.
[0223] Specifically, the morphological parameter detection and spatial distribution detection operations for the bud structure can include: obtaining the ID and pixel set of all bud instances in the bud structure mask image, counting the total number of bud instances, and calculating the area, mean, and standard deviation of each bud instance as the morphological parameter detection sub-result; based on this, calculating the centroid coordinates of each bud instance, selecting effective buds based on whether the centroid falls within the foreground area of the main structure mask, counting the number of effective buds, calculating the bud retention ratio and bud density, and constructing a distance matrix for the centroids of all effective buds to calculate the nearest neighbor distance, mean, standard deviation, minimum, and maximum values of each bud as the spatial distribution detection sub-result.
[0224] Specifically, the scale detection operation for spherical structures may include: obtaining the IDs and pixel sets of all spherical instances in the spherical structure mask image, and counting the total number of spherical instances; for each spherical instance, extracting its pruned morphological skeleton and calculating the number of skeleton pixels as the skeleton length, while using Euclidean distance transformation to locate the geometric center, searching the longest path on the pruned skeleton as the principal axis, and scanning along the principal axis with multiple point normals to obtain the maximum cross-sectional thickness; calculating the mean and standard deviation of the skeleton length and the mean and standard deviation of the maximum cross-sectional thickness based on all spherical instances, and using the above-mentioned number of spherical instances and the statistics of each geometric scale as the detection sub-result of the spherical structure.
[0225] For example, in addition to outputting the detection results as a structured data file, a PDF detection report containing a mask overlay visualization image and quantitative indicator annotations can be automatically generated. Specifically, the original brightfield image and various structural masks can be color-overlayed at preset transparency, and key quantitative indicators (such as the number of main bodies, bud density, maximum cross-sectional thickness of the sphere, etc.) can be annotated in text boxes next to or below the image, generating a one-page or multi-page detection report with mixed text and images. This detection report can be automatically archived to the experimental database, making it convenient for researchers to use directly for experimental records and result reporting, without the need for additional manual organization and formatting.
[0226] In some implementations, developmental status can be automatically determined based on the output detection results. Specifically, key quantitative indicators in the detection results (such as the number of bulbils, target cross-sectional thickness, and bud density) can be compared with pre-established reference ranges for each developmental stage. When a key indicator falls within a certain stage's reference range, the predicted developmental stage label for that hair follicle organoid is automatically output, while abnormal indicators deviating from the reference range are marked. This function can assist researchers in quickly screening samples with developmental abnormalities or significant drug treatment effects, improving data interpretation efficiency in high-throughput screening scenarios.
[0227] This application embodiment obtains the culture stage information corresponding to the bright-field image of hair follicle organoids; determines at least one target structure type corresponding to the bright-field image based on the culture stage information, and selects a matching target segmentation model from multiple pre-trained instance segmentation models for each target structure type. The target structure types include main structures, bud structures, and bulb structures. Using each target segmentation model corresponding to each target structure type, a structure mask image for each target structure type is output based on the bright-field image. A structure detection operation matching the corresponding target structure type is performed on each structure mask image to obtain a detection sub-result corresponding to each target structure type. Based on the detection sub-result corresponding to at least one target structure type, a detection result corresponding to the hair follicle organoid is generated. The structure detection operation types include, at least, for the main structure, morphological parameter detection of multiple main instances in the corresponding structure mask image; for the bud structure, morphological parameter detection of multiple bud instances in the corresponding structure mask image and spatial distribution detection of multiple bud instances; or for the bulb structure, scale detection of multiple bulb instances. In this way, a stage-adaptive multi-structure collaborative processing mechanism can be used to dynamically adapt the segmentation and detection strategies required for the main structure, bud structure and spherical structure at different developmental stages. Specifically, this application introduces information about the developmental stage as a priori condition for segmentation strategy selection, enabling the system to know in advance the developmental stage of the current sample and determine the target structure type that actually needs to be detected at that stage (e.g., only the main body is needed in the early stage, the main body and buds are needed in the middle stage, and the spherical structure is needed in the later stage). Then, a dedicated segmentation model finely tuned with specific structural data is independently called for each target structure type, avoiding problems such as missed buds and segmentation errors caused by a one-size-fits-all approach to all structures. On this basis, this application further designs differentiated structure detection operations for the geometric and spatial characteristics of different target structure types. The main body structure performs morphological parameter detection to quantify the overall contour attributes, the bud structure performs morphological parameter detection and spatial distribution detection simultaneously to characterize the aggregation and dispersion patterns in nested scenes, and the spherical structure performs scale detection to capture the features of slender extension and bifurcation morphology. Thus, the detection operations of each type of structure are matched with their own biological morphological laws, solving the problem that a unified processing method cannot adapt to the coexistence and dynamic evolution characteristics of multiple structures. In summary, this application can employ the optimal segmentation model and detection strategy for the differentiated structural composition and morphological characteristics of hair follicle organs at different developmental stages, thereby effectively improving the accurate detection capability of hair follicle organs throughout their entire developmental cycle.
[0228] In some embodiments, the overall detection process for hair follicle organoids throughout the entire developmental cycle of this application is described. Specifically, firstly, the input bright-field image and its corresponding culture days can be acquired and analyzed. Then, based on the comparison between the culture days and a preset threshold, the culture stage information of the hair follicle organoid corresponding to the bright-field image is determined. Based on the culture stage information, the corresponding detection method is selected to obtain the final detection result and output it.
[0229] Specifically, in the early and mid-early stages, hair follicle organoids only possess the main structure and have not yet formed hair buds or bulbils; therefore, the target structure type is determined solely to be the main structure. Both stages utilize the main structure segmentation model, but the difference lies in the configuration: in the early stage, a first detection scale parameter (e.g., d_L1=150 pixels) is configured to accommodate small-volume subjects; if this configuration is invalid, it automatically reverts to the second detection scale parameter for re-segmentation. In the mid-early stage, the second detection scale parameter (e.g., d_L2=520 pixels) is directly configured to accommodate the larger main structure. Neither stage requires post-processing related to substructures; the main structure mask image output by the main segmentation model is directly fed into the detection sub-result generation stage after area filtering.
[0230] In the intermediate stage, the main structure and bud structure of hair follicle organoids coexist, therefore the target structure type is determined to be the main structure and the bud structure. The system can simultaneously call the main structure segmentation model (configured with the second detection scale parameter) and the bud structure segmentation model (configured with independent parameters suitable for small-scale targets, for example, the target diameter d_S = 30 pixels), and output the main structure mask image and the bud structure mask image respectively. The bud structure mask image is first filtered by area (e.g., A_min = 3000 pixels) to remove noisy instances, and then performs parent-child structure attribution determination and mask expansion: the overlap area of each bud instance and each main instance is calculated, the main instance with the largest overlap area is taken as the parent instance, and valid buds are retained based on the comparison of the overlap ratio R_i and the preset retention threshold θ_keep (e.g., 0.2). At the same time, based on the comparison of the overlap ratio R_i and the preset expansion threshold θ_union (e.g., 0.2), out-of-bounds pixels are incorporated into the main mask, resulting in a corrected main structure mask image and a bud structure mask image with a clear parent-child topological relationship. Finally, based on the corrected hair structure mask image, the spatial distribution statistics of hair are performed, and the total number of hair instances, the hair retention rate, hair density, and nearest neighbor distance statistics are output.
[0231] In the later stages, the main structure and bulbous structure of hair follicle organoids coexist, so the target structure type can be determined as the main structure and the bulbous structure. The system calls the main structure segmentation model (configuring the second detection scale parameter) and the bulbous structure segmentation model. The main structure segmentation model directly outputs the main structure mask image; after the bulbous structure segmentation model outputs the probability map, it first performs the double threshold and watershed composite segmentation in step 103.3 (the first probability threshold τ_high and the second probability threshold τ_low, exemplarily corresponding to probability values of 0.97 and 0.74) to obtain the initial mask image of the bulbous structure. Subsequently, the slender structure fracture repair (end-to-end merging) is performed: for each pair of adjacent bulbous instances, based on the composite conditions of aspect ratio AR_i≥AR_thr (e.g., 3.0), end caps adjacent to end caps, and end caps not adjacent to sides, the same source fracture fragments are merged through a disjoint-set data structure to obtain the merged bulbous structure mask image. Next, perform automatic Y-shaped structure cutting: For the spherical instance to be cut where the total number of skeleton endpoints n_end=3 and the number of bifurcation points is 1, the cutting can be based on the branch length. Long arms are filtered using a preset length threshold L_min (e.g., 30 pixels) and a preset ratio threshold R_balance (e.g., 2.0). Separation is achieved through a multi-stage cutting line search (left-right rotation search → up-down rotation search → translational supplementary search along the tangent), resulting in an updated spherical structure mask image. Next, parent-child structure attribution determination and mask expansion are performed to establish the parent-child topological relationship between spherical instances and main body instances, and the main body mask is synchronously corrected. Finally, morphological skeleton and geometric feature analysis can be performed based on the corrected spherical structure mask image, outputting geometric indicators such as the total number of spherical instances, skeleton length, and maximum cross-sectional thickness. The detection sub-results output from each stage are summarized to generate a CSV report containing all quantitative indicators and a visual overlay, completing a fully automated analysis chain from the original image to structured phenotypic data.
[0232] Please see Figure 3 This application embodiment also provides a device for detecting hair follicle organoid images, which can implement the above-mentioned method for detecting hair follicle organoid images. The device for detecting hair follicle organoid images includes: The acquisition module 31 is used to acquire culture stage information corresponding to the bright field image of hair follicle organoids; Module 32 is selected to determine at least one target structure type corresponding to the bright field image based on the cultivation stage information, and for each target structure type, a matching target segmentation model is selected from multiple pre-trained instance segmentation models. The target structure types include main structure, bud structure and spherical structure. Output module 33 is used to output a structure mask image for each target structure type based on the bright field image, using each target segmentation model corresponding to each target structure type. Detection module 34 is used to perform a structure detection operation that matches the corresponding target structure type on each structure mask image, and obtain the detection sub-result corresponding to each target structure type; The generation module 35 is used to generate the detection result corresponding to the hair follicle organoid based on the detection sub-result corresponding to at least one target structure type. The types of structure detection operations include at least the morphological parameter detection operation of multiple main body instances in the corresponding structure mask image for the main body structure, or the morphological parameter detection operation of multiple bud instances in the corresponding structure mask image for the bud structure and the spatial distribution detection operation of multiple bud instances, or the scale detection operation of multiple spherical instances for the spherical structure.
[0233] The specific implementation of the hair follicle organoid image detection device is basically the same as the specific embodiment of the hair follicle organoid image detection method described above, and will not be repeated here. Subject to meeting the requirements of the embodiments of this application, the hair follicle organoid image detection device may also be equipped with other functional modules to implement the hair follicle organoid image detection method in the above embodiments.
[0234] This application also provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described method for detecting hair follicle organoid images. This computer device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0235] Please see Figure 4 , Figure 4 The hardware structure of a computer device according to another embodiment is illustrated. The computer device includes: The processor 41 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application. The memory 42 can be implemented in the form of read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 42 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 42 and called by the processor 41 to execute the hair follicle organoid image detection method of the embodiments of this application. Input / output interface 43 is used to implement information input and output; The communication interface 44 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 45 transmits information between various components of the device (e.g., processor 41, memory 42, input / output interface 43, and communication interface 44); The processor 41, memory 42, input / output interface 43 and communication interface 44 are connected to each other within the device via bus 45.
[0236] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for detecting hair follicle organoid images.
[0237] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0238] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0239] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0240] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0241] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0242] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0243] It should be understood that in this application, "at least one" and "several" refer to one or more, and "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0244] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0245] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0246] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0247] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0248] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A method for detecting images of hair follicle organoids, characterized in that, The method includes: Obtain culture stage information corresponding to bright-field images of hair follicle organoids; Based on the cultivation stage information, at least one target structure type corresponding to the bright-field image is determined. For each target structure type, a matching target segmentation model is selected from multiple pre-trained instance segmentation models. The target structure types include main structure, bud structure, and bulb structure. The target segmentation models include main structure segmentation models, bud structure segmentation models, and bulb structure segmentation models. Selecting a matching target segmentation model from multiple pre-trained instance segmentation models for each target structure type includes: when the cultivation stage information indicates that the hair follicle organoid is in an early stage, determining the target structure type as a main structure, and selecting the main structure segmentation model corresponding to the main structure from the multiple instance segmentation models. The main structure segmentation model is configured with a first detection scale parameter. When the cultivation stage information indicates that the hair follicle organoid is in an early to mid-stage... When the target structure type is determined to be the main structure, a main structure segmentation model corresponding to the main structure is selected from the multiple instance segmentation models. The main structure segmentation model is configured with a second detection scale parameter, which is greater than the first detection scale parameter. When the culture stage information indicates that the hair follicle organoid is in the middle stage, the target structure type is determined to be both the main structure and the hair bud structure. A main structure segmentation model corresponding to the main structure and a hair bud structure segmentation model corresponding to the hair bud structure are selected from the multiple instance segmentation models. When the culture stage information indicates that the hair follicle organoid is in the late stage, the target structure type is determined to be both the main structure and the bulb structure. A main structure segmentation model corresponding to the main structure and a bulb structure segmentation model corresponding to the bulb structure are selected from the multiple instance segmentation models. Based on the bright-field image, output a structure mask image for each target structure type using the segmentation model corresponding to each target structure type. Perform a structure detection operation that matches the corresponding target structure type on each structure mask image to obtain the detection sub-result for each target structure type; Based on the detection sub-results corresponding to the at least one target structure type, the detection results corresponding to the hair follicle organoids are generated. The structure detection operation includes at least the following types: for the main structure, morphological parameter detection of multiple main instances in the corresponding structure mask image; for the bud structure, morphological parameter detection of multiple bud instances in the corresponding structure mask image and spatial distribution detection of the multiple bud instances; and scale detection of multiple spherical instances for the spherical structure.
2. The method for detecting hair follicle organoid images according to claim 1, characterized in that, The target segmentation model types include main structure segmentation model, bud structure segmentation model, and spherical structure segmentation model. The structure mask image types include at least one of main structure mask image, bud structure mask image, and spherical structure mask image. The step of outputting a structure mask image for each target structure type based on the bright-field image using each target segmentation model corresponding to each target structure type includes: When the target structure type is a main structure, the main structure segmentation model outputs a main structure mask image containing at least one main entity instance based on the bright field image. When the target structure type is a bud structure, the bud structure segmentation model outputs an initial structure mask image containing at least one bud instance based on the bright field image. Based on the size relationship between the bud area of each bud instance in the initial structure mask image and a preset bud area threshold, the bud instances in the initial structure mask image are filtered to obtain the corresponding bud structure mask image. When the target structure type is a spherical structure, the spherical structure segmentation model outputs a corresponding probability map based on the bright field image, and generates a spherical structure mask image containing at least one spherical instance based on the instance probability value corresponding to each pixel contained in the probability map.
3. The method for detecting hair follicle organoid images according to claim 2, characterized in that, The step of generating a spherical structure mask image containing at least one spherical instance based on the instance probability value corresponding to each pixel in the probability map includes: A first comparison result is obtained by comparing the instance probability value corresponding to each pixel in the probability map with a preset first probability threshold. When the first comparison result indicates that the probability value of the instance corresponding to the first pixel of the target exists in the probability map is greater than the first probability threshold, the first pixel of the target is determined as a seed pixel, and at least one seed region is generated based on multiple seed pixels; A second comparison result is obtained by comparing the instance probability value corresponding to each pixel in the probability map with a preset second probability threshold, wherein the second probability threshold is less than the first probability threshold; When the second comparison result indicates that the probability value of the instance corresponding to the second pixel of the target exists in the probability map is greater than the second probability threshold, the second pixel of the target is determined as a candidate pixel, and a candidate region is generated based on multiple candidate pixels; In the candidate region, the watershed algorithm is executed with all seed regions as initial labels to obtain the sphere instance corresponding to each seed region; Generate a corresponding spherical structure mask image based on the spherical instance corresponding to each seed region.
4. The method for detecting hair follicle organoid images according to claim 1, characterized in that, The types of structure mask images include main structure mask images, tuft structure mask images, and spherical structure mask images. After outputting the structure mask image for each target structure type based on the bright-field image using the target segmentation model corresponding to each target structure type, the process further includes: When the culture stage information indicates that the hair follicle organoid is in the intermediate or late stage, a target structure mask image is determined based on the culture stage information, wherein the target structure mask image is the hair bud structure mask image corresponding to the intermediate stage or the bulb structure mask image corresponding to the late stage. For each substructure instance in the target structure mask image, calculate the overlap area between the substructure instance and each main instance in the main structure mask image, and determine the main instance with the largest overlap area as the parent instance of the corresponding substructure instance; For each substructure instance, the overlap ratio is obtained based on the ratio between the overlapping area corresponding to the parent instance and the area of the substructure instance; For each substructure instance, when the overlap ratio is greater than a preset retention threshold, the substructure instance is determined as the target substructure instance corresponding to the parent instance, and a corrected structure mask image is generated based on multiple target substructure instances corresponding to the target structure mask image. When the overlap ratio is greater than or equal to a preset expansion threshold, and the target substructure instance has at least one target pixel that crosses the pixel boundary of the parent instance, the at least one target pixel of the target substructure instance is merged into the parent instance to obtain the corresponding target main body instance, and the main body structure mask image is corrected based on each target main body instance to obtain the corrected main body structure mask image.
5. The method for detecting hair follicle organoid images according to claim 1, characterized in that, The step of performing a structure detection operation on each structure mask image that matches the corresponding target structure type, to obtain a detection sub-result for each target structure type, includes: When the culture stage information indicates that the hair follicle organoid is in the intermediate stage, determine the main structure mask image and hair bud structure mask image corresponding to the intermediate stage; For each hair instance contained in the hair structure mask image, the hair instance pixel coordinates of each corresponding hair instance pixel are determined, and the hair centroid coordinates are calculated based on the average of the multiple hair instance pixel coordinates corresponding to each hair instance. For each bud instance contained in the bud structure mask image, calculate the target overlap area between each bud instance and at least one corresponding main instance. When the target overlap area is greater than a preset retention threshold, retain the corresponding bud instance as a target bud instance. The hair bud screening and retention ratio is calculated based on the ratio between the first number of multiple target hair bud instances corresponding to the hair bud structure mask image and the second number of multiple hair bud instances contained in the hair bud structure mask image. Based on the main structure mask image, the area of the main instance of the multiple main instances is determined, and the bud density is calculated based on the first quantity and the area of the main instance. For each target hair instance, calculate the centroid distance between the corresponding target centroid coordinates and the adjacent target centroid coordinates of each adjacent target hair instance, and determine the minimum centroid distance from the multiple centroid distances corresponding to multiple adjacent target hair instances as the nearest neighbor distance of the current target hair instance. Based on the nearest neighbor distances corresponding to the multiple target hair bud instances, calculate the mean centroid distance, standard deviation of centroid distance, maximum centroid distance, and minimum centroid distance; Based on the first quantity, the hair bud screening retention ratio, the hair bud density, the mean centroid distance, the standard deviation of the centroid distance, the maximum centroid distance, and the minimum centroid distance, a detection sub-result corresponding to the hair bud structure is generated.
6. The method for detecting hair follicle organoid images according to claim 1, characterized in that, The structure mask image is a spherical structure mask image. After outputting the structure mask image for each target structure type based on the bright-field image using the segmentation model corresponding to each target structure type, the process further includes: When the culture stage information indicates that the hair follicle organoid is in the late stage, for each spherical instance in the spherical structure mask image, the corresponding morphological skeleton is extracted, and the corresponding average thickness is calculated based on the area of the spherical instance corresponding to the current spherical instance and the skeleton length of the morphological skeleton. Obtain the minimum bounding ellipse corresponding to each spherical instance, and calculate the aspect ratio corresponding to each spherical instance based on the minimum bounding ellipse; Determine the number of adjacent skeleton pixels of each skeleton pixel in the morphological skeleton corresponding to each sphere instance, and determine the skeleton pixels with a number of one adjacent skeleton pixels as the skeleton endpoints of the sphere instance; For each spherical instance, the two farthest skeleton endpoints are determined as the two end skeleton endpoints of the spherical instance; For each spherical instance, an end cap region is constructed with each end skeleton endpoint as the center and the average thickness as the radius, and the region in the spherical instance other than the end cap region is defined as the side region. For each spherical instance in the spherical structure mask image, obtain the neighboring spherical instances that are adjacent to the current spherical instance; For each spherical instance, when the aspect ratio of the current spherical instance and at least one of the adjacent spherical instances is greater than or equal to a preset aspect ratio threshold, and the end cap region corresponding to the current spherical instance is adjacent to the end cap region corresponding to the adjacent spherical instance, and the end cap region corresponding to the current spherical instance is not adjacent to the side region corresponding to the adjacent spherical instance, and the end cap region corresponding to the adjacent spherical instance is not adjacent to the side region corresponding to the current spherical instance, the current spherical instance and the adjacent spherical instance are merged into one spherical instance; The spherical structure mask image is updated based on the merged multiple spherical instances to generate an updated spherical structure mask image.
7. The method for detecting hair follicle organoid images according to claim 1, characterized in that, The structure mask image is a spherical structure mask image. After outputting the structure mask image for each target structure type based on the bright-field image using the segmentation model corresponding to each target structure type, the process further includes: When the culture stage information indicates that the hair follicle organoid is in the late stage, for each spherical instance in the spherical structure mask image, the corresponding morphological skeleton is extracted, and the total number of skeleton endpoints and the number of bifurcation points of the morphological skeleton are determined. The bifurcation point is a skeleton pixel in the morphological skeleton with a number of adjacent skeleton pixels greater than or equal to three. When the total number of skeleton endpoints is three and the number of bifurcation points is one, the spherical instance is determined as the spherical instance to be cut, and each skeleton branch and its corresponding branch length are determined on the morphological skeleton, with the bifurcation point as the starting point and each skeleton endpoint as the ending point. When at least two first skeleton branches in the morphological skeleton have a branch length greater than or equal to a preset length threshold, and the ratio between the longer first branch and the shorter second branch of the at least two first skeleton branches is less than or equal to a preset proportion threshold, skeleton branches to be retained and skeleton branches to be cut are determined from the two first skeleton branches. The preset length threshold is determined based on the larger value between a preset minimum absolute length threshold and a reference threshold. The reference threshold is calculated based on the product of a preset relative length proportion and the length of the shortest branch among the multiple skeleton branches. On the retained skeleton branch, select a starting segment skeleton point close to the bifurcation point, and determine the local tangent direction of the retained skeleton branch at the bifurcation point based on the starting segment skeleton point, and determine the local tangent direction as the initial cutting direction; The step length is accumulated along the skeleton branch to be cut from the bifurcation point to the end skeleton endpoint of the skeleton branch to be cut. When the accumulated length reaches the target branch length corresponding to the second skeleton branch, the current skeleton pixel is determined as a candidate cutting point. Centered on the candidate cutting point, the initial cutting direction is rotated within a preset angle range with a preset step size to obtain multiple candidate cutting directions. For each candidate cutting direction, the cutting direction is extended bidirectionally to the mask boundary of the current sphere instance to be cut to form a candidate cutting line. A preset kerf thickness is applied to the candidate cutting line to obtain a kerf band. The pixel area covered by the kerf band is removed from the instance mask of the current sphere instance to be cut to obtain the remaining mask area. For each spherical instance to be cut, connected component analysis is performed on the remaining mask region to obtain multiple spherical sub-instances. In the spherical structure mask image, the spherical instance to be cut is replaced with the multiple spherical sub-instances. Based on the multiple spherical sub-instances corresponding to each spherical instance to be cut, the spherical structure mask image is updated to obtain an updated spherical structure mask image.
8. The method for detecting hair follicle organoid images according to claim 1, characterized in that, The structure mask image is a spherical structure mask image. The step of performing a structure detection operation on each structure mask image, matching the corresponding target structure type, yields a detection sub-result for each target structure type, including: When the culture stage information indicates that the hair follicle organoid is in a late stage, determine the bulb structure mask image corresponding to the late stage. For each sphere instance contained in the sphere structure mask image, the corresponding morphological skeleton is extracted, and the skeleton endpoints and bifurcation points of the morphological skeleton are determined based on the number of adjacent skeleton pixels of each skeleton pixel on the morphological skeleton. For each spherical instance, starting from each skeleton endpoint, the nearest target bifurcation point is determined along the morphological skeleton, and the branch length corresponding to each skeleton endpoint is determined based on the current skeleton endpoint and the target bifurcation point. Branches with branch lengths less than a preset branch length threshold are deleted to obtain the pruned morphological skeleton. For each spherical instance, Euclidean distance transformation is performed on the structural mask image corresponding to the spherical instance to obtain the distance value of each pixel to the nearest mask boundary, and the pixel with the largest distance value is determined as the geometric center pixel of the spherical instance; For each spherical instance, on the trimmed morphological skeleton, starting from the geometric center pixel, determine the longest continuous path between the skeleton endpoints, and determine the continuous path as the main axis; On the main axis, a set of morphological skeleton points adjacent to the geometric center pixel is determined, and the local tangent direction of the geometric center pixel is determined based on the set of morphological skeleton points. According to the direction orthogonal to the local tangent direction, a search is performed from the geometric center pixel to the boundary of the current sphere instance to obtain two target boundary points. Based on the distance between the two target boundary points, the candidate cross section thickness of the geometric center pixel is obtained, and the next candidate cross section thickness is calculated based on the updated set of morphological skeleton points. Repeat the step of calculating multiple candidate cross-sectional thicknesses based on the updated morphological skeleton point set until the preset number of updates is reached, and select the largest target cross-sectional thickness from the multiple candidate cross-sectional thicknesses. Based on the number of multiple spherical instances contained in the spherical structure mask image, the number of target skeleton pixels corresponding to the trimmed morphological skeleton of each spherical instance, the number of principal axis pixels corresponding to the principal axis, and the target cross-sectional thickness, the detection sub-result corresponding to the spherical structure is obtained.
9. A device for detecting images of hair follicle organoids, characterized in that, The device includes: The acquisition module is used to acquire culture stage information corresponding to bright-field images of hair follicle organoids; The selection module is used to determine at least one target structure type corresponding to the bright field image based on the cultivation stage information, and for each target structure type, select a matching target segmentation model from multiple pre-trained instance segmentation models, wherein the target structure types include main structure, bud structure and spherical structure. The output module is used to output a structure mask image for each target structure type based on the bright field image, using each target segmentation model corresponding to each target structure type. The detection module is used to perform a structure detection operation on each structure mask image that matches the corresponding target structure type, and obtain the detection sub-result corresponding to each target structure type; A generation module is used to generate a detection result corresponding to the hair follicle organoid based on the detection sub-results corresponding to the at least one target structure type; The types of structure detection operations include at least the morphological parameter detection operation of multiple main body instances in the corresponding structure mask image for the main body structure, or the morphological parameter detection operation of multiple bud instances in the corresponding structure mask image for the bud structure and the spatial distribution detection operation of the multiple bud instances, or the scale detection operation of multiple spherical instances for the spherical structure.
10. A computer device, characterized in that, The computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the method for detecting hair follicle organoid images according to any one of claims 1 to 8.
11. 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 detecting hair follicle organoid images according to any one of claims 1 to 8.
Citation Information
Patent Citations
Target detection method and device for scalp hair follicle data and medium
CN118247633A
Scalp feature detection method and device and electronic equipment
CN120198720A