Batch image processing system and method for single molecule image processing

By providing a batch image processing system and method for single-molecular image processing, the shortcomings of the prior art in processing single-molecular images are solved, efficient and accurate image processing and analysis are achieved, and application needs in the field of biomedical science are met.

CN119599985AActive Publication Date: 2025-03-11SOUTH CHINA UNIV OF TECH
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411658395.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-03-11
Estimated Expiration
2044-11-19

AI Technical Summary

Technical Problem

The prior art is difficult to effectively process single-molecule images, especially in batch data processing and customized analysis, which limits its application in the field of biomedical science.

Method used

A batch image processing system and method for single molecule image processing is provided, including image input, preprocessing, target feature detection and labeling, quantity statistics and data storage, and result output. The system uses libraries such as OpenCV, OpenPyXL and Matplotlib to realize functions such as grayscale processing, contrast enhancement, threshold segmentation, feature detection and marking, data statistics and export.

Benefits of technology

It significantly improves the speed and efficiency of image processing, ensures high accuracy detection and labeling of target features, reduces false detection and missed detection rates, provides intuitive parameter settings and result display interfaces, simplifies user operations, and meets the growing scientific research needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119599985A_ABST
    Figure CN119599985A_ABST
Patent Text Reader

Abstract

The invention discloses a batch image processing system and method for single molecule image processing, and belongs to the technical field of image processing, and the method comprises the following steps: image input: receiving and reading a single or multiple image files selected by a user by using a cv2. Imread () function in an OpenCV library; graying processing, image cutting, automatic image cutting and contrast enhancement are carried out on the input image; performing target feature detection and marking on the preprocessed image, wherein the target feature detection comprises single-image feature detection and double-image feature detection; performing quantity statistics and data storage on the target features, recording coordinates and quantity of green rectangular frames, and exporting statistical data as an Excel file by using an OpenPyXL library; a cv2. Imwrite () function of the OpenCV is used for storing the processed image; according to the batch image processing system and method for single molecule image processing, manual operation steps of downstream medical workers are reduced, the efficiency and accuracy of medical related scientific research work are improved, and the batch image processing system and method are suitable for application scenes of cancer related large-batch preventive screening.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a batch image processing system and method for single molecule image processing. Background Art

[0002] With the rapid development of biological science and technology, single-molecule detection technology has become an important tool for studying the dynamic behavior of biological molecules and biostatistics. Traditional biochemical methods can usually only provide average information of a large number of molecules, but cannot reveal the unique behavior of a single molecule. They can only be qualitative but not quantitative, making it impossible to accurately stage cancer in vitro diagnosis and requiring further diagnosis, which increases the risk for patients and the burden on the medical system and the economy. Specific research single-molecule detection systems are urgently needed to be developed.

[0003] In modern biological science research, single-molecule detection technology has become an important means to reveal the dynamic behavior of biomolecules and the interactions between molecules. Although traditional image processing tools, such as ImageJ and MATLAB, are powerful, they often require users to have a certain programming foundation or complex operation procedures, which limits their application among non-professional computer personnel in the biomedical field. In addition, existing tools are insufficient in processing batch data and customized analysis, and cannot meet the growing scientific research needs. Therefore, there is an urgent need for an application specifically for single-molecule image processing, which has an intuitive graphical user interface, integrates commonly used image processing functions, lowers the threshold for use, and improves the data processing efficiency of researchers. Summary of the invention

[0004] The purpose of the present invention is to provide a batch image processing system and method for single molecule image processing to solve the problems existing in the background technology.

[0005] To achieve the above object, the present invention provides a batch image processing method for single molecule image processing, comprising the following steps:

[0006] S1. Image input: Use the cv2.imread() function in the OpenCV library to receive and read a single or multiple image files selected by the user, supporting multiple image formats;

[0007] S2, preprocessing the input image, including grayscale processing, image cropping, automatic image cropping and contrast enhancement;

[0008] Grayscale processing: Use the cv2.cvtColor() function in the OpenCV library to convert the color image into a grayscale image. The weighted formula is Gray = 0.299 × R + 0.587 × G + 0.114 × B.

[0009] Image cropping, based on the cropping parameters input by the user, uses image slicing operations to remove irrelevant areas on the top, bottom, left, and right sides of the image;

[0010] Contrast enhancement: Use OpenCV's cv2.convertScaleAbs() function to adjust the contrast of the grayscale image according to the contrast enhancement factor set by the user;

[0011] S3. Target feature detection and marking are performed on the preprocessed image, including single image feature detection and dual image feature detection. Based on the grayscale threshold input by the user, the enhanced image is globally threshold segmented. The dual image feature detection uses color marking method to mark the target features of the two images respectively, and the transparency is superimposed by cv2.addWeighted() function to generate a composite image. Adjacent features are detected in the composite image and marked with green rectangular boxes.

