0% found this document useful (0 votes)
3 views

Lecture 16 Region Segmentation

The document discusses segmentation in image processing, outlining methods such as edge-based and region-based segmentation, along with their pros and cons. It details edge detection techniques, edge linking methods, and region growing approaches, emphasizing the importance of similarity measures and region merging techniques. Additionally, it introduces chain codes as a boundary representation method, highlighting their advantages and limitations in shape description and recognition.

Uploaded by

Jam Falak Shair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lecture 16 Region Segmentation

The document discusses segmentation in image processing, outlining methods such as edge-based and region-based segmentation, along with their pros and cons. It details edge detection techniques, edge linking methods, and region growing approaches, emphasizing the importance of similarity measures and region merging techniques. Additionally, it introduces chain codes as a boundary representation method, highlighting their advantages and limitations in shape description and recognition.

Uploaded by

Jam Falak Shair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Segmentation

Segmentation is the separation of one or more regions or objects in an image based on a


discontinuity or a similarity criterion. A region in an image can be defined by its border (edge) or
its interior, and the two representations are equal. There are prominently three methods of
performing segmentation:
 Pixel Based Segmentation
 Region-Based Segmentation
 Edges based segmentation
Edges based segmentation
Edge-based segmentation contains 2 steps:
 Edge Detection: In edge detection, we need to find the pixels that are edge pixels of an
object. There are many object detection methods such as Sobel operator, Laplace
operator, Canny, etc.

1 0 -1

2 0 -2

1 0 -1

Sobel vertical Operator

+1 2 1

0 0 0

-1 -2 -1

Sobel Horizontal Operator


0 -1 0

-1 4 -1

0 -1 0

Negative Laplace Operator

 Edge Linking: In this step, we try to refine the edge detection by linking the adjacent
edges and combine to form the whole object. The edge linking can be performed using
any of the two methods below:
o Local Processing: In this method, we used gradient and direction to link the
neighborhood edges. If two edges have a similar direction vector then they can be
linked.
o Global processing: This method can be done using HOG transformation(The
Histogram of Oriented Gradients (HOG) is a feature descriptor used in computer
vision for object detection.)
 Pros :
o This approach is similar to how the humans brain approaches the segmentation
task.
o Works well in images with good contrast between object and background.

 Limitations:
o Does not work well on images with smooth transitions and low contrast.

o Sensitive to noise.

o Robust edge linking is not trivial and easy to perform.

Region-Based Segmentation
In this segmentation, we grow regions by recursively including the neighboring pixels that are
similar and connected to the seed pixel. We use similarity measures such as differences in gray
levels for regions with homogeneous gray levels. We use connectivity to prevent connecting
different parts of the image.
There are two variants of region-based segmentation:
 Top-down approach
o First, we need to define the predefined seed pixel. Either we can define all pixels
as seed pixels or randomly chosen pixels. Grow regions until all pixels in the
image belongs to the region.
 Bottom-Up approach
o Select seed only from objects of interest. Grow regions only if the similarity
criterion is fulfilled.
 Similarity Measures:
o Similarity measures can be of different types: For the grayscale image the
similarity measure can be the different textures and other spatial properties,
intensity difference within a region or the distance b/w mean value of the region.
 Region merging techniques:
o In the region merging technique, we try to combine the regions that contain the
single object and separate it from the background.. There are many regions
merging techniques such as Watershed algorithm, Split and merge algorithm, etc.
 Pros:
o Since it performs simple threshold calculation, it is faster to perform.

o Region-based segmentation works better when the object and background have
high contrast.
 Limitations:
o It did not produce many accurate segmentation results when there are no
significant differences b/w pixel values of the object and the background.
Implementation:
 In this implementation, we will be performing edge and region-based segmentation. We
will be using scikit image module for that and an image from its dataset provided.
 Python3

# code
import numpy as np
import matplotlib.pyplot as plt
from skimage.feature import canny
from skimage import data,morphology
from skimage.color import rgb2gray
import scipy.ndimage as nd
plt.rcParams["figure.figsize"] = (12,8)
%matplotlib inline
# load images and convert grayscale
rocket = data.rocket()
rocket_wh = rgb2gray(rocket)
# apply edge segmentation
# plot canny edge detection
edges = canny(rocket_wh)
plt.imshow(edges, interpolation='gaussian')
plt.title('Canny detector')
# fill regions to perform edge segmentation
fill_im = nd.binary_fill_holes(edges)
plt.imshow(fill_im)
plt.title('Region Filling')
# Region Segmentation
# First we print the elevation map
elevation_map = sobel(rocket_wh)
plt.imshow(elevation_map)
# Since, the contrast difference is not much. Anyways we will perform it
markers = np.zeros_like(rocket_wh)
markers[rocket_wh < 0.1171875] = 1 # 30/255
markers[rocket_wh > 0.5859375] = 2 # 150/255
plt.imshow(markers)
plt.title('markers')
# Perform watershed region segmentation
segmentation = morphology.watershed(elevation_map, markers)
plt.imshow(segmentation)
plt.title('Watershed segmentation')
# plot overlays and contour
segmentation = nd.binary_fill_holes(segmentation - 1)
label_rock, _ = nd.label(segmentation)
# overlay image with different labels
image_label_overlay = label2rgb(label_rock, image=rocket_wh)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(24, 16), sharey=True)
ax1.imshow(rocket_wh)
ax1.contour(segmentation, [0.8], linewidths=1.8, colors='w')
ax2.imshow(image_label_overlay)
fig.subplots_adjust(**margins)

Output:
Elevation maps
Chain codes boundary representation method in digital image processing
Chain codes are a boundary representation method in digital image processing that encodes the
shape of an object by following its boundary and representing each step with a direction
code. This method is based on a sequence of connected straight-line segments of a specified
length and direction. The direction of each segment is represented by a numbering scheme,
typically based on 4-connectivity or 8-connectivity.
Here's a more detailed explanation:
1. Boundary Following:
 The process begins by tracing the boundary of an object in a specific direction (e.g.,
clockwise).
 This tracing involves moving from one boundary pixel to its adjacent neighbor.
2. Direction Coding:
 For each step along the boundary, the direction of the movement is encoded using a
numbering scheme.
 Commonly used schemes include 4-connectivity (where the adjacent pixel can be in one
of four directions: north, south, east, west) and 8-connectivity (where the adjacent pixel
can also be in the four diagonal directions).
3. Chain Code Representation:
 The sequence of direction codes forms the chain code, which represents the boundary.
 This code provides a compact and functional representation of the boundary's shape.
4. Advantages of Chain Codes:
 Shape Description:
Chain codes provide a clear and concise way to describe the shape of an object.
 Storage Efficiency:
Compared to storing the coordinates of all boundary pixels, chain codes can be more storage-
efficient.
 Suitability for Recognition:
The format of chain codes can be well-suited for certain recognition processes.
5. Limitations:
 Rotation Invariance:
Chain codes are not inherently rotation-invariant, meaning that rotating the object will change
the chain code.
 Sensitivity to Starting Point:
The chain code can vary depending on the starting point of the boundary tracing.
 Potential for Compression:
While chain codes can be more storage-efficient than storing raw pixel data, they may also be too
compressed for some computer manipulation tasks.

You might also like