📚
DLIP
  • Introduction
  • Prerequisite
  • Image Processing Basics
    • Notes
      • Thresholding
      • Spatial Filtering
      • Masking with Bitwise Operation
      • Model n Calibration
    • Tutorial
      • Tutorial: Install OpenCV C++
      • Tutorial: Create OpenCV Project
      • Tutorial: C++ basics
      • Tutorial: OpenCV Basics
      • Tutorial: Image Watch for Debugging
      • Tutorial: Spatial Filter
      • Tutorial: Thresholding and Morphology
      • Tutorial: Camera Calibration
      • Tutorial: Color Image Processing
      • Tutorial: Edge Line Circle Detection
      • Tutorial: Corner Detection and Optical Flow
      • Tutorial: OpenCV C++ Cheatsheet
      • Tutorial: Installation for Py OpenCV
      • Tutorial: OpenCv (Python) Basics
    • LAB
      • Lab Report Template
      • Lab Report Grading Criteria
      • LAB Report Instruction
      • LAB: Grayscale Image Segmentation
        • LAB: Grayscale Image Segmentation -Gear
        • LAB: Grayscale Image Segmentation - Bolt and Nut
      • LAB: Color Image Segmentation
        • LAB: Facial Temperature Measurement with IR images
        • LAB: Magic Cloak
      • LAB: Straight Lane Detection and Departure Warning
      • LAB: Dimension Measurement with 2D camera
      • LAB: Tension Detection of Rolling Metal Sheet
  • Deep Learning for Perception
    • Notes
      • Lane Detection with Deep Learning
      • Overview of Deep Learning
        • Object Detection
        • Deep Learning Basics: Introduction
        • Deep Learning State of the Art
        • CNN, Object Detection
      • Perceptron
      • Activation Function
      • Optimization
      • Convolution
      • CNN Overview
      • Evaluation Metric
      • LossFunction Regularization
      • Bias vs Variance
      • BottleNeck Unit
      • Object Detection
      • DL Techniques
        • Technical Strategy by A.Ng
    • Tutorial - PyTorch
      • Tutorial: Install PyTorch
      • Tutorial: Python Numpy
      • Tutorial: PyTorch Tutorial List
      • Tutorial: PyTorch Example Code
      • Tutorial: Tensorboard in Pytorch
      • Tutorial: YOLO in PyTorch
        • Tutorial: Yolov8 in PyTorch
        • Tutorial: Train Yolo v8 with custom dataset
          • Tutorial: Train Yolo v5 with custom dataset
        • Tutorial: Yolov5 in Pytorch (VS code)
        • Tutorial: Yolov3 in Keras
    • LAB
      • Assignment: CNN Classification
      • Assignment: Object Detection
      • LAB: CNN Object Detection 1
      • LAB: CNN Object Detection 2
      • LAB Grading Criteria
    • Tutorial- Keras
      • Train Dataset
      • Train custom dataset
      • Test model
      • LeNet-5 Tutorial
      • AlexNet Tutorial
      • VGG Tutorial
      • ResNet Tutorial
    • Resource
      • Online Lecture
      • Programming tutorial
      • Books
      • Hardware
      • Dataset
      • Useful sites
  • Must Read Papers
    • AlexNet
    • VGG
    • ResNet
    • R-CNN, Fast-RCNN, Faster-RCNN
    • YOLOv1-3
    • Inception
    • MobileNet
    • SSD
    • ShuffleNet
    • Recent Methods
  • DLIP Project
    • Report Template
    • DLIP 2021 Projects
      • Digital Door Lock Control with Face Recognition
      • People Counting with YOLOv4 and DeepSORT
      • Eye Blinking Detection Alarm
      • Helmet-Detection Using YOLO-V5
      • Mask Detection using YOLOv5
      • Parking Space Management
      • Vehicle, Pedestrian Detection with IR Image
      • Drum Playing Detection
      • Turtle neck measurement program using OpenPose
    • DLIP 2022 Projects
      • BakeryCashier
      • Virtual Mouse
      • Sudoku Program with Hand gesture
      • Exercise Posture Assistance System
      • People Counting Embedded System
      • Turtle neck measurement program using OpenPose
    • DLIP Past Projects
  • Installation Guide
    • Installation Guide for Pytorch
      • Installation Guide 2021
    • Anaconda
    • CUDA cuDNN
      • CUDA 10.2
    • OpenCV
      • OpenCV Install and Setup
        • OpenCV 3.4.13 with VS2019
        • OpenCV3.4.7 VS2017
        • MacOS OpenCV C++ in XCode
      • Python OpenCV
      • MATLAB-OpenCV
    • Framework
      • Keras
      • TensorFlow
        • Cheat Sheet
        • Tutorial
      • PyTorch
    • IDE
      • Visual Studio Community
      • Google Codelab
      • Visual Studio Code
        • Python with VS Code
        • Notebook with VS Code
        • C++ with VS Code
      • Jupyter Notebook
        • Install
        • How to use
    • Ubuntu
      • Ubuntu 18.04 Installation
      • Ubuntu Installation using Docker in Win10
      • Ubuntu Troubleshooting
    • ROS
  • Programming
    • Python_Numpy
      • Python Tutorial - Tips
      • Python Tutorial - For Loop
      • Python Tutorial - List Tuple, Dic, Set
    • Markdown
      • Example: API documentation
    • Github
      • Create account
      • Tutorial: Github basic
      • Tutorial: Github Desktop
    • Keras
      • Tutorial Keras
      • Cheat Sheet
    • PyTorch
      • Cheat Sheet
      • Autograd in PyTorch
      • Simple ConvNet
      • MNIST using LeNet
      • Train ConvNet using CIFAR10
  • Resources
    • Useful Resources
    • Github
Powered by GitBook
On this page
  • LAB: Grayscale Image Segmentation
  • I. Introduction
  • II. Procedure
  • Output Examples
  • III. Report
  • Appendix

Was this helpful?

  1. Image Processing Basics
  2. LAB
  3. LAB: Grayscale Image Segmentation

LAB: Grayscale Image Segmentation -Gear

PreviousLAB: Grayscale Image SegmentationNextLAB: Grayscale Image Segmentation - Bolt and Nut

Last updated 28 days ago

Was this helpful?

LAB: Grayscale Image Segmentation

I. Introduction

Goal: Defective Gear Inspection System

Plastic gears are widely used in many applications, including toys, RC cars, and plastic-based hardware. Since they are made of plastic, it is fragile and can have broken gear teeth. You are asked to develop a machine vision system that can inspect defective plastic gears.

After analyzing histogram, applying thresholding and morphology, we can identify and extract the target objects from the background by finding the contours around the connected pixels.

II. Procedure

  • Design algorithms to detect defective gear for given images.

    • Include a flowchart to explain the algorithm flow.

  • You should apply image processing algorithms, which you have learnt in class, as much as possible.

  • If you want to use other algorithms that were not covered in class, then you should briefly explain how that algorithm works.

  • For the output, you should calculate the following

    • Number of defective teeth

    • Diameter of the gear

    • Quality Inspection (Pass or Fail)

  • You must explain each process with appropriate results

  • You MUST include all the following in the report.

    • A simple flowchart to explain your algorithm

    • Apply appropriate filters to enhance image

    • Explain how the appropriate threshold value was chosen (if used)

    • Apply the appropriate morphology method to segment parts (if necessary)

      • Find the contour and draw the segmented objects. See Appendix

    • Explain how to determine the defective teeth

Output Examples

Examples: Output images of each process

III. Report

You are required to write a concise lab report and submit the program files.

First, read LAB Report Instruction

Lab Report:

  • Use the given Lab Report Template

  • Show what you have done with concise explanations and example results of each necessary process

  • In the appendix, show your source code.

  • You must write the report in markdown file (*.md),

    • Recommend (Typora 0.x < 1.x) or Notion

    • When embedding images

      Option 1) If you are using local path images: You must include local image folder with the report in zip file

      Option 2) Use online link for images.

  • Submit in both PDF and original documentation file/images

Source Code:

  • Zip all the necessary source files.

  • Only the source code files. Do not submit visual studio project files etc.

Appendix

Tip: (contour_demo.cpp)

// OpenCV - use findCountours function

C++: void findContours (InputOutputArray image, OutputArrayOfArrays contours, int mode, int method, Point offset=Point())

C++: void drawContours(InputOutputArray image, InputArrayOfArrays contours, int contourIdx, const Scalar& color, int thickness=1, int lineType=8, InputArrayhierarchy=noArray(), int maxLevel=INT_MAX, Point offset=Point() )
// Example code
// dst: binary image
 vector<vector<Point>> contours;
 vector<Vec4i> hierarchy;

  /// Find contours
 findContours( dst, contours, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE, Point(0, 0) );
  
 /// Draw all contours excluding holes
 Mat drawing( dst.size(), CV_8U,Scalar(255));
 drawContours( drawing, contours, -1, Scalar(0), CV_FILLED);
   
 cout<<" Number of coins are ="<<contours.size()<<endl;
 
 for( int i = 0; i< contours.size(); i++ )
 {
      printf(" * Contour[%d] -  Area OpenCV: %.2f - Length: %.2f \n", i, contourArea(contours[i]),                          arcLength( contours[i], true ) );       
 }

Download the test image