[0012] S4. Count and store the detected target features, record the coordinates and quantity of the green rectangular boxes, and use the OpenPyXL library to export the statistical data into an Excel file;

[0013] S5. Use OpenCV's cv2.imwrite() function to save the processed image, save the processed image and statistical results to the path specified by the user, and provide visualization and data export functions.

[0014] Preferably, the grayscale processing process is as follows:

[0015] Read the RGB channel values ​​of a color image;

[0016] Apply the gray value calculation formula to each pixel to generate the corresponding gray image;

[0017] Use OpenCV's grayscale function for conversion to improve processing efficiency: gray_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2GRAY)

[0018] Through the cv2.cvtColor() function, the system can quickly convert color images into grayscale images, generate single-channel image data, and reduce computational complexity.

[0019] Preferably, the image cropping process is as follows:

[0020] Get the original width and height of the image;

[0021] Calculate the coordinates of the cropped image area according to the cropping parameters to ensure that the cropped area is within the image boundary;

[0022] Use OpenCV's cropping function to perform the cropping operation and generate a cropped image: cropped_img = img[top:height-bottom,left:width-right]

[0023] Through the slicing operation of NumPy arrays, the system can efficiently crop images, retain areas of interest, and reduce the amount of data for subsequent processing.

[0024] Preferably, the contrast enhancement process is as follows:

[0025] Get the contrast enhancement factor set by the user

[0026] Apply contrast enhancement algorithms to grayscale images to adjust the grayscale value of each pixel and enhance image details;

[0027] Use OpenCV's cv2.convertScaleAbs() function to adjust the contrast and generate an enhanced image: contrast_factor = 2.0 # User-defined contrast factor

[0028] enhanced_image=cv2.convertScaleAbs(gray_image,alpha=contrast_factor,beta=0)

[0029] Through the cv2.convertScaleAbs() function, the system can flexibly adjust the contrast of the image, improve the contrast difference between the target feature and the background, and enhance the detectability of the feature.

[0030] Preferably, the threshold segmentation process is as follows:

[0031] Get the grayscale threshold set by the user;

[0032] Apply the threshold segmentation formula to each pixel to generate a binary image, and mark the pixels below the threshold as the target area. The threshold segmentation formula is as follows:

[0033]

[0034] Use OpenCV's threshold function to achieve efficient binarization processing and generate a binary image: threshold_value = 100 # User-set grayscale threshold

[0035] thresholded_img=cv2.threshold(enhanced_image,threshold_value,255,cv2.THRESH_BINARY_INV)

[0036] Through the cv2.threshold() function, the system can quickly convert the grayscale image into a binary image and extract the target area to facilitate subsequent feature detection and analysis.

[0037] Preferably, the layer overlay process is as follows:

[0038] Load images at different stages of image processing as separate layers;

[0039] Set the transparency of each layer to ensure that the marker color is clearly visible. For example, using OpenCV's cv2.addWeighted() function: combined_image = cv2.addWeighted(layer1,0.5,layer2,0.5,0)

[0040] Generate a composite image after superposition, retaining the characteristic information of each layer.

[0041] Preferably, the process of performing quantitative statistics on the detected target features is as follows:

[0042] a. During feature detection, record the coordinates of each green rectangle;

[0043] b. Count the total number of green rectangles as a measure of the number of features;

[0044] c. Use counting variables or lists to store statistical data;

[0045] d. Store feature counts and associated data for each image in an internal data structure (such as a list or dictionary).

[0046] e. Collect statistical data while reading and processing image data using OpenCV;

[0047] f. Use OpenPyXL library to export statistical data into Excel files for easy viewing and further data analysis.

[0048] Preferably, the data export process is as follows:

[0049] Export feature counts and related data to Excel tables to support users in subsequent data processing and analysis;

[0050] Use OpenPyXL to create a workbook, set table headers, and write statistical data row by row;

[0051] Provides the function of automatically opening saved Excel files, so that users can view statistical results instantly; the visual display process is as follows:

[0052] Use Matplotlib and other drawing libraries to generate visualization charts, including the original image, the red pixel detection image, the cropped image, and the image with a green rectangular box;

[0053] Provides an interactive window that allows users to zoom in, zoom out, and pan to view image details, making it easier for users to verify and analyze processing results.

[0054] A batch image processing system for single molecule image processing, comprising:

[0055] The image input module is equipped with a user interface for selecting and receiving single or multiple image files, and uses the cv2.imread() function of OpenCV to read images;

[0056] The image preprocessing module is equipped with a grayscale processing unit and an image cropping unit, and uses the cv2.cvtColor() function of OpenCV and the image slicing operation to perform grayscale conversion and cropping on the image;

[0057] The contrast enhancement module is equipped with a contrast adjustment unit and uses the cv2.convertScaleAbs() function of OpenCV to enhance the contrast of the image;

[0058] The threshold segmentation module is equipped with a threshold processing unit and uses the cv2.threshold() function of OpenCV to achieve binary segmentation of the image;

