# 边缘检测算法
一个简单的边缘检测算法
## 算法介绍
算法来自于以下公式:
![avatar](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMsAAAAtCAYAAAAA5p+sAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAAhdEVYdENyZWF0aW9uIFRpbWUAMjAyMTowNzozMSAyMTozOTowOBAFAdIAAAmWSURBVHhe7Z1/TFRXFscP+4c/Igqy4q9UWX9EV0XcQkVFy7ZVVxSpNmGjFNtqUhqjUf/QtNElsmVtjKg1bv/QSLJafyA//MWmplsLK7VUNiKoKCBiBaVRQUREUaO2s+979j53GN6bd2EGmLH3k5zcXyNv5s47955z7nmjj02DFAqFJb8RpUKhsEApi0IhiVIWhUISpSwKhSRKWRQKSZSyKBSSKGVRKCTx+fmXX9Q5i0IhgdpZFApJlLIoFJIoZVEoJFHK4kBDQ4OoKX4t3L17V9Sc02HKUlxURI8fPxYt76CpqYkSPvxQtBS/Fk588w0dO3pUtMxxGg1L3bVL1OQIDg6mKRERfPHExERatWoVxS9aJEY9n/v379PMGTPoTGGh6GkJ5qO0rIwCAgKob9++9Pz5c7p58yY9ePCAVqxYQePGjROvVLiDuro6ysrK4jn29/cnfz8/unX7NrfDQkMp4aOPxCtd42BaGvXs2ZPmv/OO6DFGamfJyMig1NRU0WrN8ePHebx79+7cLr98mcuBAwdy6S34+PiImjFhYWH0/nvv0SDtc+3bu5cqKipoUng4/Tk2VilKB/BTTQ1NmTyZJSszk9LT03nuF8XH03RtUXMX0k+pYGdxJnfq623aTcJSVl5u+JrKq1dt06ZNsxUWFnJb03hbTEyM7WFzc6vXerLca2zkz2k0Zi+LFy/m1504ccJwXIl7JScnh+c7Li7OcNxV2bdvn+3w4cOGY/ZiubNcuniRS5gdo0eP5rojw4cPp2HDhpFv797cvlxezpqPrc2bkFlhYKpdFHMyPiSES0XHclbzf0H4pElcuhvZncVSWYrPneMy7LXXuNTZ++WX7MTrlG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lihGXUzBMijZ2BHn1cs2YNzxFy3jBHkZGRNNvJ+dW78fH05ltviZY5HfLzrf/Mzqa37VYz5C3Bn5kbHd1iNVi/fj0NeeUV6RCpQtGVuH1nAfaKAvBQGH5oANqOw06ceOM8Blm8ZtnLCoWn0Sk/DM55OampHFZOSUnh5/p7+fpyisj7H3wgXqVQeDad/iv6COFd05zSrjwlVijaQ6cri0Lhraj/B1+hkKRDHHyF4mVEKYtCIYlSFoVCEqUsCoUURP8FHoMHOEcYXhsAAAAASUVORK5CYII=)
其中,*E'*表示边缘图像,*I*表示输入图像,*i,j*表示对应行列的像素。接下来,将其边缘图像重新映射至`[0, 255]`之间,再执行反色操作以获得最终的边缘图像*E*,如下所示:
![avatar](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVAAAABECAYAAADX2G3gAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAABI6SURBVHhe7Z2FjyTVE8f5nwh+HHa4u7u7B5fDncMSSHCXw+UIcBdcgi9+uB56uCf0L5/Hr5bqmmqZnp3e3el6ySe7Xe+1zZv+Tr160ktkkSJFihSpUQoBjRQpUqSGKQQ0UqRIkRqmENBIkSJFaphCQCNFihSpYQoBjRQpUqSGKQQ0UqRIkRqmJf75558sCIIg6J8Q0CDoIM8//3z2888/u3lBfUJAg6BjzJ8/P1tyySWzu+++280P6hMCGnSCL7/8Mnldf/zxh5s/UbzzzjuufRhceumlffHQQw+l/ebMmZME9N577+05ZtAfIaDByHPuuedms2bNyjbffPNsueWWyw4//PAkqLbcHnvska2//vop/4ILLsiOO+64bOutt05iY8tiI+/YY49N4nTEEUek4x9zzDE9ZYcF5+X8XAtosRQOO+ywbJVVVkn5/ICw37777ptsixYt6jlm0B8hoMFIgxDOnj17fPvJJ5/MNtpooyQon3zySa4sAipiJJx55pnZX3/9lSsHthxcf/31PeXaQM4vAmnBrvNXX3317Oyzz+4pF/RPCGgwsixevDgJx0033ZSzI6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