> For the complete documentation index, see [llms.txt](https://capellac.gitbook.io/opencv/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://capellac.gitbook.io/opencv/week3/indian-institute-of-technology-image-segmentation.md).

# Indian Institute Of Technology-Image Segmentation

## Overview

* What is segmentation?
* Different approaches for image segmentation
  * Discontinuity based
  * Similarity based
* Different edge detection operators
* Linking of edge points&#x20;

  * Local processing
  * Global processing

## &#x20;Image Segmentation two Approaches

1. Discontinuity Based&#x20;
   1. Isolated Points
   2. Lines
   3. Edges
2. Similarity Based

   1. Thresholding
   2. Region Growing
   3. Region Splitting & Merging

## We are going to focus on Discontinuity Base Image Segmentation

## Point Detection ( $$|R| > T$$ ) (T = non-negative threshold)

<div align="left"><img src="https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8FuZ4mi1QuEuWfL5k%2F-MB8Ge6PJzEuQFWliR6i%2FThe-sub-image-and-the-point-detection-mask.png?alt=media&amp;token=8eedbe50-3fb0-4b30-ae95-0aaa05e51f0e" alt=""></div>

## Line Detection (masks = \[horizontal, vertical, 45, -45])

<div align="left"><img src="https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8FuZ4mi1QuEuWfL5k%2F-MB8H4cFDPU9_2vmigPE%2FThe-line-detection-masks.png?alt=media&amp;token=1611f792-3269-47ee-983d-f3f8445a48ae" alt=""></div>

## Edge Detection

{% hint style="danger" %}
Don't forget: using $$2^{nd}$$ derivative might look pretty sensible, however, it has a huge downside which is sensivity to noise in order to fix this problem we usually use GaussianBlur. Stay tuned!&#x20;
{% endhint %}

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8FuZ4mi1QuEuWfL5k%2F-MB8HS10bxnE-PXds_aN%2FEdgeDetection.PNG?alt=media\&token=fa272227-330b-4ffb-a642-3501388f1f77)

### Calculation of Derivative

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8I4rNmMVaVJlJG_gr%2F-MB8IqiSuFZqpw-NMF6Q%2F2ndDerivative.PNG?alt=media\&token=f5f7bf15-f601-49de-828a-8dbcdd099563)

### Calculation of Direction

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8I4rNmMVaVJlJG_gr%2F-MB8JFu8RZIYUU467y8w%2Fdirection.PNG?alt=media\&token=0b1a0d0e-b618-4223-acff-f349db011cb2)

### Edge Operators

Prewitt Edge Operator

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8I4rNmMVaVJlJG_gr%2F-MB8JUNdfZSM4iqoPknK%2FprewittEdgeOperator.PNG?alt=media\&token=483fba28-fa1e-4b8b-a8a1-8f4843754e1b)

Sobel Edge Operator

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8I4rNmMVaVJlJG_gr%2F-MB8Jm6PzsRDuH1I0d_H%2FSobelEdgeOperator.PNG?alt=media\&token=da3e8c43-80d2-4a45-bd2c-2649ae832028)

Example of Sobel Edge Operator Result

1. Original Image
2. Horizantal Component of Sobel Edge Detector
3. Vertical Component of Sobel Edge Detector
4. Combining Vertical and Horizontal Sobel EDge Detector

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8Jr49pt1Z-8ND6Jpe%2F-MB8KYWXxw3Us54VVKPg%2FsobelResults.PNG?alt=media\&token=9683c497-e25a-470f-8663-0a2bda6e4d98)

Laplacian Operator

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8Jr49pt1Z-8ND6Jpe%2F-MB8LFdIO2MmOqcCBGWQ%2FLaplacianOperatorFormula.PNG?alt=media\&token=e4828108-5c93-4d9a-89d0-5e38389ec888)

Laplacian Operator horizontal and Vertical

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8Jr49pt1Z-8ND6Jpe%2F-MB8LRp3-rRTMZ3fxo0B%2FLAplacianOperator.PNG?alt=media\&token=86116f6a-1ba1-4ca4-82d1-3f278cf046e9)

If we also want to add diagonal elements, laplacian operator transforms like

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8Jr49pt1Z-8ND6Jpe%2F-MB8LhT2oBFsMmDRFnCb%2Flaplacian%20operatorExtra.PNG?alt=media\&token=3bf2a2d7-7a99-4ecd-9525-2705e16e8dd5)