[0059] The feature detection and marking module is configured with a single image feature detection unit and a dual image feature detection unit, and uses a color marking method and a spatial neighborhood search algorithm to realize feature detection and marking;

[0060] The feature counting and statistics module is equipped with a data recording unit and a data export unit, and uses the OpenPyXL library to realize the recording and export of statistical data;

[0061] The result output module is equipped with an image saving unit and a visualization display unit, and uses OpenCV's cv2.imwrite() function and Matplotlib library to save and display the processing results.

[0062] Therefore, the present invention adopts the above-mentioned batch image processing system and method for single molecule image processing, which has the following beneficial effects:

[0063] (1) Through batch processing and optimized image processing algorithms, the speed and efficiency of image processing are significantly improved to meet the needs of large-scale image data analysis;

[0064] (2) Use a variety of techniques such as grayscale conversion, contrast enhancement, threshold segmentation, and morphological processing to ensure high-accuracy detection and marking of target features and reduce false detection and missed detection;

[0065] (3) Adaptive threshold segmentation and layer operation technology enhances the algorithm's adaptability to images of different quality and characteristics, ensuring stable performance in various application scenarios;

[0066] (4) Provides an intuitive parameter setting and result display interface, allowing users to flexibly adjust processing parameters according to actual needs and easily obtain analysis results;

[0067] (5) Modular system design facilitates subsequent function expansion and optimization to meet the evolving image analysis needs.

[0068] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] Figure 1 is an overall flow chart of an embodiment of the present invention;

[0070] Figure 2 This is a schematic diagram of a parameter adjustment tab interface according to an embodiment of the present invention;

[0071] Figure 3 This is a schematic diagram of an image thumbnail tab interface according to an embodiment of the present invention;

[0072] Figure 4 A schematic diagram of a save path setting tab interface according to an embodiment of the present invention;

[0073] Figure 5 This is a schematic diagram of the swing test tab interface of an embodiment of the present invention;

[0074] Figure 6 This is a schematic diagram of the interface of the operating instructions and language setting tab of the embodiment of the present invention;

[0075] Figure 7 Schematic diagram of image assembly and swing test in an embodiment of the present invention, wherein (a) is the first image in the swing test; (b) is the second image in the swing test; (c) is the composite image; (d) is the correlation relationship between adjacent features in the two images;

[0076] Figure 8 Schematic diagram of automatic image cropping according to an embodiment of the present invention, wherein (a) is the original pixel point; (b) is the marked pixel point; (c) is the cropped image;

[0077] Fig. 9 Schematic diagram of image processing results according to an embodiment of the present invention. DETAILED DESCRIPTION

[0078] The following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0079] See also Figure 1 , a batch image processing method for single molecule image processing, comprising the following steps:

[0080] S1. Image input: Use the cv2.imread() function in the OpenCV library to receive and read single or multiple image files selected by the user, supporting multiple image formats.

[0081] Realize efficient input of multi-format images, support batch processing of single and multiple images, and meet different analysis requirements;

[0082] The user interface allows users to select single or multiple image files, and supports a variety of common image formats (such as JPEG, PNG, BMP). The OpenCV library is used to read and convert images to ensure efficient processing and compatibility of image data.

[0083] The system ensures that the input image is in a supported format, such as JPEG, PNG, BMP, etc., by checking the file extension and MIME type.

[0084] The user selects multiple images at one time through the multi-file selection dialog box, and the system will batch read and store the file paths of these images to facilitate subsequent batch processing.

[0085] For application scenarios that require comparative analysis, the system provides the function of selecting two images at the same time to ensure that the two images can be synchronously detected and marked during the processing.

[0086] Specific implementation:

[0087] Use OpenCV's cv2.imread() function to read the image:

[0088] import cv2

[0089] #Read a single image

[0090] image=cv2.imread(image_path)

[0091] #Read multiple images

[0092] images=[cv2.imread(path)for path in image_paths]

[0093] Through the cv2.imread() function, the system can support multiple image formats and store image data in the form of NumPy arrays for subsequent processing.

[0094] S2, preprocessing the input image, including grayscale processing, image cropping, automatic image cropping and contrast enhancement;

[0095] Grayscale processing, using the cv2.cvtColor() function in the OpenCV library to convert the color image into a grayscale image, reduce the data dimension, simplify the calculation, and use the weighted average method to convert the RGB channels into grayscale values. The weighted formula is Gray = 0.299×R+0.587×G+0.114×B.

[0096] The grayscale processing process is as follows:

[0097] Read the RGB channel values ​​of a color image;

[0098] Apply the gray value calculation formula to each pixel to generate the corresponding gray image;

[0099] Use OpenCV's grayscale function for conversion to improve processing efficiency: gray_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2GRAY)

[0100] Through the cv2.cvtColor() function, the system can quickly convert color images into grayscale images, generate single-channel image data, and reduce computational complexity.

