87
Image Processing 主主主 主主主

Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Embed Size (px)

Citation preview

Page 1: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Processing

主講人:虞台文

Page 2: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Page 3: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Processing

Smoothing

Page 4: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Smoothing

Smoothing is also called blurring

Why smoothing?

– reduce noise and camera artifact

– reduce the resolution of an image in a

principled way

Page 5: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Smoothing

void cvSmooth(

const CvArr* src,

CvArr* dst,

int smoothtype=CV_GAUSSIAN,

int param1=3,

int param2=0,

double param3=0,

double param4=0

);

void cvSmooth(

const CvArr* src,

CvArr* dst,

int smoothtype=CV_GAUSSIAN,

int param1=3,

int param2=0,

double param3=0,

double param4=0

);

smoothtype: CV_BLUR_NO_SCALE CV_BLUR CV_GAUSSIAN CV_MEDIAN CV_BILATERAL

Depending on smoothtype

Page 6: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Smoothing

Page 7: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Smoothing

Page 8: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Example cvSmoothBLUR

MEDIAN

GAUSSIAN

BILATERAL

param1=7param2=7

param1=7

param1=7param2=7

param1=7param3=50.0Param4=3.5

Original

Page 9: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Exercise

DownloadTest Program

DownloadTest Program

Page 10: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Processing

Image Morphology

Page 11: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Morphological Operations

Morphological operations come from the word “morphing” in Biology which means “changing a shape”.

Morphing

Page 12: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Morphological Operations

Originated from set operations Can be used to manipulate object shapes s

uch as thinning, thickening, filling, etc.

Page 13: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Binary Image Representation

0 0 1 0 00 0 1 0 01 1 1 1 10 0 1 0 00 0 1 0 0

A

( 2,0), ( 1,0), (0,0), (1,0), (2,0),

(0,2), (0,1), (0, 1), (0, 2)A

Page 14: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Basic Set Operations

Page 15: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Translation and Reflection Operations

Translation Reflection ˆ , for B w w b b B , for

zA c c a z a A

A

1 2( , )z z z

(A)z B̂

B

Page 16: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Logical Operations

Page 17: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Basic Morphological Operations

Dilation– Enlarge a region

Erosion– Shrink a region

Opening– Get rid of small portions of region that jut out

from the boundary into the background region

Closing– Close up internal holes in a region and

eliminate “bays” along the boundary

Page 18: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Basic Morphological Operations

Defined based on a structure element

Morphological Operation

Structure Element

Page 19: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Structure Elements

Page 20: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Dilation

zA B z B A

A = Object to be dilatedB = Structuring element

A B

Page 21: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Dilation zA B z B A

A

B

Page 22: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Dilation zA B z B A

Page 23: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Erosion A By

zA B z B A y

A = Object to be erodedB = Structuring element

Page 24: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Erosion zA B z B A y

B

A

Page 25: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Erosion zA B z B A y

Page 26: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Example: Application of Dilation and Erosion

Remove small objects such as noise

Page 27: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Duality Between Dilation and Erosion

( )c cA B A B y

Pf) ( )cc

zA B z B A y

cc

zz B A

c

zz B A

cA B

Page 28: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Opening

( )A B A B B y

Page 29: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Opening

( )A B A B B y z zA B B B A

Combination of all parts of A that can completely contain B

Opening eliminates narrow and small details and corners.

Page 30: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Example: Opening

( )A B A B B y

Page 31: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Example: Opening

( )A B A B B y

Page 32: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Closing

( )A B A B B y

Page 33: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Closing ( )A B A B B y

Closing fills narrow gaps and notches

Page 34: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Example: Closing

( )A B A B B y

Page 35: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Example: Closing

( )A B A B B y

Page 36: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Opening vs. Closing

Duality Properties of Opening

Properties of Closing

c cA B A B

1. A B A

1. A B A

3. A B B A B

3. A B B A B

2. If then C D C B D B

2. If then C D C B D B

Idempotent property: can’t change any more

Page 37: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Example: Application of Morphological Operations

Finger print enhancement

Page 38: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Example: Application of Morphological Operations

Finger print enhancement

Page 39: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Processing

Some Applications of Image Morphology

Page 40: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Hit-or-Miss Transformation

X

W

W X Xc

( )cA X A X A W X y y*

Page 41: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Hit-or-Miss Transformation

A contains pattern X

Ac contains pattern Xc

( )cA X A X A W X y y*

Page 42: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Hit-or-Miss Transformation

( )cA X A X A W X y y*

Page 43: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Hit-or-Miss Transformation

( )cA X A X A W X y y*

Page 44: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Boundary Extraction

( )β A A A B y

A shrinks a little bit

Page 45: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Boundary Extraction

( )β A A A B y

