Method for automatically converting astronomical CCD (Charge Coupled Device) image into AI (Artificial Intelligence) training sample
By automatically converting astronomical CCD images into AI training samples, the problems of incompatible astronomical image formats, low annotation efficiency, and diverse label formats are solved. This enables the construction of efficient and accurate astronomical AI training datasets and supports label format conversion for multiple deep learning frameworks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZIJINSHAN ASTRONOMICAL OBSERVATORY CHINESE ACAD OF SCI
- Filing Date
- 2025-12-15
- Publication Date
- 2026-05-01
AI Technical Summary
In existing technologies, the incompatibility of astronomical CCD image formats, low annotation efficiency, and difficulty in meeting the diverse requirements of label formats lead to low efficiency in building astronomical AI training datasets, and the format conversion process is prone to losing important information.
This paper presents an automatic conversion method for astronomical CCD images to AI training samples, including image preprocessing, interactive annotation, dynamic range normalization, and multi-format label generation. It supports the import of FITS format images, bias field, dark field, and flat field calibration, uses the ZScale algorithm for dynamic range normalization, and supports automatic conversion of various label formats such as YOLO, COCO, Pascal VOC, and Mask R-CNN.
It has achieved fully automated processing of astronomical image datasets, improved data preparation efficiency, preserved the dynamic range characteristics of astronomical images, improved the accuracy of annotation and multi-format support capabilities, and reduced manual operations.
Smart Images