[0101] Image cropping, based on the cropping parameters entered by the user, uses image slicing operations to remove irrelevant areas at the top, bottom, left, and right of the image. Focus on the area of ​​interest to improve processing efficiency and accuracy.

[0102] Cropping parameters: top crop pixel number (Top Crop), bottom crop pixel number (Bottom Crop), left crop pixel number (Left Crop), right crop pixel number (Right Crop).

[0103] The image cropping process is as follows:

[0104] Get the original width and height of the image;

[0105] Calculate the coordinates of the cropped image area according to the cropping parameters to ensure that the cropped area is within the image boundary;

[0106] Use OpenCV's cropping function to perform the cropping operation and generate a cropped image: cropped_img = img[top:height-bottom,left:width-right]

[0107] Through the slicing operation of NumPy arrays, the system can efficiently crop images, retain areas of interest, and reduce the amount of data for subsequent processing.

[0108] Automatic image cropping, in the batch process, the effective area of ​​the image is automatically cropped to the same size to ensure the effectiveness and accuracy of subsequent analysis. Using the color marking method, the pixels below the threshold are marked with a specific color (such as red), and a reference line (such as a blue vertical line) is added, and the red area near the blue line is marked green, and cropped according to the vertical coordinate of the green point.

[0109] 1. Color marking:

[0110] Convert the binary image to a color image to support color labeling: colored_img = cv2.cvtColor(thresholded_img, cv2.COLOR_GRAY2BGR);

[0111] Mark the pixels below the threshold in red to enhance the visibility of the target area: colored_img[thresholded_img==255]=[0,0,255] #Red mark (BGR format).

[0112] 2. Add reference lines:

[0113] Calculate the center position of the image (such as the middle x coordinate): middle_x = colored_img.shape[1] / / 2;

[0114] Add a blue vertical line at the center of the image as a reference line: colored_img[:,middle_x] = [255,0,0] #Blue line (BGR format);

[0115] 3. Automatic cropping:

[0116] Mark green pixels: cropped_initial_img[y,neighbor_x]=[0,255,0]

[0117] cropped_initial_img[y,x]=[0,255,0]

[0118] Collect green pixel y-coordinates: green_y_coordinates = [y for x, y in green_pixels]

[0119] Crop the image according to the minimum and maximum y coordinates of the green pixels: final_cropped_img = cropped_initial_img[min_y:max_y,:]

[0120] The specific steps are as follows:

[0121] Mark pixels below the threshold in red;

[0122] Construction reference blue line;

[0123] If there are blue pixels near red, they will be marked green, and the image will be cropped according to the green vertical coordinate.

[0124] Contrast enhancement: Through the contrast enhancement algorithm, use OpenCV's cv2.convertScaleAbs() function to adjust the contrast of the grayscale image according to the contrast enhancement coefficient set by the user; enhance the contrast between the target features and the background in the image, and improve the distinguishability and detection accuracy of the features.

[0125] Contrast enhancement formula:

[0126] new_pixel=average+contrast_factor×(original_pixel-average).

[0127] The contrast enhancement process is as follows:

[0128] Get the contrast enhancement factor set by the user

[0129] Apply contrast enhancement algorithms to grayscale images to adjust the grayscale value of each pixel and enhance image details;

[0130] Use OpenCV's cv2.convertScaleAbs() function to adjust the contrast and generate an enhanced image: contrast_factor = 2.0 # User-defined contrast factor

[0131] enhanced_image=cv2.convertScaleAbs(gray_image,

[0132] alpha=contrast_factor,beta=0)

[0133] Through the cv2.convertScaleAbs() function, the system can flexibly adjust the contrast of the image, improve the contrast difference between the target feature and the background, and enhance the detectability of the feature.

[0134] S3. Perform target feature detection and marking on the preprocessed image, including single image feature detection and dual image feature detection. Perform global threshold segmentation on the enhanced image based on the grayscale threshold input by the user. Dual image feature detection uses color marking method to mark target features in the two images respectively, and uses cv2.addWeighted() function to perform transparency superposition to generate a composite image. Adjacent features are detected in the composite image and marked with a green rectangular frame.

[0135] Threshold segmentation binarizes the image and extracts pixels below the set grayscale threshold as target features to facilitate subsequent feature detection and analysis.

[0136] The threshold segmentation process is as follows:

[0137] Get the grayscale threshold set by the user;

[0138] Apply the threshold segmentation formula to each pixel to generate a binary image, and mark the pixels below the threshold as the target area. The threshold segmentation formula is as follows:

[0139]

[0140] Use OpenCV's threshold function to achieve efficient binarization processing and generate a binary image:

[0141] threshold_value=100# Grayscale threshold set by the user

[0142] thresholded_img=cv2.threshold(enhanced_image,threshold_value,255,cv2.THRESH_BINARY_INV)

