You are on page 1of 25

Image Processing

Lecture 5: Image Analysis


Image Segmentation

Modified by:
Assoc. Prof. Dr Hossam Mahmoud Moftah
Faculty of computers and artificial intelligence– Beni-Suef University
Region-based methods

❑Region-based methods find connected regions based on some


similarity of the pixels within them. The objective is to
produce connected regions

❑The goal is to find regions that correspond to objects as a


person sees them

❑However, if we require that the pixels in a region be too


similar, we may over-segment the image, and if we allow too
much flexibility we may merge what should be separate
objects.

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Region-based methods
❑Region growing (lab assignment using python )
✓Region growing is a bottom-up procedure that starts with
“seed” pixels, and then grows regions by adding neighboring
pixels that have similar properties (e.g. brightness, color,
texture, gradient, geometric properties)

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Region-based methods
❑Region growing
✓Region growing techniques are generally better in noisy
images where edges are extremely difficult to detect. They
are particularly useful with images which have multi-modal
histograms.

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Boundary-based methods

❑Boundary-based methods are based on finding pixel


differences rather than pixel similarities.

❑The goal is to determine a closed boundary such that an


inside (the object or foreground) and an outside (the
background) can be defined.

✓Edge detection and linking


✓Boundary tracking

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Boundary-based methods
❑ Edge detection and linking
❑Sobel operator (lab assignment using python )

✓Edges in an image are detected by using a gradient operator


such as the Sobel operator, and then thresholding the
magnitude of the gradient image.

✓Some linking of the edges to form a connected boundary is


needed. Adjacent edge pixels could be linked if they have
similar properties, e.g. a similar gradient magnitude and
orientation based on the Sobel results:

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Boundary-based methods
❑ Edge detection and linking

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Boundary-based methods
❑ Edge detection and linking
✓Edge linking is usually followed by post-processing to find
sets of linked pixels separated by small gaps, which can then
be filled in.

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Boundary-based methods
❑Boundary tracking
✓ Boundary tracking may be applied to a gradient image or any other
image containing only boundary information.

✓ Once a single point on the boundary has been identified, simply by


locating a gray-level maximum, the analysis proceeds by following
or tracking the boundary, assuming it to be a closed shape, with the
aim of finding all other pixels on that specific boundary

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Canny edge detection

❑ Canny Edge Detection is a popular edge detection algorithm. It was


developed by John F. Canny in
❑ It is a multi-stage algorithm and we will go through each stages.
❑ Steps:
1. Noise Reduction
✓ first step is to remove the noise in the image with a 5x5
Gaussian filter.
2. Finding Intensity Gradient of the Image
✓ Smoothened image is then filtered with a Sobel kernel in both
horizontal and vertical direction to get first derivative in
horizontal direction ( Gx) and vertical direction ( Gy).

Adapted from https://docs.opencv.org/3.4/da/d22/tutorial_py_canny.html


Canny edge detection

3. Non-maximum Suppression:
✓ after getting gradient magnitude and direction, a full scan of image
is done to remove any unwanted pixels which may not constitute
the edge.

✓ For this, at every pixel, pixel is checked if it is a local maximum in


its neighborhood in the direction of gradient. Check the image
below:

Adapted from https://docs.opencv.org/3.4/da/d22/tutorial_py_canny.html


Canny edge detection

❑ Point A is on the edge ( in vertical direction). Gradient


direction is normal to the edge.

❑ Point B and C are in gradient directions. So point A is


checked with point B and C to see if it forms a local maximum.
If so, it is considered for next stage, otherwise, it is suppressed (
put to zero).

In short, the result you get is a binary image with "thin edges".

Adapted from https://docs.opencv.org/3.4/da/d22/tutorial_py_canny.html


Canny edge detection

4. Hysteresis Thresholding
✓This stage decides which are all edges are really edges
and which are not.

✓For this, we need two threshold values, minVal and


maxVal.

✓Any edges with intensity gradient more than maxVal are


sure to be edges and those below minVal are sure to be non-
edges, so discarded.

✓Those who lie between these two thresholds are classified


edges or non-edges based on their connectivity.

Adapted from https://docs.opencv.org/3.4/da/d22/tutorial_py_canny.html


Canny edge detection

Adapted from https://docs.opencv.org/3.4/da/d22/tutorial_py_canny.html


Canny edge detection

❑The edge A is above the maxVal, so considered as "sure-


edge".
❑Although edge C is below maxVal, it is connected to edge A,
so that also considered as valid edge and we get that full curve.

❑ But edge B, although it is above minVal and is in same


region as that of edge C, it is not connected to any "sure-edge",
so that is discarded.

Adapted from https://docs.opencv.org/3.4/da/d22/tutorial_py_canny.html


Canny edge detection

❑Canny Edge Detection in OpenCV

Adapted from https://docs.opencv.org/3.4/da/d22/tutorial_py_canny.html


Canny edge detection

❑Canny Edge Detection in OpenCV

Adapted from https://docs.opencv.org/3.4/da/d22/tutorial_py_canny.html


Canny edge detection

❑Canny Edge Detection using medical images


original image Canny

Adapted Alexander Zotin, Konstantin Simonov, Mikhail Kurako,Yousif Hamad , Svetlana Kirillova, Edge
detection in MRI brain tumor images based on fuzzy C-means clustering, 22nd International Conference on
Knowledge-Based and Intelligent Information & Engineering Systems
Other methods
❑Active contours
✓Segmentation of medical images is a difficult task
complicated by noise and sampling artifacts.

✓Often we are looking for an object in an image which is


smooth and has a closed boundary.

✓It is possible to control the snake through a function called


the energy by analogy with physical systems.

✓The snake is active because it is continuously evolving so as


to reduce its energy.

✓By specifying an appropriate energy function we can make a


snake that evolves to have particular properties such as
smoothness.
Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Other methods
❑Active contours
✓The energy function for a snake is in two parts, the internal
and external energies.

✓The internal energy depends on the intrinsic properties of the


snake, such as its length or curvature.

✓ The external energy depends on factors such as image


structure and particular constraints the user has imposed.

✓If we want the snake to shrink like an elastic band, we need


to define an internal energy that increases with its length.

✓User-defined control points, approximately equally spaced,


specify the starting position of the snake

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Other methods
❑Active contours

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
Other methods
❑Active contours
✓Algorithm Snake

s is the arc-length parameterization of the contour C=C(s).

In general, are set to constants and their values


will influence the result.
Other methods
❑Active contours
✓ Algorithm Snake (lab assignment using python )
✓Inputs: Image I and a chain of points on the image
✓f the minimum fraction of snake points that must move in each iteration and U(p)
a small neighborhood of p and d (the average distance).

1. For each i= 1, .. , N, find the location in U(pi) for which the energy
functional is minimum and move the control point pi to that point.
2. For each i=1, …, N, estimate the curvature and look for local maxima.

✓ Set bi= 0 for all pi at which the curvature has a local maximum or
exceeds some user-defined value.
3. Update the value of the average distance, d.
Other methods
❑Active contours

Adapted from Geoff Dougherty, Image Processing for Medical Applications, CAMBRIDGE, 2009
The End

You might also like