image segmentation and image file...

34
Digital Image Processing Lecture # 13 Image Segmentation and Image File Formats Autumn 2012

Upload: others

Post on 15-Mar-2020

27 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing

Lecture # 13

Image Segmentation and Image File Formats

Autumn 2012

Page 2: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 2

Region-Based Segmentation

► Region Growing

1. Region growing is a procedure that groups pixels or subregions into larger regions.

2. The simplest of these approaches is pixel aggregation, which starts with a set of “seed” points and from these grows regions by appending to each seed points those neighboring pixels that have similar properties (such as gray level, texture, color, shape).

3. Region growing based techniques are better than the edge-based techniques in noisy images where edges are difficult to detect.

Page 3: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 3

Region-Based Segmentation

Example: Region Growing based on 8-connectivity

( , ) : input image array

( , ): seed array containing 1s (seeds) and 0s

( , ): predicate

f x y

S x y

Q x y

Page 4: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 4

Region Growing based on 8-connectivity

1. Find all connected components in ( , ) and erode each

connected components to one pixel; label all such pixels

found as 1. All other pixels in S are labeled 0.

2. Form an image such that, aQ

S x y

f t a pair of coordinates (x,y),

let ( , ) 1 if the is satisfied otherwise ( , ) 0.

3. Let be an image formed by appending to each seed point

in all the 1-value points in that are 8-con

Q Q

Q

f x y Q f x y

g

S f

nected to that

seed point.

4. Label each connencted component in g with a different region

label. This is the segmented image obtained by region growing.

Page 5: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 5

TRUE if the absolute difference of the intensities

between the seed and the pixel at (x,y) is T

FALSE otherwise

Q

Page 6: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 6

Page 7: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 7

4-connectivity

Page 8: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 8

8-connectivity

Page 9: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 9

Page 10: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 10

Page 11: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 11

Region Splitting and Merging

: entire image :entire image : predicate

1. For any region , If ( ) = FALSE,

we divide the image into quadrants.

2. When no further splitting is possible,

merge any adjacent regi

i

i i

i

R R Q

R Q R

R

ons and

for which ( ) = TRUE.

3. Stop when no further merging is possible.

j k

j k

R R

Q R R

Page 12: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 12

Page 13: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 13

Page 14: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 14

TRUE if and 0

FALSE otherwise

a m bQ

Page 15: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 15

K-means Clustering

► Partition the data points into K clusters randomly. Find the centroids of each cluster.

► For each data point:

Calculate the distance from the data point to each cluster.

Assign the data point to the closest cluster.

► Recompute the centroid of each cluster.

► Repeat steps 2 and 3 until there is no further change in the assignment of data points (or in the centroids).

Page 16: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

K-Means Clustering

Page 17: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

K-Means Clustering

Page 18: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

K-Means Clustering

Page 19: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

K-Means Clustering

Page 20: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

K-Means Clustering

Page 21: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

K-Means Clustering

Page 22: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

K-Means Clustering

Page 23: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

K-Means Clustering

Page 24: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 24

Clustering

► Example

D. Comaniciu and P.

Meer, Robust Analysis

of Feature Spaces:

Color Image

Segmentation, 1997.

Page 25: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 25

Image File Formats

►To understand the advantages and disadvantages of various image formats

►Categories

One category

►Raster Image Formats

►Vector Image Formats

Another category

►Binary Image Formats

►ASCII Image Formats

Page 26: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 26

Raster Image Formats ►Breaks the image into a series of color dots

called “pixels”

►The number of bits at each pixel determines the maximum number of colors

1 bits= 2 (21) colors

2 bits= 4(22) colors

4 bits= 16 (24) colors

8 bits= 256 (28) colors

16 bits= 65,536 (216) colors

24 bits = 16,777,216 (224) colors !

Page 27: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 27

Vector Image Formats

►Break the image into a set of mathematical descriptions of shapes: curve, arc, rectangle, sphere etc.

►Resolution-independent: scalable without the problem of “pixelating” .

►Not all images are easily described in a mathematical form.

How to describe a photograph?

Page 28: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Comparison

►Raster

-Resolution-dependent

-Suitable for photographs

-smooth tones and subtle details

-larger size

►Vector

-Resolution-independent

-suitable for line drawings, CAD, Logos

- Smooth curves

- Smaller size

Page 29: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 29

What are the common types of image formats

►Raster

►GIF (Graphics Interchange Format), Bitmap, JPEG,TIFF, PBM (portable Bit Map – binary), PGM (Portable Gray map – grayscale), PPM (Portable Pixel Map – color), PNM (Portable Any Map – any three), PCD(photo CD), PNG (Portable Network Graphics), etc.

►Vector: PS(postscript), EPS (embedded postscript), CDW (CorelDraw), WMF (windows metafile), SVG (Scalable vector graphics), etc.

Page 30: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 30

CompuServ GIF – Graphics Interchange Format

►First standardized in 1987 by compuserv (called GIF87a)

►Updated in 1989 to include transparency, interlacing, and animation (called GIF89a)

►Use the LZW (Lempel-Ziv Welch) algorithm for compression

►A maximum of 256 colors, so doesn’t work well for photographs

►Suitable for small images such as icons ►Simple animations

Page 31: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 31

Bitmaps

►Can create great image with 24 or even 32 bits per pixel

►File size is large, for example, a bitmap image of size 1024*768*3= 2MBs

►How to reduce size? Run Length Encoding (RLE) – lossless

►What about even smaller size? Lossy encoding such as JPEG.

Page 32: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 32

JPEG (Joint Photographic Experts

Group)

►Lossy encoding

Page 33: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 33

TIFF (Tag Image File Format)

► Tag-based image format ► Originated in 1986 at Aldus Corp. (PageMaker), the

latest version 6.0 ► Developed by Aldus and Microsoft ► Platform-independent ► Mostly used by scanners and desktop publishing ► http://www.libtiff.org/ for a TIFF library ► Support compressions of CCITT Fax 3 & 4, LZW,

JPEG etc. ► Support multiple color spaces: Grayscale, RGB,

YCbCr, CMYK etc.

Page 34: Image Segmentation and Image File Formatsweb.uettaxila.edu.pk/.../Lect13_Segmentation_3_printable.pdfImage Segmentation and Image File Formats Autumn 2012 Digital Image Processing

Digital Image Processing Lecture # 13 34

Which One to Use

►No unique answer

►For small image e.g. icon …. GIF

►For large image e.g. photograph … JPEG

►If scalability required … PS, EPS