[0143] Through the cv2.threshold() function, the system can quickly convert the grayscale image into a binary image and extract the target area to facilitate subsequent feature detection and analysis.

[0144] The swing test detects and analyzes the angular momentum or motion characteristics of the microsphere by processing two images simultaneously, providing a more comprehensive analysis result.

[0145] The implementation process is as follows:

[0146] Process the two images separately:

[0147] 1. Apply single image feature detection to the first image, marked in red: colored_img1 = cv2.cvtColor(thresholded_img1,cv2.COLOR_GRAY2BGR)

[0148] colored_img1[thresholded_img1==255]=[0,0,255]#red mark

[0149] 2. Apply single image feature detection to the second image, marked in blue: colored_img2 = cv2.cvtColor(thresholded_img2,cv2.COLOR_GRAY2BGR)

[0150] colored_img2[thresholded_img2==255]=[255,0,0]#blue mark

[0151] Layer overlay: Overlay the two marked images with transparency to generate a composite image: combined_image = cv2.addWeighted(colored_img1,0.5,colored_img2,0.5,0)

[0152] 3. Ensure that features marked with different colors are still clearly visible after superposition.

[0153] Adjacent feature detection:

[0154] 1. Traverse each pixel in the composite image and find the red pixel and the blue pixel in its neighborhood.

[0155] 2. Mark the pixel pairs that meet the adjacent conditions in green, draw a green rectangular box, and highlight the associated features.

[0156] 3. Use OpenCV's drawing function for marking:

[0157]

[0158]

[0159] By drawing the green rectangular frame, the system can intuitively display the correlation between adjacent features in the two images, making it easier to analyze the movement characteristics of the microspheres.

[0160] Layer overlay operation, through layer overlay technology, combines image information from different sources or at different processing stages to facilitate simultaneous observation and analysis of multiple features.

[0161] The implementation process is as follows:

[0162] 1. Load images at different stages of image processing as separate layers.

[0163] 2. Set the transparency of each layer to ensure that the marker color is clearly visible. For example, use OpenCV's cv2.addWeighted() function: combined_image = cv2.addWeighted(layer1,0.5,layer2,0.5,0)

[0164] 3. Generate a composite image after superposition, retaining the characteristic information of each layer.

[0165] S4. Perform quantitative statistics and data storage on the detected target features, provide quantitative analysis results, record the coordinates and quantity of the green rectangular boxes, and use the OpenPyXL library to export the statistical data into an Excel file.

[0166] The implementation process is as follows:

[0167] Quantity Statistics:

[0168] 1. During feature detection, record the coordinates of each green rectangle.

[0169] 2. Count the total number of green rectangles as a measure of the number of features.

[0170] 3. Use a count variable or list to store statistics: green_box_counts = []

[0171] green_box_counts.append({'Image Path':image_path,'Green Box Count':green_box_count})

[0172] Data Storage:

[0173] 1. Store feature counts and associated data for each image in an internal data structure (such as a list or dictionary).

[0174] 2. Collect statistics while reading and processing image data using OpenCV.

[0175] 3. Use the OpenPyXL library to export statistical data as Excel files for easy viewing and further data analysis:

[0176]

[0177]

[0178] Automated Processing:

[0179] 1. When batch processing multiple images, the system automatically summarizes the statistics of each image.

[0180] 2. Provide the function of automatically opening saved Excel files, so that users can view statistical results instantly. For example:

[0181]

[0182] S5. Use OpenCV's cv2.imwrite() function to save the processed image, save the processed image and statistical results to the path specified by the user, and provide visualization and data export functions to facilitate users to view and use the analysis results.

[0183] The implementation process is as follows:

[0184] Image Saving:

[0185] Get the save path specified by the user.

[0186] Save the processed image with the green rectangular frame in a format selected by the user (e.g. PNG, JPEG).

[0187] Use OpenCV's cv2.imwrite() function to save: cv2.imwrite(save_image_path, enhanced_image_with_boxes)

[0188] Data export:

[0189] 1. Export feature counts and related data as Excel tables to support users in subsequent data processing and analysis.

[0190] 2. Use OpenPyXL to create a workbook, set table titles, and write statistical data row by row.

[0191] 3. Provide the function of automatically opening saved Excel files, so that users can view statistical results instantly.

[0192] Visual display:

[0193] 1. Use a drawing library such as Matplotlib to generate a visualization chart, including the original image, the red pixel detection image, the cropped image, and the image with a green rectangular box.

[0194] 2. Provide an interactive window that allows users to zoom in, zoom out, and pan to view image details, making it easier for users to verify and analyze processing results. For example:

[0195] import matplotlib.pyplot as plt

[0196] fig,axes=plt.subplots(2,2,figsize=(10,10),dpi=dpi)

[0197] axes[0,0].imshow(cv2.cvtColor(original_image,cv2.COLOR_BGR2RGB))

[0198] axes[0,0].set_title('Original Image')