Figure CN121962797A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the interdisciplinary field of astronomical image processing and artificial intelligence. Specifically, it relates to an automatic conversion method for astronomical CCD images to AI training samples, which is suitable for the creation of datasets for deep learning applications such as astronomical target detection, classification and recognition. Background Technology
[0002] With the expanding application of deep learning technology in astronomy, celestial object detection, classification, and recognition based on convolutional neural networks have become important methods for processing astronomical CCD image data. However, constructing high-quality astronomical AI training datasets still faces many technical challenges, severely restricting the development of intelligent astronomical observation.
[0003] In existing technologies, the creation of astronomical AI training datasets mainly suffers from the following problems: First, there's the issue of format incompatibility. Raw data from astronomical observations is typically in FITS (Flexible Image Transport System) format, featuring 16-bit or higher bit depth, a unique header structure, and high dynamic range. However, mainstream deep learning frameworks require 8-bit RGB or grayscale image input. Existing general-purpose image annotation tools such as LabelImg and CVAT cannot directly process FITS format, requiring complex format conversions, which can easily result in the loss of important astronomical photometric information.
[0004] Second, the annotation efficiency is low. Targets in astronomical images are usually point sources or extended sources, numbering in the hundreds to thousands. Traditional rectangular or polygonal annotation methods do not reflect the actual morphological characteristics of celestial objects, and manual annotation of each one is extremely labor-intensive. Although semi-automatic detection methods based on astronomical software such as SExtractor exist, their output format is incompatible with deep learning label formats, still requiring a significant amount of manual conversion work.
[0005] Third, there is a need for diverse label formats. Different deep learning frameworks and model architectures require different label formats. For example, the YOLO series models use normalized bounding box text format, Mask R-CNN uses COCO JSON format, and Faster R-CNN uses Pascal VOC XML format. Existing tools typically only support a single format, making it difficult to meet diverse research needs. Format conversion is cumbersome and error-prone.
[0006] Therefore, there is an urgent need to develop an AI training sample automatic conversion method specifically for the characteristics of astronomical CCD images, which can efficiently process FITS format images, provide annotation tools suitable for astronomical target features, support label formats of various mainstream deep learning frameworks, and automatically construct standardized training datasets. Summary of the Invention
[0007] This invention addresses the shortcomings of existing technologies by providing an automatic conversion method for astronomical CCD images to AI training samples, solving efficiency and standardization issues in astronomical image format conversion, target annotation, and dataset construction.
[0008] To achieve the above objectives, the present invention adopts the following technical solution: An automatic conversion method from astronomical CCD images to AI training samples includes the following steps: Step 1: Import one or more FITS images through the graphical interface and set the image preprocessing parameters. The FITS images are FITS format astronomical CCD image files. Step 2: Perform bias field, dark field, and flat field calibration on the FITS image according to the image preprocessing parameters; Step 3: Label celestial objects in the FITS image using the interactive image display interface; Step 4: Set the split ratio of the training set, validation set, and test set in the training sample set; Step 5: Select the label format corresponding to the target AI training framework; Step 6: Use the ZScale algorithm to perform dynamic range normalization on the FITS image and generate the corresponding label file according to the selected label format; Step 7: Randomly allocate labeled FITS images according to the segmentation ratio, and automatically construct a standardized AI training dataset directory structure containing training set, validation set and test set; Step 8: Output the complete AI training sample dataset.
[0009] Optionally, in step one, the image preprocessing parameters include the dark field file path, the offset field file path, and the flat field file path, and the FITS image is displayed and selected through a file tree list.
[0010] Optionally, in step three, the manual circular annotation mode is used for annotation, specifically as follows: Create circular annotation areas by clicking and dragging with the mouse. The manual circular annotation mode supports annotation selection, dragging and moving, radius adjustment and deletion operations.
[0011] Optionally, in step three, the automatic detection and annotation mode is used for annotation, specifically as follows: The system automatically detects celestial targets based on the SEP source extraction algorithm. The detection threshold is dynamically adjusted through interface parameters, and the detection results are automatically converted into circular labels.
[0012] Optionally, the detection process of the SEP source extraction algorithm includes: Perform background estimation and background subtraction on the input image; The source target is extracted based on the set detection threshold and the background global root mean square error; Measure the center coordinates and ellipse parameters of each source target, and take twice the major axis of the ellipse as the labeling radius.
[0013] Optionally, in step five, the label format used is YOLO format, which is used to convert the annotations into a normalized bounding box format. The output text file contains the category ID, the normalized coordinates of the center point, the normalized width, and the height.
[0014] Optionally, in step five, the label format used is COCO format, which is used to generate a JSON structure file containing a list of image information, a list of annotation information, and a list of category information. Each annotation contains an image ID, a category ID, bounding box coordinates, and an area.
[0015] Optionally, in step five, the tag format used is Pascal VOC format, which is used to generate an XML file containing image size information and target bounding box coordinates.
[0016] Optionally, in step five, the label format used is Mask R-CNN format, which is used to generate a JSON file and convert the labels into a 36-point polygon approximation, including bounding boxes, polygon coordinates, and area.
[0017] Optionally, in step six, the ZScale algorithm calculates the upper and lower limits of the dynamic range of the FITS image, then crops and linearly stretches the image data, and finally converts the stretched floating-point data into an 8-bit unsigned integer and saves it as a PNG format image.
[0018] The beneficial effects of this invention are as follows: This invention automates the entire process from importing FITS images to generating training datasets, significantly reducing manual operations and improving data preparation efficiency; this invention is optimized for the characteristics of astronomical CCD images, supports standard dark field, bias field, and flat field calibration, and uses the ZScale algorithm to preserve the dynamic range characteristics of astronomical images; it integrates the SEP astronomical source extraction algorithm, achieving high accuracy in automatic detection; the manual annotation tool supports precise position and radius adjustment, resulting in reliable annotation results; this invention supports label formats from four mainstream deep learning frameworks: YOLO, COCO, Pascal VOC, and Mask R-CNN, meeting different research needs and avoiding redundant annotation. Attached Figure Description
[0019] Figure 1 A flowchart illustrating the overall process of automatically converting astronomical CCD images into AI training samples; Figure 2 A schematic diagram of the image import and preprocessing interface; Figure 3 This is a schematic diagram of the interactive annotation interface, demonstrating the manual circular annotation function; Figure 4 This is a schematic diagram illustrating the automatic annotation effect, showcasing the detection results of the SEP algorithm; Figure 5 This diagram illustrates the conversion between various label formats, showcasing the outputs of four formats: YOLO, COCO, Pascal VOC, and Mask R-CNN. Figure 6 The generated training dataset directory structure diagram illustrates the standardized file organization method. Detailed Implementation
[0020] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0021] In one embodiment, the present invention proposes an automatic conversion method for astronomical CCD images to AI training samples, the process of which is as follows: Figure 1 As shown, it includes the following steps: Step 1: Import one or more FITS format astronomical CCD image files through the graphical interface and set the image preprocessing parameters; Step 2: Perform bias field, dark field, and flat field calibration on the original FITS image according to the preprocessing parameters; Step 3: Manually mark celestial targets with circles or automatically detect and mark them based on the SEP algorithm through the interactive image display interface; Step 4: Set the split ratio of the training set, validation set, and test set in the training sample set; Step 5: Select the label format corresponding to the target AI training framework. The label format includes at least one of the following: YOLO format, COCO format, Pascal VOC format, or Mask R-CNN format. Step 6: Use the ZScale algorithm to perform dynamic range normalization on the FITS image, convert the 16-bit image data into an 8-bit PNG format image, and generate the corresponding tag file according to the selected tag format; Step 7: Randomly allocate labeled images according to the segmentation ratio, and automatically construct a standardized dataset directory structure containing training set, validation set and test set; Step 8: Output the complete AI training sample dataset.
[0022] The graphical interface in Step 1 also supports the following auxiliary functions: the keyboard shortcut Delete key to delete the currently selected annotation, Q key to switch to the previous image, and E key to switch to the next image; real-time display of the number of annotations for the current image, marking annotated images and their annotation counts in the file tree list; automatic saving of the annotation information of the current image when switching images, and automatic restoration when switching back; display of the current image's position in the list, file name, and basic parameters.
[0023] The preprocessing module in step two supports automatically checking whether the dimensions of the bias, dark, and flat files match the original image; displays the current processing progress and estimated remaining time in real time; and saves the calibrated image to a user-specified folder with the filename prefixed with "cal_".
[0024] Step 3 includes interactive annotation functions such as creating circular annotations by dragging and dropping with the mouse, selecting and editing annotations, automatically detecting annotations based on the SEP source extraction algorithm, and supporting dynamic adjustment of the detection threshold.
[0025] In step five, the label formats include YOLO, COCO, Pascal VOC, and Mask R-CNN, and a special coordinate transformation optimization was performed for the circular features of astronomical point source targets.
[0026] This embodiment uses a batch of 10 FITS format astronomical images, each with a size of 1024×1024 pixels, containing dozens to hundreds of star targets. The goal is to create a YOLO format training dataset, including the following steps: Step 1: Start the system, and select 10 FITS files in batch using the "Import Image Files" button, such as... Figure 2 As shown, the software system automatically displays the file list in the file tree on the left. Step 2: Set the paths for the bias, dark, and flat calibration files in sequence. Click the "Start Preprocessing" button. The system will automatically read the calibration files and apply the calibration formula to each original image: Calibrated Image = (Original Image - Bias Field - Exposure Time × Dark Field) / Flat Field, where the exposure time is automatically extracted from the EXPTIME keyword in the FITS file header (100 seconds in this example). The calibrated images are saved to the user-specified folder, with the filename prefixed with "cal_". The system interface displays the processing progress, and the list of calibrated images is automatically loaded upon completion. Step 3: View the first image in the main display area. The image has been preprocessed using the ZScale algorithm, automatically optimizing the dynamic range, making the star targets clearly visible. Use the mouse to click and drag at the star locations to create circular annotations. The radius of the annotations should cover the halo range of the star, such as... Figure 3As shown. After each image is labeled, click the "Next" button (or press the E key), and the system will automatically save the current labeling information and load the next image. If you need to modify a labeled target, you can select the label by clicking it (it will turn red), drag the center of the label to move its position, drag the edge control points to adjust the radius, and press the Delete key to delete the selected label. During the labeling process, the number of labels for the current image is displayed in real time at the bottom of the interface, and the number of labels is displayed after the labeled images in the file tree list; Step 4: After all 10 images are labeled, set the segmentation ratio in the "Sample Dataset Generation" area: 70% for training set (7 images), 20% for validation set (2 images), and 10% for test set (1 image). Step 5: Select "YOLO" from the "Label Format" drop-down menu; Step Six: Click the "Generate Sample Dataset" button and select the output folder. The system first applies the ZScale algorithm to each FITS image, calculating the image's statistical features to determine the dynamic range upper and lower limits (vmin, vmax), then performs linear stretching: `normalized_image = (image - vmin) / (vmax - vmin) × 255`, converts it to an 8-bit unsigned integer, and saves it as a PNG. Next, the circular annotations are converted to YOLO format, using the bounding square of each annotation as the bounding box, and the normalized center point coordinates and dimensions are calculated. Then, images are randomly assigned to the training, validation, and test sets, maintaining the set proportions. A standard directory structure is then created. Finally, a YOLO format `dataset.yaml` configuration file is generated. train: dataset / train / images val: dataset / val / images test: dataset / test / images nc: 1 names: ['star'] Step 7: The system will display a pop-up notification indicating that the dataset has been generated, including statistical information: 7 training images, 2 validation images, 1 test image, and approximately 300 annotations in total. The output dataset can be directly used for training models such as YOLOv5 and YOLOv8.
[0027] In another embodiment, the present invention provides a computer-readable storage medium storing a computer program that enables a computer to execute the automatic conversion method from astronomical CCD images to AI training samples as described in the foregoing embodiments.
[0028] In another embodiment, the present invention proposes an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the automatic conversion method from astronomical CCD images to AI training samples as described in the foregoing embodiment.
[0029] In the embodiments disclosed in this application, a computer storage medium may be a tangible medium that may contain or store programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of computer storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CDROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0030] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0031] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should be considered within the scope of protection of the present invention.
Claims
1. An automatic conversion method from astronomical CCD images to AI training samples, characterized in that, Includes the following steps: Step 1: Import one or more FITS images through the graphical interface and set the image preprocessing parameters. The FITS images are FITS format astronomical CCD image files. Step 2: Perform bias field, dark field, and flat field calibration on the FITS image according to the image preprocessing parameters; Step 3: Label celestial objects in the FITS image using the interactive image display interface; Step 4: Set the split ratio of the training set, validation set, and test set in the training sample set; Step 5: Select the label format corresponding to the target AI training framework; Step 6: Use the ZScale algorithm to perform dynamic range normalization on the FITS image and generate the corresponding label file according to the selected label format; Step 7: Randomly allocate labeled FITS images according to the segmentation ratio, and automatically construct a standardized AI training dataset directory structure containing training set, validation set and test set; Step 8: Output the complete AI training sample dataset.
2. The automatic conversion method from astronomical CCD images to AI training samples as described in claim 1, characterized in that: In step one, the image preprocessing parameters include the dark field file path, the offset field file path, and the flat field file path. The FITS image is displayed and selected through a file tree list.
3. The automatic conversion method from astronomical CCD images to AI training samples as described in claim 1, characterized in that: In step three, the manual circular annotation mode is used for annotation, specifically as follows: Create circular annotation areas by clicking and dragging with the mouse. The manual circular annotation mode supports annotation selection, dragging and moving, radius adjustment and deletion operations.
4. The automatic conversion method from astronomical CCD images to AI training samples as described in claim 1, characterized in that: In step three, the automatic detection and annotation mode is used for annotation, specifically as follows: The system automatically detects celestial targets based on the SEP source extraction algorithm. The detection threshold is dynamically adjusted through interface parameters, and the detection results are automatically converted into circular labels.
5. The automatic conversion method from astronomical CCD images to AI training samples as described in claim 4, characterized in that: The detection process of the SEP source extraction algorithm includes: Perform background estimation and background subtraction on the input image; The source target is extracted based on the set detection threshold and the background global root mean square error; Measure the center coordinates and ellipse parameters of each source target, and take twice the major axis of the ellipse as the labeling radius.
6. The automatic conversion method from astronomical CCD images to AI training samples as described in claim 1, characterized in that: In step five, the label format used is YOLO format, which is used to convert the annotations into a normalized bounding box format. The output text file contains the category ID, the normalized coordinates of the center point, the normalized width, and the height.
7. The automatic conversion method from astronomical CCD images to AI training samples as described in claim 1, characterized in that: In step five, the label format used is COCO format, which is used to generate a JSON structure file containing a list of image information, a list of annotation information, and a list of category information. Each annotation contains an image ID, a category ID, bounding box coordinates, and an area.
8. The automatic conversion method from astronomical CCD images to AI training samples as described in claim 1, characterized in that: In step five, the tag format used is Pascal VOC format, which is used to generate an XML file containing image size information and target bounding box coordinates.
9. The automatic conversion method from astronomical CCD images to AI training samples as described in claim 1, characterized in that: In step five, the label format used is Mask R-CNN format, which is used to generate JSON files and convert the labels into a 36-point polygon approximation, including bounding boxes, polygon coordinates, and area.
10. The automatic conversion method from astronomical CCD images to AI training samples as described in claim 1, characterized in that: In step six, the ZScale algorithm calculates the upper and lower limits of the dynamic range of the FITS image, then crops and linearly stretches the image data, converts the stretched floating-point data into an 8-bit unsigned integer, and saves it as a PNG format image.