Alarm Clock

Selasa, 07 Juli 2009

Jawaban Tugas 6

// searching for vertical lines

short[,] vse = new short[3, 3] {
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 }
};
AForge.Imaging.Filters.HitAndMiss vFilter =
new AForge.Imaging.Filters.HitAndMiss( vse );
System.Drawing.Bitmap vImage = vFilter.Apply( image );
// searching for horizontal lines

short[,] hse = new short[3, 3] {
{ 0, 0, 0 },
{ 1, 1, 1 },
{ 0, 0, 0 }
};
AForge.Imaging.Filters.HitAndMiss hFilter =
new AForge.Imaging.Filters.HitAndMiss( hse );
System.Drawing.Bitmap hImage = hFilter.Apply( image );


source code 2
// create filter sequence
AForge.Imaging.Filters.FiltersSequence filterSequence =
new AForge.Imaging.Filters.FiltersSequence();
// add 8 thinning filters with different structuring elements
filterSequence.Add(new AForge.Imaging.Filters.HitAndMiss(
new short [,] {{0, 0, 0}, {-1, 1, -1}, {1, 1, 1}}, HitAndMissMode.Thinning ));
filterSequence.Add(new AForge.Imaging.Filters.HitAndMiss(
new short [,] {{-1, 0, 0}, {1, 1, 0}, {-1, 1, -1}}, HitAndMissMode.Thinning ));
filterSequence.Add(new AForge.Imaging.Filters.HitAndMiss(
new short [,] {{1, -1, 0}, {1, 1, 0}, {1, -1, 0}}, HitAndMissMode.Thinning ));
filterSequence.Add(new AForge.Imaging.Filters.HitAndMiss(
new short [,] {{-1, 1, -1}, {1, 1, 0}, {-1, 0, 0}}, HitAndMissMode.Thinning ));
filterSequence.Add(new AForge.Imaging.Filters.HitAndMiss(
new short [,] {{1, 1, 1}, {-1, 1, -1}, {0, 0, 0}}, HitAndMissMode.Thinning ));
filterSequence.Add(new AForge.Imaging.Filters.HitAndMiss(
new short [,] {{-1, 1, -1}, {0, 1, 1}, {0, 0, -1}}, HitAndMissMode.Thinning ));
filterSequence.Add(new AForge.Imaging.Filters.HitAndMiss(
new short [,] {{0, -1, 1}, {0, 1, 1}, {0, -1, 1}}, HitAndMissMode.Thinning ));
filterSequence.Add(new AForge.Imaging.Filters.HitAndMiss(
new short [,] {{0, 0, -1}, {0, 1, 1}, {-1, 1, -1}}, HitAndMissMode.Thinning ));
// create filter iterator for 10 iterations
AForge.Imaging.Filters.FilterIterator filter =
new AForge.Imaging.Filters.FilterIterator(filterSequence, 10);

Tidak ada komentar:

Posting Komentar