[0199] axes[0,0].axis('off')

[0200] axes[0,1].imshow(cv2.cvtColor(red_pixel_image,cv2.COLOR_BGR2RGB))

[0201] axes[0,1].set_title('Red Pixel Detection')

[0202] axes[0,1].axis('off')

[0203] axes[1,0].imshow(cv2.cvtColor(cropped_image,cv2.COLOR_BGR2RGB))

[0204] axes[1,0].set_title('Cropped Image')

[0205] axes[1,0].axis('off')

[0206] axes[1,1].imshow(cv2.cvtColor(enhanced_image_with_boxes,cv2.COLOR_BGR2RGB))

[0207] axes[1,1].set_title(f'Green Boxes\nTotal Boxes:{green_box_count}')

[0208] axes[1,1].axis('off')

[0209] plt.tight_layout()

[0210] plt.show()

[0211] Through the visualization function of Matplotlib, the system can intuitively display the processing results and help users verify and analyze the results.

[0212] A batch image processing system for single molecule image processing, comprising:

[0213] The image input module is equipped with a user interface for selecting and receiving single or multiple image files, and uses the cv2.imread() function of OpenCV to read images;

[0214] The image preprocessing module is equipped with a grayscale processing unit and an image cropping unit, and uses the cv2.cvtColor() function of OpenCV and the image slicing operation to perform grayscale conversion and cropping on the image;

[0215] The contrast enhancement module is equipped with a contrast adjustment unit and uses the cv2.convertScaleAbs() function of OpenCV to enhance the contrast of the image;

[0216] The threshold segmentation module is equipped with a threshold processing unit and uses the cv2.threshold() function of OpenCV to realize the binary segmentation of the image;

[0217] The feature detection and marking module is configured with a single image feature detection unit and a dual image feature detection unit, and uses a color marking method and a spatial neighborhood search algorithm to realize feature detection and marking;

[0218] The feature counting and statistics module is equipped with a data recording unit and a data export unit, and uses the OpenPyXL library to realize the recording and export of statistical data;

[0219] The result output module is equipped with an image saving unit and a visualization display unit, and uses OpenCV's cv2.imwrite() function and Matplotlib library to save and display the processing results.

[0220] Specific embodiments refer to Figure 2-Figure 9 :

[0221] S1: Processing simulated clinical samples on a microfluidic chip, collecting images taken by a microscope on the chip, and generating angular momentum for captured single molecules by forward and reverse injection;

[0222] The collected image is a 2368*1720 RGB 24-bit color image, with each pixel occupying 3 bytes of storage space. The images generated by the forward fluid and the reverse fluid are imported into the system, and the images are processed using the system's preset parameters. After the system completes image assembly and feature detection, statistics are performed and a result graph automatically pops up to observe whether there is a swing of more than 50%. If there is no sample, there may be a problem. If it exceeds 50%, proceed to the next step.

[0223] S1.1: adjust the image size to the specified size of 1000*500 to obtain the processed image data;

[0224] S1.2: The contrast of the enhanced image is 1.5 times of the original one;

[0225] According to the contrast adjustment formula

[0226] new_pixel=average+contrast_factor×(original_pixel-average), where original_pixel is the pixel value of the original image, average is the average brightness of the image, and contrast_factor is the contrast adjustment coefficient.

[0227] S1.3: convert the enhanced image into a grayscale image;

[0228] According to the grayscale conversion formula Gray = 0.299 × R + 0.587 × G + 0.114 × B, the image is converted into a single-channel gray image, where Gray represents grayscale, R represents red, G represents green, and B represents blue;

[0229] S1.4: Convert the grayscale image into a numpy array for subsequent processing;

[0230] Convert the grayscale image object to a NumPy array by calling the np.array() function. This process involves extracting the pixel data from the object and copying it into the newly created NumPy array;

[0231] S1.5: Mark pixels in the image: mark pixels below the threshold with a specified color;

[0232] Create a pure white background image with RGBA mode, size of 1000*500, and pure white color (255, 255, 255, 255). Find the points in the grayscale image whose pixel values ​​are lower than the threshold. These points will be marked. Define the marking color. The color has a transparency value (128), red [255, 0, 0, 128], blue [0, 0, 255, 128]. Replace the pixels that meet the conditions, that is, the points below the threshold, with the specified red and blue, and keep the rest white. Crop the image: After obtaining the image size, calculate the cropping boundary: left, top, right, and bottom define the cropping area, indent a certain amount of pixels from the four boundaries of the image respectively, call Image.crop() to process the image, and only copy the data in the cropping area. Find adjacent red and blue points: Use numpy to traverse all pixels in the image, find red pixels, and check whether there are blue points within 0-2 pixels next to the red point. If adjacent red and blue points are found, Add their coordinates (x, y) to the list, iterate over all adjacent points, filter out those points whose difference in the horizontal coordinate is 1 found by the threshold, and ensure that duplicate points that are too close to each other are not selected. Adjust the coordinates of adjacent points to fit the cropped image: use index operations in numpy arrays to adjust the coordinates of adjacent points according to the cropping area so that these coordinates fit the cropped image. For each adjacent point, subtract left_crop from the horizontal coordinate and subtract top_crop from the vertical coordinate. This maps the position of the point to the cropped image coordinate system. Use ImageDraw.Draw(cropped_image) to draw on the cropped image. For each adjacent red and blue point, draw a green rectangular box with a size of enlarged_box_size and a border width of 1 pixel. Use matplotlib to display the cropped image and mark how many green rectangular boxes have been drawn to complete the statistics. Automatically pop up the image for the user to check.