### Laplacian Of Gaussians (LoG)

{% hint style="success" %}
Why we need LoG, Using Laplacian what kind of downsides have? These Questions are critically important to understand the Log. We know that Laplacian uses 2nd derivative function and it's really really sensitive to noise that's a big problem but thanks to gaussian we can solve this problem and that's why we use gaussian mask before implementing laplacian mask.
{% endhint %}

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8MRGjP2jvoZY5eY-R%2F-MB8M_RFTKjyWYgKQKVa%2FLoGFormula.PNG?alt=media\&token=e01e25bf-9d8c-47bb-ab59-d8a8217c9c3b)

Laplacian of Gaussian Graphics

1. Implemented Gaussian
2. After Gaussian implementing Laplacian

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8MRGjP2jvoZY5eY-R%2F-MB8Mz8pVwO6mNr1yZHs%2FLog2.PNG?alt=media\&token=f3457991-63c9-4afd-af3f-ebab5c56f65d)

LoG Mask

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8MRGjP2jvoZY5eY-R%2F-MB8N97v1b4GhdTbVGHo%2FLogMAsk.PNG?alt=media\&token=60899811-235a-4afd-bcf9-43e6f402cae1)

Comparison Result Images

1. Original Image
2. Output of the Sobel Operator
3. Output of the LoG operator

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8MRGjP2jvoZY5eY-R%2F-MB8NfCzqM9pC8i8_AMT%2FComparisonSobelAndLoGOperators.PNG?alt=media\&token=7cf323d1-7e21-4fc4-a334-72c6af9fee48)

{% hint style="success" %}
LoG(Laplacian of Gaussian) can determine that what is the location of an edge presenting on the image.
{% endhint %}

{% hint style="success" %}
We learned that normally we don't use second derivative of function on edge detection, however, important to learn LoG operator.
{% endhint %}

### Edge Linking

1. Local Processing
2. Global Processing

We are going to look at local processing technique

{% hint style="danger" %}
Suppose that image already operated by sobel edge operator.
{% endhint %}

In this sobel edge operated image we are going to look for similarities.

**Similarity Measures.**

* Strength
* Direction (of gradient)

{% hint style="success" %}
T = Thresholding

A = Angle
{% endhint %}

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8OF1kEInqsvB-gPyv%2F-MB8RETL5kNuXq1A7Z7t%2FEdgeLinking.PNG?alt=media\&token=8596d32d-e858-4b3b-87a9-639a48249454)

## Quiz Questions

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8OF1kEInqsvB-gPyv%2F-MB8RVJXN1uEkUgQ4lI3%2FQuizQuestions.PNG?alt=media\&token=0e0b3e7e-e42e-4fd7-971d-589b29523589)

## My Answers

1. Image segmentation is simply distinguishing an object from rest of the image.
2. Basic approaches are Discontinuity based method (Edge Based Method), Region Based Method(Similarity Based). These were basic methods and there are some advance methods as well, I am going to add an image for that at the last of the page.
3. Line and Edge different because in line background is the same but there is a line top of the background. However, in edge there is a transmisson between two area.
4. In Prewitt operator there is no any emphasis but in Sobel emphasis increases when we close to the center of an image.
5. LoG stands for Laplacian of Gaussian operation. In LoG we simply apply Gaussian operation then Laplacian operator with this way we're going to be able to obtain an awesome result.

## All Image Segmentation Methods

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8UO3kkJwiiktOaBxP%2F-MB8UfQyHsGAg4JB9yMA%2FImageSegmentation%20Methods.PNG?alt=media\&token=2213bbe5-beb3-41a1-bc6a-cfaa20d7597a)

## Comparison Of Image Segmentation Methods

![](https://2797135393-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M99TkJnCKaTvw9u9gQJ%2F-MB8V0rh6anjQsWXRz3E%2F-MB8V9ykNmi04h5oa-x1%2FComparisonOfImageSegmentationTechniques.PNG?alt=media\&token=68725ec5-7bc9-4554-b3f6-c5534a171ddd)

## Extra Source:

{% embed url="<https://ijcsmc.com/docs/papers/May2014/V3I5201499a84.pdf>" %}
