• 沒有找到結果。

Computer Vision Homework 9

N/A
N/A
Protected

Academic year: 2022

Share "Computer Vision Homework 9"

Copied!
8
0
0

加載中.... (立即查看全文)

全文

(1)

Computer Vision

Homework 9

General Edge Detection

December 14, 1998

R87526001

許為元 William W. Hsu

(2)

Programming tool:

This program was developed with Borland C++ Builder 3.0 on Windows 98.

This program has the following functions:

1. Dynamic histogram display and multi-image display.

2. Dynamic information (pixel, histogram) update status bar.

3. Binarizing or inverting an image.

4. Conducting histogram equalization.

5. Dynamic morphological operation kernel assignment.

6. Conducting general morphological operations: dilation, erosion, opening, closing and hit-and-miss.

7. Down-sampling the image into smaller sizes.

8. Calculate Yokoi connectivity number and conducts image thinning.

9. Display binary image in ASCII ‘*’ symbols or in Yokoi connectivity numbers.

10. Adding Gaussian noise and salt & pepper to the image.

11. Dynamic assignment of filtering kernel.

12. Conducts box filter and mean filter.

13. General edge detection operators: Roberts, Prewitt, Sobel, Frei and Chen, Kirsch, Robinson, and Nevatia-Babu.

14. Simple hand adjusting zero crossing operation.

The format of the data files used in this program ( *.raw format ) is as follows:

1. The first 4 bytes specify the image height.

2. The second 4 bytes specify the image width.

3. The following 512*512 bytes specifies the image data in gray level.

Code Fragment for Zero-Crossing

This function conducts zero crossing detection on the input intensity image.

The threshold value depends on the user, which controls it with another threshold assigning window. This function can be found under the ‘Tools’ submenu.

void __fastcall IMAGE::ZeroCrossing( IMAGE *dest ) { int a, b;

dest->sizex = sizex;

dest->sizey = sizey;

(3)

MainForm->ProgressBar1->Show();

MainForm->ProgressBar1->Max = sizey;

for( MainForm->ProgressBar1->Position = b = 0; b < sizey;

b++, MainForm->ProgressBar1->Position = b ) for( a = 0; a < sizex; a++ )

if( function_zero_crossing( a, b, Form8->TrackBar1->Position ) ) dest->data[b][a] = 255;

MainForm->ProgressBar1->Hide();

}

Code Fragment for Zero-Crossing Decision

This function is used by the zero-crossing function to determine that if its neighborhood pixels are in condition of a true zero crossing or not.

bool __fastcall IMAGE::function_zero_crossing( int x, int y, const int val ) { int u, v;

const int neighbor[8][2] = {

{ 1, 0 }, { 0, -1 }, { -1, 0 }, { 0, 1 }, { 1, 1 }, { 1, -1 }, { -1, -1 }, { -1, 1 } };

int c;

for( c = 0; c < 8; c++ ) {

u = x + neighbor[c][0];

v = y + neighbor[c][1];

if( u < 0 || v < 0 || u >= sizex || v >= sizey ) continue;

if( ( ( data[y][x] * data[v][u] ) < 0 ) &&

( abs( data[y][x] ) >= val ) && ( abs( data[v][u] ) >= val ) ) return true;

}

return false;

}

Code Fragment for Edge Dectection

The mask used by this function is decided by its caller, which is the option the user selects from the main menu.

void __fastcall IMAGE::EdgeDetecting( char *type, TObject *Sender ) { int a, b, c, dx, dy;

float val;

FILE *fp;

int max;

sprintf( buffer, "%s\\Filters\\%s.flt", cwd, type );

if( ( fp = fopen( buffer, "r+t" ) ) == NULL ) {

ShowMessage( AnsiString( "System Error: Filter " )

+ AnsiString( buffer ) + AnsiString( "doesn't exist!" ) );

return;

(4)

}

fscanf( fp, "%d", &zImages );

fscanf( fp, "%d %d", &dx, &dy );

max = 0;

for( a = 0; a < zImages; a++ ) {

Form7->BitBtn3Click( Sender );

for( b = 0; b < dx; b++ ) for ( c = 0; c < dy; c++ ) {

fscanf( fp, "%f", &val );

Form7->StringGrid1->Cells[c+23-dy/2][b+23-dx/2] = FloatToStr( val );

if( max < ( int ) val ) max = ( int ) val;

}

zTempImage[a] = new IMAGE;

CopyImage( zTempImage[a] );

zTempImage[a]->BoxFilter( &box_filter );

}

Form8->TrackBar1->Max = 5 * max * dx * dy;

Form8->TrackBar1->Frequency = Form8->TrackBar1->Max / 10;

Form8->TrackBar1->Position = 2 * max * dx * dy;

Form8->Edit1->Text = IntToStr( Form8->TrackBar1->Position );

fclose( fp );

Form8->ShowModal();

}

Original Image: Lena

This is the original image of Lena with histogram.

(5)

Roberts Operator

Threshold value = 12.

Prewitt’s Edge Detector

Threshold value = 24.

(6)

Sobel’s Edge Detector

Threshold value = 38.

Frei and Chen’s Gradient Operator

Threshold value = 30.

(7)

Kirsch’s Compass Operator

Threshold value = 135.

Robinson’s Compass Operator

Threshold value = .43

(8)

Nevatia-Babu’s 5x5 Operator

Threshold value = 12500.

參考文獻

相關文件

• Richard Szeliski, Image Alignment and Stitching: A Tutorial, Foundations and Trends in Computer Graphics and Computer Vision, 2(1):1-104, December 2006. Szeliski

Conducting binary morphological operations: dilation, erosion, opening, closing and hit-and-miss.. Dynamic gray morphological operation kernel assignment with color depth showing

The algorithm used is averaging algorithm, i.e., when shrinking a 512 by 512 image into a 64 by 64 image, which is 1/8 of the original size, we take 8 by 8 blocks and use the

Conducting binary morphological operations: dilation, erosion, opening, closing and hit-and-miss.. Dynamic gray morphological operation kernel assignment with color depth showing

另外一般來說要處理不等號較為困難, 所以當 要證明 one-to-one 時, 我們大都用 Definition 5.3.7 的

• It is a plus if you have background knowledge on computer vision, image processing and computer graphics.. • It is a plus if you have access to digital cameras

• To achieve small expected risk, that is good generalization performance ⇒ both the empirical risk and the ratio between VC dimension and the number of data points have to be small..

• Learn the mapping between input data and the corresponding points the low dimensional manifold using mixture of factor analyzers. • Learn a dynamical model based on the points on