[0233] S2: Collect a large number of images of unidirectional flow using an optical microscope;

[0234] The collected image is a 2368*1720 RGB 24-bit color image, and each pixel occupies 3 bytes of storage space.

[0235] S3: Run the system and select the save path;

[0236] S4: Adjust the corresponding parameters of the system according to the captured images, and import the images to be processed for batch processing;

[0237] S4.1: The contrast of the enhanced image is twice the original one;

[0238] According to the contrast adjustment formula:

[0239] new_pixel=average+contrast_factor×(original_pixel-average), where original_pixel is the pixel value of the original image, average is the average brightness of the image, and contrast_factor is the contrast adjustment coefficient.

[0240] S4.2: converting the enhanced image into a grayscale image;

[0241] According to the grayscale conversion formula Gray = 0.299 × R + 0.587 × G + 0.114 × B, the image is converted into a single-channel gray image, where Gray represents grayscale, R represents red, G represents green, and B represents blue;

[0242] S4.3: Convert the grayscale image into a numpy array for subsequent processing;

[0243] Convert the grayscale image object to a NumPy array by calling the np.array() function. This process involves extracting the pixel data from the object and copying it into the newly created NumPy array;

[0244] S5: Mark pixels in the image: the parameters below the clipping threshold are marked in red, and the parameters below the grayscale threshold are selected with a green box and counted;

[0245] S6: automatic image cropping;

[0246] Draw a blue auxiliary line in the middle of the image, and perform upper and lower cropping to remove the red areas marked on the upper and lower edges so that the blue auxiliary line only intersects with the boundary line of the captured image. Mark the pixels near the intersection point with green, crop the vertical coordinates of the green pixel points of the image, crop the image left and right, and delete the blue auxiliary line at the same time to ensure that there is no red mark on the image and leave the valid area of ​​the image.

[0247] S7: Draw a rectangular box to mark black pixels: Use ImageDraw.Draw(cropped_image) to draw on the cropped image. For each black pixel below the grayscale threshold, draw a green rectangular box with a size of enlarged_box_size and a border width of 5 pixels.

[0248] S8: Display and save the image: Use matplotlib to display the cropped image, mark how many green rectangles are drawn to complete the statistics, and save the image to the specified path.

[0249] S9: Export statistical tables: Use openpyxl to create and manage Excel files and save them to the directory specified by the user.

[0250] In actual operation, JetBrains Pycharm 2023.2.5 (Professional Edition) is installed to realize image processing and statistical functions. It is necessary to install tkinter (standard library), PIL, numpy, matplotlib.pyplot, openpyxl, platform (standard library), subprocess (standard library), pathlib (standard library), and PyInstaller modules to realize specific functions.

[0251] Therefore, the present invention adopts the above-mentioned batch image processing system and method for single-molecule image processing, and provides an efficient, stable, and easy-to-operate batch image processing system by combining a graphical user interface. It can meet the actual needs of users at a lower computing cost and a faster speed, while avoiding the dependence of machine learning and deep learning methods on large amounts of data, model training, and computing resources, and completes the tasks of automatic cropping, automatic image adjustment, threshold processing, feature detection, and image assembly.

[0252] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.

Claims

1. A batch image processing method for single molecule image processing, characterized in that: The following steps are involved: S1. Image input: Use the cv2.imread() function in the OpenCV library to receive and read a single or multiple image files selected by the user; S2, preprocessing the input image, including grayscale processing, image cropping, automatic image cropping and contrast enhancement; Grayscale processing: Use the cv2.cvtColor() function in the OpenCV library to convert the color image into a grayscale image. The weighted formula is Gray = 0.299 × R + 0.587 × G + 0.114 × B. Image cropping, based on the cropping parameters input by the user, uses image slicing operations to remove irrelevant areas on the top, bottom, left, and right sides of the image; Contrast enhancement: Use OpenCV's cv2.convertScaleAbs() function to adjust the contrast of the grayscale image according to the contrast enhancement factor set by the user; S3. Target feature detection and marking are performed on the preprocessed image, including single image feature detection and dual image feature detection. Based on the grayscale threshold input by the user, the enhanced image is globally threshold segmented. The dual image feature detection uses color marking method to mark the target features of the two images respectively, and the transparency is superimposed by cv2.addWeighted() function to generate a composite image. Adjacent features are detected in the composite image and marked with green rectangular boxes. S4. Count and store the detected target features, record the coordinates and quantity of the green rectangular boxes, and use the OpenPyXL library to export the statistical data into an Excel file; S5. Use OpenCV's cv2.imwrite() function to save the processed image, save the processed image and statistical results to the path specified by the user, and provide visualization and data export functions.

