Team Gryffindor: Difference between revisions

From Cpre584
Jump to navigation Jump to search
No edit summary
No edit summary
 
(15 intermediate revisions by 3 users not shown)
Line 9: Line 9:
}}
}}


=== Assignment #2 ===
== Subversion ==
[http://homepages.inf.ed.ac.uk/rbf/HIPR2/sobel.htm Description of Sobel's Algorithm] - This is a great website teachs us how it works, and it also provide some examples, which help us to implement in C code.
You can checkout the source for our projects using the subversion repository below.  Use your ISU NetID as both your username and password:
svn co http://svn.chaddington.com/cpre584


Compiler:
== Updating the UserApp for Sobel ==
 
[[Team Gryffindor - Sobel Source Code]]
gcc -O -lm sobel.c -o sobel
 
./sobel
 
Sobel edge detection algorithm code with C (''Since the code is very long, I just show key part of algorithm''):
 
  int sobel(double threshold) {
  unsigned int  x, y, i, v, u;            // for loop counter
  unsigned char R, G, B;        // color of R, G, B
  double val[MASK_N] = {0.0};
  int adjustX, adjustY, xBound, yBound;
  double total;
  for(y = 0; y != height; ++y) {
    for(x = 0; x != width; ++x) {
      for(i = 0; i != MASK_N; ++i) {
        adjustX = (MASK_X % 2) ? 1 : 0;
                adjustY = (MASK_Y % 2) ? 1 : 0;
                xBound = MASK_X / 2;
                yBound = MASK_Y / 2;
           
        val[i] = 0.0;
        for(v = -yBound; v != yBound + adjustY; ++v) {
                    for (u = -xBound; u != xBound + adjustX; ++u) {
            if (x + u >= 0 && x + u < width && y + v >= 0 && y + v < height) {
              R = *(image_s + byte_per_pixel * (width * (y+v) + (x+u)) + 2);
              G = *(image_s + byte_per_pixel * (width * (y+v) + (x+u)) + 1);
              B = *(image_s + byte_per_pixel * (width * (y+v) + (x+u)) + 0);
             
                  val[i] +=    color_to_int(R, G, B) * mask[i][u + xBound][v + yBound];
            }
                    }
        }
      }
      total = 0.0;
      for (i = 0; i != MASK_N; ++i) {
              total += val[i] * val[i];
      }
          total = sqrt(total);
         
      if (total - threshold >= 0) {
        // black
        *(image_t + byte_per_pixel * (width * y + x) + 2) = BLACK;
        *(image_t + byte_per_pixel * (width * y + x) + 1) = BLACK;
        *(image_t + byte_per_pixel * (width * y + x) + 0) = BLACK;
      }
            else {
              // white
        *(image_t + byte_per_pixel * (width * y + x) + 2) = WHITE;
        *(image_t + byte_per_pixel * (width * y + x) + 1) = WHITE;
        *(image_t + byte_per_pixel * (width * y + x) + 0) = WHITE;
      }
    }
  }
 
  return 0;
}
 
We use color lena with 24bit bmp file
[[Image:lena.jpg|200px|thumb|left|alt text]]
 
[[Image:Lena_sobel.jpg|200px|thumb|left|alt text]]
 
== Profiling Sobel edge detection algorithm  ==
 
This command will generate a test file:
gcc -lm -pg sobel.c
./a.out
gprof a.out > test
 
test file:
 
%      cumulative  self            self    total         
   
'''80.80'''      0.15    0.15        1  145.44  175.53  sobel
16.72      0.18    0.03  4706312    0.00    0.00  color_to_int
0.00      0.18    0.00        1    0.00    0.00  read_bmp
0.00      0.18    0.00        1    0.00    0.00  write_bmp

Latest revision as of 17:45, 27 February 2012

Team Gryffindor
Error creating thumbnail: File missing
Gryffindor Team Logo
Team Members
Chad Nelson - cnel711
Mihir Awatramani - mihir
Mengduo Ma - marinama
Kuan-Hsing Ho - pm429015

Subversion

You can checkout the source for our projects using the subversion repository below. Use your ISU NetID as both your username and password:

svn co http://svn.chaddington.com/cpre584

Updating the UserApp for Sobel

Team Gryffindor - Sobel Source Code