Design and programming of image processing for bacteria counting and classification for the scan machine

110 7 0
Design and programming of image processing for bacteria counting and classification for the scan machine

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

MINISTRY OF EDUCATION AND TRAINING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY AND EDUCATION FACULTY FOR HIGH QUALITY TRAINING GRADUATION THESIS AUTOMATION AND CONTROL ENGINEERING TECHNOLOGY DESIGN AND PROGRAMMING OF IMAGE PROCESSING FOR BACTERIA COUNTING AND CLASSIFICATION FOR THE SCAN MACHINE ADVISOR : TS NGUYỄN VĂN THÁI STUDENT : TẠ YẾN NHI SKL011309 Ho Chi Minh City, June 2023 BỘ GIÁO DỤC & ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT TP HỒ CHÍ MINH KHOA ĐIỆN – ĐIỆN TỬ BỘ MÔN TỰ ĐỘNG ĐIỀU KHIỂN -∞∆∞ - ĐỒ ÁN TỐT NGHIỆP DESIGN AND PROGRAMMING OF IMAGE PROCESSING FOR BACTERIA COUNTING AND CLASSIFICATION FOR THE SCAN MACHINE GVHD: TS Nguyễn Văn Thái SVTH: Tạ Yến Nhi MSSV: 19151265 Tp Hồ Chí Minh tháng năm 2022 ACKNOWLEDGEMENT I would like to express my heartfelt gratitude to the following individuals and organizations who have played significant roles and provided invaluable support during my graduation thesis: • THIS PROJECT IS INVESTED AND FUNDED BY LABONE SCIENTIFIC CO LTD • Dr Nguyen Van Thai, my dedicated and knowledgeable supervisor, for his guidance, resources, and insightful ideas throughout the research process • The team at LABone Scientific Co Ltd, who contributed their expertise in mechanics and laboratory operations to assist in the hardware construction of the scanning device and cultivation of bacterial samples • SGS VIETNAM LTD, for their collaboration and support in providing the opportunity to collect bacterial data for my study • The talented members of the 3DvisionLab laboratory's Image Processing team, for their expertise and unwavering support in overcoming challenges and achieving the objectives of my thesis • My PARENTS & family, for their unwavering support, encouragement, and provision of necessary resources during this thesis journey • My classmates, for their camaraderie, collaboration, and assistance throughout the demanding process of the thesis • The esteemed Department of Electrical and Electronics Engineering faculty members, particularly the Automatic Control and Control Systems educators, for their comprehensive instruction and foundational knowledge I am sincerely grateful for these individuals and organizations' support, guidance, and contributions Their efforts have significantly impacted the quality and success of my research -i- LỜI CAM ĐOAN Em xin cam đoan đề tài “Thiết kế lập trình xử lý ảnh cho máy SCAN đếm phân loại khuẩn lạc.” em tự thực hiện, dựa vào tham khảo số tài liệu trước đó, hỗ trợ giúp đỡ Thầy - TS Nguyễn Văn Thái không chép từ tài liệu hay cơng trình khác Tp Hồ Chí Minh, ngày… tháng năm 2022 Sinh viên thực (Ký ghi rõ họ tên) Tạ Yến Nhi -ii- BỘ GIÁO DỤC VÀ ĐÀO TẠO CỘNG HÓA XÃ HỘI CHỦ NGHĨA VIỆT NAM TRƯỜNG ĐẠI HỌC SPKT TP.HỒ CHÍ MINH ĐỘC LẬP – TỰ DO – HẠNH PHÚC KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN TỰ ĐỘNG ĐIỀU KHIỂN o0o NHIỆM VỤ ĐỒ ÁN TỐT NGHIỆP Họ tên sinh viên: Tạ Yến Nhi MSSV: 19151265 Ngành: Công nghệ kỹ thuật Điều khiển Tự động hóa Lớp: 191513B Hệ đào tạo: Đại học quy Khóa: 2019 Giảng viên hướng dẫn: TS Nguyễn Văn Thái Ngày nhận đề tài: 31/1/2023 Ngày nộp đề tài: 30/6/2023 Tên đề tài: Thiết kế lập trình xử lý ảnh cho máy SCAN đếm phân loại khuẩn lạc Nội dung thực đề tài: • Thiết kế chiếu sáng cho máy scan • Thiết kế app cho hệ điều hành Window sử dụng WPF • Nghiên cứu, thiết kế thuật toán đếm khuẩn lạc, kiểm tra màu sắc cơng nghệ xử lý ảnh (Image Processing) trí tuệ nhân tạo (AI) • Nghiên cứu phương thức chuyển tọa độ pixel sang tọa độ thực để đo kích thước khuẩn lạc • Hiển thị kết lên phần mềm, cho phép người dùng tinh chỉnh kết quả, lưu truy xuất kết • Lập trình kết nối với camera công nghiệp máy scan barcode GIẢNG VIÊN HƯỚNG DẪN BỘ MÔN ĐIỀU KHIỂN TỰ ĐỘNG -iii- BỘ GIÁO DỤC VÀ ĐÀO TẠO CỘNG HÓA XÃ HỘI CHỦ NGHĨA VIỆT NAM TRƯỜNG ĐẠI HỌC SPKT TP.HỒ CHÍ MINH ĐỘC LẬP – TỰ DO – HẠNH PHÚC KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN TỰ ĐỘNG ĐIỀU KHIỂN o0o NHẬN XÉT CỦA GIẢNG VIÊN HƯỚNG DẪN Họ tên sinh viên: Tạ Yến Nhi MSSV: 19151265 Ngành: Công nghệ kỹ thuật Điều khiển Tự động hóa Lớp: 171513B Giáo viên hướng dẫn: TS Nguyễn Văn Thái Tên đề tài: Thiết kế lập trình xử lý ảnh cho máy SCAN đếm phân loại khuẩn lạc Nội dung đề tài khối lượng công việc thực hiện: Hoàn thành nội dung đặt đề tài Cụ thể là: • Thiết kế chiếu sáng cho máy scan • Thiết kế app cho hệ điều hành Window sử dụng WPF • Nghiên cứu, thiết kế thuật tốn đếm khuẩn lạc, kiểm tra màu sắc cơng nghệ xử lý ảnh (Image Processing) trí tuệ nhân tạo (AI) • Nghiên cứu phương thức chuyển tọa độ pixel sang tọa độ thực để đo kích thước khuẩn lạc • Hiển thị kết lên phần mềm, cho phép người dùng tinh chỉnh kết quả, lưu truy xuất kết • Lập trình kết nối với camera công nghiệp máy scan barcode Hạn chế: mô hình cần cải thiện độ xác, thời gian nhận diện số lượng mẫu khuẩn lạc đếm Đề nghị bảo vệ hay không:……………………………………………… Đánh giá loại:……………………………………………… Điểm: …… Bằng chữ:……………………… Tp Hồ Chí Minh, ngày… tháng… năm 2022 Giảng viên hướng dẫn (Ký ghi rõ họ tên) -iv- BỘ GIÁO DỤC VÀ ĐÀO TẠO CỘNG HÓA XÃ HỘI CHỦ NGHĨA VIỆT NAM TRƯỜNG ĐẠI HỌC SPKT TP.HỒ CHÍ MINH ĐỘC LẬP – TỰ DO – HẠNH PHÚC KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN TỰ ĐỘNG ĐIỀU KHIỂN o0o LỊCH TRÌNH THỰC HIỆN ĐỒ ÁN TỐT NGHIỆP Họ tên sinh viên:Tạ Yến Nhi MSSV: 19151265 Tên đề tài: Thiết kế lập trình xử lý ảnh cho máy SCAN đếm phân loại khuẩn lạc STT NGÀY/TUẦN Tuần 6/2-12/2 NỘI DUNG SV THỰC HIỆN Thực chọn đề tài Gặp GVHD để phổ biến quy định xác nhận đề tài Lên ý tưởng thiết kế chiếu sáng, tìm hiểu camera, lựa chọn linh kiện, đặt hàng linh kiện Tuần 2 Nhận linh kiện đặt hàng, thực kết nối phần 13/2-19/2 camera với máy tính, test ánh sáng hệ thống Tuần 3, 4, Nghiên cứu tổng quan hệ thống Nghiên cứu 20/2 – 6/3 tốn Machine Learning để tìm phương pháp nhận diện phù hợp sử dụng model Unet, thuật tốn Watersheds Thu thập liệu từ cơng ty Tiến hành lập trình auto-label cho liệu Tuần 5, 6, 6/3 – 26/3 Tuần 27/3 – 2/4 Thu thập liệu từ công ty Tiến hành chỉnh sửa label cho liệu Huấn luyện mơ hình Tử nghiệm độ xác mơ hình Tuần 9, 10, 11 Nghiên cứu lập trình giao diện WPF, kết 3/4 – 23/4 nối với thiết bị ngoại vi (camera, máy quét barcode) -v- XÁC NHẬN GV Tuần 12 24/4 – 30/4 tin Python CSharp Tuần 13, 14 Nghiên cứu thuật toán Camera Calibration để đo 1/5 – 14/5 Tuần 15, 16 15/5 – 21/5 Tuần 17, 19 10 11 Nghiên cứu giao tiếp API để truyền nhận thông 29/5 – 18/6 Tuần 19, 20, 21 kích thước thực khuẩn lạc Lập trình hồn thiện tính giao diện Sửa lỗi phần mềm, hiệu chỉnh phần cứng Viết báo cáo đồ án 19/6– 30/6 Giảng viên hướng dẫn (Ký ghi rõ họ tên) -vi- TABLE OF CONTENTS CHAPTER ABSTRACT 1.1 Problem Statement 1.2 The objective (goals) 1.3 Research Scope 1.4 Research limit 1.5 Research content 1.6 Report structure CHAPTER LITERATURE REVIEW 2.1 Machine Learning 2.1.1 Introduction 2.1.2 Machine Learning Workflow 2.2 Image Segmentation 2.2.1 Introduction 2.2.2 The input and output of the Image Segmentation problem 2.2.3 The Applications of Image Segmentation 2.3 U-Net: Convolutional Networks for Biomedical Image Segmentation 2.3.1 Introduction 2.3.2 Network Architecture 2.3.3 Understanding Convolution, Max Pooling, and Transposed Convolution 12 2.3.3.1 Convolution operation 12 2.3.3.2 Max pooling operation 12 2.3.3.3 Upsampling 13 2.3.4 Activation, loss function, metrics 14 2.3.4.1 Activation function 14 2.3.4.2 Loss function 15 2.3.4.3 Evaluation metrics 16 2.3.5 Resnet50 (Residual Network) 16 2.3.6 Adam optimizer 17 2.4 Segmentation using Morphological Watersheds 19 2.5 Camera Calibration 21 2.5.1 Camera calibration in computer vision 21 2.5.2 Using Zhang’s Technique to Find Intrinsic Parameters 21 2.5.2.1 Pinhole camera model 21 2.5.2.2 The projection matrix 23 -vii- 2.5.2.3 Viewing under rigid motion 24 2.5.2.4 Intrinsic camera parameters 25 2.6 Segmentation in RGB Vector Space 26 2.7 Window API (Win32 API) 27 2.8 Light in machine vision 28 2.8.1 The importance of light in machine vision tasks 28 2.8.2 Light in machine vision 28 2.8.3 Lighting technique 29 2.9 Data Storage 31 2.9.1 SQLite 31 2.9.2 XML 32 CHAPTER SYSTEM DESIGN AND IMPLEMENTATION 33 3.1 Hardware Design 33 3.1.1 Hardware design requirements 33 3.1.2 Design of an image acquisition system 33 3.1.2.1 Camera 33 3.1.2.2 Lens 34 3.1.3 Lighting system design 35 3.1.3.1 Diagram of the lighting system 35 3.1.3.2 Select dome light 36 3.1.3.3 Select backlight 37 3.2 Software Design 39 3.2.1 Program design of the software 39 3.2.1.1 Software design requirements 39 3.2.1.2 Software design 40 3.2.2 Operational interface design 40 3.3 System construction 44 3.3.1 Prepare the dataset and train the model 44 3.3.2 Predict 55 3.3.3 Window API communication 57 3.3.4 Separation and counting of colonies 59 3.3.4.1 Separation of colonies and counting the number of whole colonies 59 3.3.4.2 Conditional colony counting algorithm 60 3.3.5 Database storage 61 3.3.5.1 The sample-related datatable 61 3.3.5.2 The preset parameter-related datatable 62 -viii- CHAPTER 4: RESULTS, OBSERVATIONS, AND EVALUATIONS Figure 4-30 The result of the edit screen and the manual bacterial colony deletion feature Figure 4-31 History of session changes result -77- CHAPTER 4: RESULTS, OBSERVATIONS, AND EVALUATIONS Figure 4-32 Details history of session changes result Figure 4-33 App activity history Figure 4-34 Data retrieval results -78- CHAPTER 4: RESULTS, OBSERVATIONS, AND EVALUATIONS Figure 4-35 Export Excel result Figure 4-36 Export PDF result 4.8 Evaluate The model performs basic functions including: • Ability to zoom in on images -79- CHAPTER 4: RESULTS, OBSERVATIONS, AND EVALUATIONS • Minimum bacteria counting size: 0.5mm • Counting mode: automatic and manual control • Counting on circular Petri dishes of 90mm and 100mm • Counting on Petri dishes, surface culture dishes, and colored bacterial culture media • Automatic separation of bacterial clusters • Differentiating bacterial colors on different types of colored culture media • Creating exclusion polygon regions • Exporting data to print reports, PDFs, images (jpg, png, bmp), and Excel • Tracking origin: image/sample number/comments/date/time • Ability to scan barcodes for each sample • Allowing image import from device or camera capture • Enabling the creation and storage of parameters for each type of bacteria Due to limited image data, the algorithm is only performed on a limited number of collected bacterial samples To execute the algorithm, Machine Learning and Deep Learning libraries are required, and these libraries perform well and quickly on GPUs Therefore, for devices without a graphics card, the counting algorithm may run slower, approximately 4-5 times slower However, due to the limited time of the project, these issues will be addressed and improved in the future -80- CHAPTER 5: CONCLUSION AND FUTURE DEVELOPMENT CHAPTER CONCLUSION 5.1 Conclusion The research project has reached the level of experimental investigation It has achieved the basic objectives set forth; however, due to limitations in terms of time and the number of available bacterial samples, the results have not been obtained for all types of bacterial colonies Additionally, the algorithm's accuracy is not yet high, and the interface lacks complete functionality for all plate samples 5.2 Future development Areas for improvement and development: • Collecting additional and improving data for bacterial colony detection on multiple samples • Enhancing and adding features to the Windows app • Seeking solutions to reduce the detection speed for the model • Integrating a robotic arm to automate barcode scanning and bacterial colony counting • Uploading the collected data to a cloud platform, allowing all users within a business to simultaneously observe and enabling developers to easily gather more data for new samples • Designing a lighting circuit to reduce the cost of the product -81- REFERENCES [1] Vietnam Standard TCVN 11039 – 2015 on Food aditive - Microbiological analyses [2] Hüseyin Ateş and Ömer Nezih Gerek (2009, September 14-16) An Image- Processing Based Automated Bacteria Colony Counter Department of Electrical and Electronics Engineering, Anadolu University 26555 Eskisehir Turkey [3] Alessandro Ferraria , Stefano Lombardia, Alberto Signoronia et al(2016, July 8) Bacterial Colony Counting with Convolutional Neural Networks in Digital Microbiology Imaging Information Engineering Dept., University of Brescia, Brescia (Italy) Futura Science Park, Copan Italia S.p.A., Brescia (Italy) [4] Gabriel M ALVES and Paulo E CRUVINEL (2016, June 30) Customized Computer Vision and Sensor System for Colony Recognition and Live Bacteria Counting in Agriculture Embrapa Instrumentaỗóo, Rua XV de Novembro 1452, São Carlos, SP, 13560-970, Brazil, Universidade Federal de São Carlos, Rod Washington Luís, s/n, São Carlos, SP, 13565-905, Brazil [5] Harshall Lamba (2019, Feb 17) Understanding Convolution, Max Pooling, and Transposed Convolution https://towardsdatascience.com/understanding- semantic- segmentation- with- unet- 6be4f42d4b47 [6] Analytics Vidhya (2020, Sep 15) Camera Calibration - Theory and Implementation https://medium.com/analytics-vidhya/camera-calibration-theory- and-implementation-b253dad449fb [7] Zhengyou Zhang (2008, Aug 13) A Flexible New Technique for Camera Calibration Microsoft Research, One Microsoft Way, Redmond, WA 98052-6399, USA [8] Wilhelm Burger (2016, May 16) Zhang’s Camera Calibration Algorithm: In- Depth Tutorial and Implementation University of Applied Sciences Upper Austria, -82- School of Informatics, Communications and Media, Softwarepark 11, 4232 Hagenberg, Austria [9] Rafael C Gonzalez and Richard E Woods (2008) Color Image Processing Digital Image Processing, third edition, Pearson Education Inc, Upper Saddle River, 1, 445-447 [10] Shruti Jadon (2020, September 3) A survey of loss functions for semantic Segmentation IEEE Member [11] Yao Yuhua, Liu Lixiong, Liao Lejian, Wei Ming, Guo Jianping, Li Yinghui et al (2012) Sigmoid Gradient Vector Flow for Medical Image Segmentation School of Computer Science, Beijing Institute of Technology, Beijing, 100081, P.R.China [12] Karen Simonyan and Andrew Zisserman (2015, April 10) Very deep convolutional networks for large-scale image recognition Visual Geometry Group, Department of Engineering Science, University of Oxford [13] Sebastian Ruder (2017, Jun 15) An overview of gradient descent optimization algorithms Insight Centre for Data Analytics, NUI Galway Aylien Ltd., Dublin [14] Diederik P Kingma and Jimmy Lei Ba Adam (2015) A Method for Stochastic Optimization International Conference on Learning Representations [15] Olaf Ronneberger, Philipp Fischer, and Thomas Brox et al (2015) U-Net: Convolutional Networks for Biomedical Image Segmentation Computer Science Department and BIOSS Centre for Biological Signalling Studies, University of Freiburg, Germany [16] Vincent Dumoulin and Francesco Visin (2018, January 12) A guide to convolution arithmetic for deep learning FMILA, Université de Montréal AIRLab, Politecnico di Milan -83- APPENDIX Manual Switch on the power by turning the switch to the right side of the device to supply power to the lighting Switch position After the system is powered, the LED light on the switch will illuminate Supply power to the adapter to adjust the brightness of the two lights Adapter switch position Connect the USB port from the device to the computer (connect to the USB 3.0 port) Start application -84- Screen after launching the application The user enters their name in the User Name field (Note: the entered username must be at least characters long and should not contain special characters) After entering the name, if it is valid, the user will be allowed to select OK to proceed with the next steps After selecting OK, the user will be allowed to choose between two modes: Use barcode device and Open location file -85- Input Username If Open location file is selected, the application will switch to the main screen as shown in Figure X, allowing the user to open an image If Use barcode device is selected, the application will switch to the barcode scanning screen for the user to perform barcode scanning On this screen, the user selects Click here to find a scanner to check if the computer is connected to the scanning device If connected, the screen will display a message indicating that the device has been found Then, the user proceeds to select the COM port for scanning, puts the barcode into the scanner, and the result will be displayed on the screen Press Next to go to the main screen as shown in Figure below: -86- Scan barcode screen Main window -87- The functionalities of the buttons on the main screen will be listed in Table below: Button Icon Feature Open File Open an image that user wants to process Save Save current sample information in a folder Open Camera Run camera Capture Take an image Export PDF Export the current sample as a PDF file Export Excel Export the current sample as an Excel file Add Section Creating exclusion polygon regions Use: select each point on the image to form a polygon area Press Enter key to complete the polygon Select the polygon area and Press the Delete key if you want to remove this polygon Database Open the window database to access data History View all history of app activities Zoom in Zoom in image view Zoom out Zoom out the image view Fit to screen Remove zoom-in/zoom-out functionality and set the image to its initial state Eye Visible / Hidden the marker of colonies Scan Scan a new barcode Add preset parameter Add a new preset parameter Delete preset parameter Delete the current preset parameter -88- Change Plating Parameter Change the plating parameter in the current preset parameter Change Display Options Parameter Change the display option (marker style, marker color) parameter in the current preset parameter Change Color Parameter Change the color parameter in the current preset parameter Edit Turn on manual counting mode Use: Click the left mouse on the image view to add colony Click the right mouse on the colony marker area to remove this colony Count Start count process Validate Insert the current sample into the database The information entered by the user is listed in the table below: Total CFU Feature Discard debris Adjust the count result limit If the count result is lower or exceeds the set limit, the displayed count result will be red Sample number Input sample number if sample without scan code -89- Dilution Choose dilution (dilution concentration) This information will not affect the counting result Disk diameter Input disk diameter Volume A number of ml of colony culture solution This information is used to calculate CFU/ml Use the features above to count and save bacterial colonies into the database To access each sample in the database for viewing and editing, the user can doubleclick on the data row of that sample The screen for editing and viewing history will be displayed as Figure below After making edits, the user can press Save to save the updated information Edit Screen -90- S K L 0

Ngày đăng: 28/12/2023, 18:51

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan