Skip to content

TITHI-KHAN/Introduction_to_OpenCV_Brain_Image

Repository files navigation

Introduction_to_OpenCV_Brain_Image

image

image

image

OpenCV is a library of programming functions mainly for real-time computer vision. Originally developed by Intel, it was later supported by Willow Garage, then Itseez. Ref: Wikipedia

Installation

Prerequisites

- Python 3.x
- pip (Python package installer)

Installing OpenCV

To install OpenCV for Python, use pip:

pip install opencv-python

For full package (including contrib modules):

pip install opencv-python-contrib

Basic Operations

Reading, Writing, and Displaying Images

Reading an Image

image

Displaying an Image

image

Writing an Image

image

Basic Image Processing

Converting to Grayscale

image

Resizing Images

image

Drawing on Images

image

Advanced Image Processing

Edge Detection

image

Image Thresholding

image

Contour Detection

image

Code Explanation

This code demonstrates image processing techniques using the OpenCV library and matplotlib for visualization. Let's break down each part:

  1. Edge Detection with Contours:

    • The code reads an image (Image.png) using OpenCV, converts it to grayscale, applies Gaussian blur, and performs edge detection using the Canny edge detector.

    • Contours are then detected using findContours method, and they are drawn onto a separate image.

    • The original image, edge image, and contour image are plotted side by side using matplotlib.

  2. Thresholding with Contours:

    • This part is similar to the first one but involves thresholding the grayscale image to create a binary image using Otsu's thresholding method (cv2.THRESH_OTSU).

    • Contours are detected again, and the contour image is created and plotted alongside the original, grayscale, and binary images.

  3. Hierarchy of Contours:

    • Another variation of contour detection is showcased here. This time, contours are detected with the cv2.RETR_TREE retrieval mode, which retrieves all the contours and reconstructs a full hierarchy of nested contours.

    • Similar to previous parts, the original, grayscale, binary, and contour images are plotted.

  4. Metadata Extraction for Image:

    • This section extracts metadata such as file size, dimensions, and color depth from the image using OpenCV and OS libraries.
  5. DICOM Metadata Extraction:

    • It uses the pydicom library to read DICOM data from a file (0.dcm) and extracts metadata such as tag name and value.

Overall, the code provides a comprehensive demonstration of various image processing techniques and metadata extraction methods using OpenCV and other libraries in Python.

Simple Project Example: Face Detection

image

1. Reading and Displaying an Image

image

image

2. Converting an Image to Grayscale

image

3. Blurring an Image

image

4. Edge Detection

image

image

5. Image Thresholding

image

6. Resizing Images

image

7. Rotating an Image

image

image

8. Drawing Shapes on Images

image

9. Image Translation

image

image

10. Finding and Drawing Contours

image

11. Reading and Displaying an Image

image

12. Converting an Image to Grayscale

image

image

13. Gaussian Blurring

image

14. Edge Detection with Canny

image

15. Thresholding

image

image

16. Resizing Images

image

17. Rotating an Image

image

18. Drawing Shapes and Text on an Image

image

image

19. Image Translation

image

20. Finding and Drawing Contours

image

Official OpenCV Documentation

Additional Resources

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published