Page 46: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Boundary Extraction

( )β A A A B y

Original image

Boundary

Page 47: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Region Filling

1c

k kX X B A

0X A :seed pixel

Enlarge the filler a little bit

Make the filler inside A

Page 48: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Region Filling 1

ck kX X B A

Original image

Results of region filling

Page 49: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Extraction of Connected Components

1k kX X B A

0X A :seed pixel

Enlarge the extractor a little bit

Make the extractor part of A

Page 50: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Extraction of Connected Components

1k kX X B A

Page 51: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Morphological Operations for Gray Images

Page 52: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Dilation and Erosion by OpenCV

void cvDilate(

const CvArr* A,

CvArr* C,

IplConvKernel* B=0,

int iterations=1

);

void cvDilate(

const CvArr* A,

CvArr* C,

IplConvKernel* B=0,

int iterations=1

);

void cvErode(

const CvArr* A,

CvArr* C,

IplConvKernel* B=0,

int iterations=1

);

void cvErode(

const CvArr* A,

CvArr* C,

IplConvKernel* B=0,

int iterations=1

);

A Source image.

C Destination image.

B Structuring element used for erosion. If it is NULL, a 3×3 rectangular structuring element is used.

iterations Number of times erosion is applied.

Page 53: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Making Your Own Kernel

IplConvKernel* cvCreateStructuringElementEx( int nCols, int nRows, int anchorX, int anchorY, int shape, int* values );

IplConvKernel* cvCreateStructuringElementEx( int nCols, int nRows, int anchorX, int anchorY, int shape, int* values );

Page 54: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

More General Morphology

A Source image.

C Destination image.temp Temporary image, required in some cases.

B Structuring element.operation

Type of morphological operation.

iterations Number of times erosion is applied.

void cvMorphologyEx(

const CvArr* A,

CvArr* C,

CvArr* temp,

IplConvKernel* B,

int operation,

int iterations

);

void cvMorphologyEx(

const CvArr* A,

CvArr* C,

CvArr* temp,

IplConvKernel* B,

int operation,

int iterations

);

Page 55: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

More General Morphology

A Source image.

C Destination image.temp Temporary image, required in some cases.

B Structuring element.operation

Type of morphological operation.

iterations Number of times erosion is applied.

void cvMorphologyEx(

const CvArr* A,

CvArr* C,

CvArr* temp,

IplConvKernel* B,

int operation,

int iterations

);

void cvMorphologyEx(

const CvArr* A,

CvArr* C,

CvArr* temp,

IplConvKernel* B,

int operation,

int iterations

);

Page 56: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

More General Morphology

CV_MOP_OPEN: C = open(A,B) = dilate(erode(A,B),B)

CV_MOP_CLOSE: C = close(A,B) = erode(dilate(A,B),B)

CV_MOP_GRADIENT: C = morph_grad(A,B) = dilate(A,B) - erode(A,B)

CV_MOP_TOPHAT: C = tophat(A,B) = A - erode(A,B)

CV_MOP_BLACKHAT: C = blackhat(A,B) = dilate(A,B) - A

CV_MOP_OPEN: C = open(A,B) = dilate(erode(A,B),B)

CV_MOP_CLOSE: C = close(A,B) = erode(dilate(A,B),B)

CV_MOP_GRADIENT: C = morph_grad(A,B) = dilate(A,B) - erode(A,B)

CV_MOP_TOPHAT: C = tophat(A,B) = A - erode(A,B)

CV_MOP_BLACKHAT: C = blackhat(A,B) = dilate(A,B) - A

Page 57: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Exercise

DownloadTest Program

DownloadTest Program

Page 58: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Processing

Flood Fill

Page 59: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Flood Fill

Page 60: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Flood Fill Used to mark or isolate portions of an image

for further processing or analysis

Used to derive, from an input image, masks that can be used for subsequent routines to speed or restrict processing to only those pixels indicated by the mask.

Some routines support mask

Page 61: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Flood Fill

void cvFloodFill( IplImage* img, CvPoint seedPoint, CvScalar newVal, CvScalar loDiff = cvScalarAll(0), CvScalar upDiff = cvScalarAll(0), CvConnectedComp* comp = NULL, int flags = 4, CvArr* mask = NULL);

void cvFloodFill( IplImage* img, CvPoint seedPoint, CvScalar newVal, CvScalar loDiff = cvScalarAll(0), CvScalar upDiff = cvScalarAll(0), CvConnectedComp* comp = NULL, int flags = 4, CvArr* mask = NULL);

Page 62: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Flood Fill

DownloadTest Program

DownloadTest Program

Page 63: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Processing

Resize

Page 64: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Resize

void cvResize( const CvArr* src, CvArr* dst, int interpolation=CV_INTER_LINEAR);

