I am trying to create a median filter program under C++ with the use of a image procesing class library, calls picture.h, so I've written my code, but the compiler keep giving me a error message that I don't quite understand. Can somebody kindly explain to me what's going wrong with my program and suggest some useful resource that I possible can look up when I get stuck in this kind of situation. Thanks in advance.
Error message under the compiler:Code:#include "usage.h" #include "picture.h" int median(int& pel, const int **buf) { char array[9]; array[0]=buf[-1][-1]; array[1]=buf[-1][0]; array[2]=buf[-1][1]; array[3]=buf[0][-1]; array[4]=buf[0][0]; array[5]=buf[0][1]; array[6]=buf[1][-1]; array[7]=buf[1][0]; array[8]=buf[1][1]; for (int i=0; i<=9; i++) { for(int y=0; y<=8; y++) { if(array[y]>array[y+1]) { int temp = array[y+1]; array[y+1] = array[y]; array[y] = temp; } } pel = array[4]; return 0; } int main(int argc, char *argv[]) { usage("median inpic outpic"); picture_of_int in(argv[1]); picture_of_int out(in,median); out.write(argv[2]); return 1; }
median2.cpp: In function 'int median(int&, const int**)':
median2.cpp:30: error: a function-definition is not allowed here before '{' token
median2.cpp:36: error: expected `}' at end of input



LinkBack URL
About LinkBacks


