00001 #include "sadie.h"
00002
00003 static PIXEL maskv[][3][3] = { { { 1.0, 2.0, 1.0 }, { 0.0, 0.0, 0.0 }, {-1.0, -2.0, -1.0 } },
00004 { { 1.0, 1.0, 1.0 }, { 0.0, 0.0, 0.0 }, {-1.0, -1.0, -1.0 } },
00005 { { 1.0, 1.0, 1.0 }, {-1.0, -1.0, -1.0 }, { 0.0, 0.0, 0.0 } },
00006 { { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, -1.0 } },
00007 { { 0.0, 1.0, 0.0 }, { 0.0, -1.0, 0.0 }, { 0.0, 0.0, 0.0 } },
00008 { { 1.0, 1.0, 1.0 }, { 1.0, -2.0, 1.0 }, {-1.0, -1.0, -1.0 } } };
00009 static PIXEL maskh[][3][3] = { { {-1.0, 0.0, 1.0 }, {-2.0, 0.0, 2.0 }, {-1.0, 0.0, 1.0 } },
00010 { {-1.0, 0.0, 1.0 }, {-1.0, 0.0, 1.0 }, {-1.0, 0.0, 1.0 } },
00011 { { 0.0, -1.0, 1.0 }, { 0.0, -1.0, 1.0 }, { 0.0, -1.0, 1.0 } },
00012 { { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 1.0 }, { 0.0, -1.0, 0.0 } },
00013 { { 0.0, 0.0, 0.0 }, { 0.0, -1.0, 1.0 }, { 0.0, 0.0, 0.0 } },
00014 { {-1.0, 1.0, 1.0 }, {-1.0, -2.0, 1.0 }, {-1.0, 1.0, 1.0 } } };
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 void EDGE (
00034 IMAGE *in,
00035 short option,
00036
00037
00038
00039
00040
00041
00042 IMAGE **out1,
00043
00044 IMAGE **out2
00045
00046
00047 ) { char msg[SLEN];
00048
00049 if (TIMES) TIMING(T_EDGE);
00050 if (NAMES) {
00051 MESSAGE('I',"");
00052 MESSAGE('I',"EDGE");
00053 MESSAGE('I',"");
00054 sprintf(msg," Input image: %s",in->text);
00055 MESSAGE('I',msg);
00056 if (option == SOBEL) {
00057 MESSAGE('I'," SOBEL gradient operator");
00058 } else if (option == SOBEL2) {
00059 MESSAGE('I'," SOBEL2 gradient operator");
00060 } else if (option == SOBEL3) {
00061 MESSAGE('I'," SOBEL3 gradient operator");
00062 } else if (option == ROBERTS) {
00063 MESSAGE('I'," ROBERTS gradient operator");
00064 } else if (option == ROBERTS2) {
00065 MESSAGE('I'," ROBERTS2 gradient operator");
00066 } else if (option == PREWITT) {
00067 MESSAGE('I'," PREWITT gradient operator");
00068 }
00069 MESSAGE('I'," ...............");
00070 }
00071
00072
00073 if (!CHECKIMG(in)) {
00074 MESSAGE('E'," Can't identify image.");
00075 goto the_end;
00076 } else if (option != SOBEL && option != SOBEL2 && option != SOBEL3 && option != ROBERTS && option != ROBERTS2 && option != PREWITT) {
00077 MESSAGE('E'," Option must be one of SOBEL, SOBEL2, SOBEL3, ROBERTS, ROBERTS2, or PREWITT.");
00078 goto the_end;
00079 }
00080
00081
00082 GRADIENT(in,(PIXEL *)maskv[option],(PIXEL *)maskh[option],3,out1,out2);
00083
00084 the_end:
00085 if (TIMES) TIMING(T_EXIT);
00086 }