2. A batch image processing method for single molecule image processing according to claim 1, characterized in that: The grayscale processing process is as follows: Read the RGB channel values ​​of a color image; Apply the gray value calculation formula to each pixel to generate the corresponding gray image; Use OpenCV's cv2.cvtColor() function for conversion.

3. A batch image processing method for single molecule image processing according to claim 2, characterized in that: The image cropping process is as follows: Get the original width and height of the image; Calculate the coordinates of the cropped image area according to the cropping parameters to ensure that the cropped area is within the image boundary; Use OpenCV's crop function to perform the cropping operation and generate the cropped image.

4. A batch image processing method for single molecule image processing according to claim 3, characterized in that: The contrast enhancement process is as follows: Get the contrast enhancement factor set by the user Apply contrast enhancement algorithms to grayscale images to adjust the grayscale value of each pixel and enhance image details; Use OpenCV's cv2.convertScaleAbs() function to implement contrast adjustment and generate an enhanced image.

5. A batch image processing method for single molecule image processing according to claim 4, characterized in that: The threshold segmentation process is as follows: Get the grayscale threshold set by the user; Apply the threshold segmentation formula to each pixel to generate a binary image, and mark the pixels below the threshold as the target area. The threshold segmentation formula is as follows: Use OpenCV's cv2.threshold() function to implement efficient binarization processing and generate a binary image.

6. A batch image processing method for single molecule image processing according to claim 5, characterized in that: The layer overlay process is as follows: Load images at different stages of image processing as separate layers; Set the transparency of each layer to ensure that the marker color is clearly visible; Generate a composite image after superposition, retaining the characteristic information of each layer.

7. A batch image processing method for single molecule image processing according to claim 5, characterized in that: The process of counting the detected target features is as follows: a. During feature detection, record the coordinates of each green rectangle; b. Count the total number of green rectangles as a measure of the number of features; c. Use counting variables or lists to store statistical data; d. Store feature counts and associated data for each image in an internal data structure (such as a list or dictionary). e. Collect statistical data while reading and processing image data using OpenCV; f. Use OpenPyXL library to export statistical data into Excel files for easy viewing and further data analysis.

8. The batch image processing method for single molecule image processing according to claim 5, characterized in that: The data export process is as follows: Export feature counts and related data to Excel tables to support users in subsequent data processing and analysis; Use OpenPyXL to create a workbook, set table headers, and write statistical data row by row; Provides the function of automatically opening saved Excel files, so that users can view statistical results instantly; the visual display process is as follows: Use Matplotlib and other drawing libraries to generate visualization charts, including the original image, the red pixel detection image, the cropped image, and the image with a green rectangular box; Provides an interactive window that allows users to zoom in, zoom out, and pan to view image details, making it easier for users to verify and analyze processing results.

9. A batch image processing system for single molecule image processing as claimed in any one of claims 1 to 8, characterized in that: Includes the following modules: The image input module is equipped with a user interface for selecting and receiving single or multiple image files, and uses the cv2.imread() function of OpenCV to read images; The image preprocessing module is equipped with a grayscale processing unit and an image cropping unit, and uses the cv2.cvtColor() function of OpenCV and the image slicing operation to perform grayscale conversion and cropping on the image; The contrast enhancement module is equipped with a contrast adjustment unit and uses the cv2.convertScaleAbs() function of OpenCV to enhance the contrast of the image; The threshold segmentation module is equipped with a threshold processing unit and uses the cv2.threshold() function of OpenCV to achieve binary segmentation of the image; The feature detection and marking module is configured with a single image feature detection unit and a dual image feature detection unit, and uses a color marking method and a spatial neighborhood search algorithm to realize feature detection and marking; The feature counting and statistics module is equipped with a data recording unit and a data export unit, and uses the OpenPyXL library to realize the recording and export of statistical data; The result output module is equipped with an image saving unit and a visualization display unit, and uses OpenCV's cv2.imwrite() function and Matplotlib library to save and display the processing results.

Citation Information

Patent Citations

  • A remote sensing image sea surface ship detection method based on visual attention mechanism and information entropy

    CN109427055A

  • Single-frame infrared image weak and small target detection method and device, equipment and storage medium

    CN113409352A

  • Full-scribing high-throughput color pathological imaging analysis instrument and method

    CN115032196A

  • Automatic testing method and system for effectiveness of router game acceleration function

    CN116781556A

  • Picture classification method and computing device

    CN117975474A