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