void cvResize( const CvArr* src, CvArr* dst, int interpolation=CV_INTER_LINEAR);

Page 65: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Processing

Image Pyramids

Page 66: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Pyramids

Represent NN image as a “pyramid” of11, 22, 44, 2k2k images (assuming N = 2k)

Page 67: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Pyramids

Represent the image using a collection of

images

– Called a pyramid because the resolution of the images

decreases

Most common pyramid: Gaussian pyramid

– At each level, generate the next level by blurring the

image with a Gaussian, then downsampling

For reconstruction: Laplacian pyramid needed

Page 68: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Gaussian Pyramid

At each level,

generate the next

level by blurring the

image with a

Gaussian, then

downsampling

Page 69: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Problems on Gaussian Pyramid

It is redundant

Each level contains

all of the low-

frequencies that are

available at the

lower levels.

Page 70: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Laplacian Pyramid

Original Image

Reduce

Enlarge

=-

Shrunk and Enlarged Version

Original Image

Detail

Page 71: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

The Detail

The image represents everything in the high-resolution image that cannot be represented in a low-resolution image

Page 72: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Gaussian Pyramid &Lapacian Pyramid

Gaussian Pyramid Laplacian Pyramid

Page 73: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Compression

Page 74: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

PyrDown

void cvPyrDown(

const CvArr* src,

CvArr* dst,

int filter=CV_GAUSSIAN_5x5

);

void cvPyrDown(

const CvArr* src,

CvArr* dst,

int filter=CV_GAUSSIAN_5x5

);

The function performs the downsampling step of the Gaussian pyramid decomposition. First it convolves the source image with the specified filter and then downsamples the image by rejecting even rows and columns.

Page 75: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

PyrUp

void cvPyrUp(

const CvArr* src,

CvArr* dst,

int filter=CV_GAUSSIAN_5x5

);

void cvPyrUp(

const CvArr* src,

CvArr* dst,

int filter=CV_GAUSSIAN_5x5

);

The function cvPyrUp performs up-sampling step of Gaussian pyramid decomposition. First it upsamples the source image by injecting even zero rows and columns and then convolves result with the specified filter multiplied by 4 for interpolation. So the destination image is four times larger than the source image.

Page 76: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Segmentation

Page 77: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Segmentation

Page 78: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Pyramid Image Segmentation

void cvPyrSegmentation(

IplImage* src,

IplImage* dst,

CvMemStorage* storage,

CvSeq** comp,

int level,

double threshold1,

double threshold2

)

void cvPyrSegmentation(

IplImage* src,

IplImage* dst,

CvMemStorage* storage,

CvSeq** comp,

int level,

double threshold1,

double threshold2

)

Page 79: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Pyramid Image Segmentation

DownloadTest Program

DownloadTest Program

Page 80: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Image Processing

Threshold

Page 81: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Threshold

double cvThreshold(

CvArr* src,

CvArr* dst,

double threshold,

double max_value,

int threshold_type

);

double cvThreshold(

CvArr* src,

CvArr* dst,

double threshold,

double max_value,

int threshold_type

);

Page 82: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Threshold

double cvThreshold(

CvArr* src,

CvArr* dst,

double threshold,

double max_value,

int threshold_type

);

double cvThreshold(

CvArr* src,

CvArr* dst,

double threshold,

double max_value,

int threshold_type

); CV_THRESH_OTSU

Page 83: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Threshold

double cvThreshold(

CvArr* src,

CvArr* dst,

double threshold,

double max_value,

int threshold_type

);

double cvThreshold(

CvArr* src,

CvArr* dst,

double threshold,

double max_value,

int threshold_type

);

Page 84: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Threshold

CV_THRESHOLD_BINARY

threshold=100

CV_THRESHOLD_BINARY |CV_THRESHOLD_OTSU

Page 85: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Adaptive Threshold

void cvAdaptiveThreshold( CvArr* src, CvArr* dst, double max_val, int adaptive_method = CV_ADAPTIVE_THRESH_MEAN_C int threshold_type = CV_THRESH_BINARY, int block_size = 3, double param1 = 5);

void cvAdaptiveThreshold( CvArr* src, CvArr* dst, double max_val, int adaptive_method = CV_ADAPTIVE_THRESH_MEAN_C int threshold_type = CV_THRESH_BINARY, int block_size = 3, double param1 = 5);

Page 86: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Adaptive Threshold

CV_ADAPTIVE_THRESH_MEAN_C

CV_THRESHOLD_BINARY

threshold=5

Page 87: Image Processing 主講人:虞台文. Content Smoothing Image Morphology Some Applications of Image Morphology Flood Fill Resize Image Pyramids Threshold

Threshold & Adaptive Threshold

DownloadTest Program

DownloadTest Program