2019-12-08 03:13:45 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"<h2><center>edge detection</center></h2>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2019-12-08 22:19:30 +00:00
|
|
|
"execution_count": 11,
|
2019-12-08 03:13:45 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2019-12-08 22:19:30 +00:00
|
|
|
"<matplotlib.image.AxesImage at 0x7fa72c19bf50>"
|
2019-12-08 03:13:45 +00:00
|
|
|
]
|
|
|
|
},
|
2019-12-08 22:19:30 +00:00
|
|
|
"execution_count": 11,
|
2019-12-08 03:13:45 +00:00
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW8AAAD8CAYAAAC4uSVNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOy9v8t125bn9RljzLWfc++tyixF2gYNBFMTDYwFwaDRSA0MBCvqQDARI6FTf2AkXNFAEE00kobGv0BaTfzRKI0gtjRio9Ba977PXnOMYfAdcz/vuXXOqbKqD30u9cxL1Tnnffdee6255hw/vuM7vtO6m8/xOT7H5/gcv13D/27fwOf4HJ/jc3yO///j03h/js/xOT7Hb+H4NN6f43N8js/xWzg+jffn+Byf43P8Fo5P4/05Psfn+By/hePTeH+Oz/E5Psdv4fjRjLeZ/VNm9j+Z2V83s3/tx/qdz/E5Psfn+LM47MfgeZtZAP8z8E8CfwP4q8A/393/49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HNuNl5yQJjetfDsyc7duGYRdzu1U8s0b6p9soWcXVWsNkpxNWYXjzGydzvdJRiTqcO5sb2p2l+tInjzNRmGc5nT9eRpN2XF1Ya7wiRHGUmXagXhmisr2YQC7Wc+MonvGz8a5t3dfxn4y3+8T5twvAgSp7zZtdmT20QUj0tRy2VBmGlhtqLtTEVXN1/oNqoGY5qFu1N7srZRftNtuDf7utmDqX7DG9uLsOa5EwK6btwNR1hsWVPVWiTKrtgk3sFdtyIvAJbSYLv0dKHfXy4IY1dNJuFQhtl
|
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"import cv2\n",
|
|
|
|
"import math\n",
|
|
|
|
"import numpy as np\n",
|
|
|
|
"from scipy.signal import convolve2d\n",
|
|
|
|
"from matplotlib import pyplot as plt\n",
|
|
|
|
"\n",
|
2019-12-08 22:19:30 +00:00
|
|
|
"img = cv2.imread('sheep.png')[:,:,::-1]\n",
|
|
|
|
"plt.imshow(img)"
|
2019-12-08 03:13:45 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"sobel filter"
|
|
|
|
]
|
|
|
|
},
|
2019-12-08 12:02:15 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2019-12-08 22:19:30 +00:00
|
|
|
"execution_count": 12,
|
2019-12-08 12:02:15 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2019-12-08 22:19:30 +00:00
|
|
|
"<matplotlib.image.AxesImage at 0x7fa72c18dc50>"
|
2019-12-08 12:02:15 +00:00
|
|
|
]
|
|
|
|
},
|
2019-12-08 22:19:30 +00:00
|
|
|
"execution_count": 12,
|
2019-12-08 12:02:15 +00:00
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
2019-12-08 22:19:30 +00:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAACTCAYAAAB1YlneAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOy9S6wmSXbf94uIzPwe91nVVf2abs4MyeEMObRpiRRF2JZEWbIhCJAFAbZgGTC0MMSF4Y0XhrXwQtDC0FbemZYNeCNbMgxZEiyIelGQLFgELYlDa0jNcHo40z3d1V1VXVX38b0yI+J4EXEiIm9V94xMttkibgDdde/9vsyMjMd5/M//nDAiwm27bbfttt22317N/lZ34Lbdttt2227bb367Fe637bbdttv227DdCvfbdttu2237bdhuhfttu2237bb9Nmy3wv223bbbdtt+G7Zb4X7bbtttu22/DdsnJtyNMX/IGPM1Y8w3jDF/+pN6zm27bbfttt2255v5JHjuxhgHfB34d4HvAL8I/AkR+ZXf9Ifdttt2227bbXuufVKW+08C3xCRb4rICPwvwB/9hJ51227bbbttt+1G+6SE+2eAd5rfv5P/dttu2227bbft/4fW/VY92BjzM8DPAJhh+PHhpZeRZcyfpe98N8So/d6LrjHm+d+13bz3R13/Ud//uOv+ZT672f+Pe9ZH3fv5a/UPUsbgRfe/+dnNv3/UO7yo7ze/37bvNtYf9/zv9fsverePe/53u7bvAis3cTku6F3kbr+hNwGAyPwlDWB48aTp3wWDYGbfu3mNfkfK55S/RGz5u22u0760fbj5HCnfSfeyCMYIIqa5XupbGdDLpbn+4/pXfjbp0yi1lzevc0ScieV7N9/lo8Zn/lm6s8x7Xu7TvnP9PvM+NfNdxiXfs+3DR/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
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"kx = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]) / 4\n",
|
|
|
|
"ky = np.array([[1, 2, 1], [0, 0, 0], [-1, -2, -1]]) / 4\n",
|
|
|
|
"\n",
|
2019-12-08 22:19:30 +00:00
|
|
|
"grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n",
|
2019-12-08 12:02:15 +00:00
|
|
|
"\n",
|
|
|
|
"blur = convolve2d(grey, np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]]) / 9)\n",
|
|
|
|
"\n",
|
|
|
|
"dx = convolve2d(blur, kx)\n",
|
|
|
|
"dy = convolve2d(blur, ky)\n",
|
|
|
|
"\n",
|
|
|
|
"x = np.concatenate((dx, dy), axis=1)\n",
|
|
|
|
"\n",
|
|
|
|
"plt.imshow(x)"
|
|
|
|
]
|
|
|
|
},
|
2019-12-08 03:13:45 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2019-12-08 22:19:30 +00:00
|
|
|
"execution_count": 19,
|
2019-12-08 03:13:45 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2019-12-08 22:19:30 +00:00
|
|
|
"<matplotlib.image.AxesImage at 0x7fa726fcdc50>"
|
2019-12-08 03:13:45 +00:00
|
|
|
]
|
|
|
|
},
|
2019-12-08 22:19:30 +00:00
|
|
|
"execution_count": 19,
|
2019-12-08 03:13:45 +00:00
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
2019-12-08 22:19:30 +00:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAACSCAYAAAC+Pop7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+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422NoT1xHcN8pKg+hXeM/olnirlF8doyNu1Zblp9c2SdOxHdSERHiei+4NipRHQHET3U/N/eHCci+gARHSKie4jo/D6Nj7FEK6nOI0Xrud0y63RddsSc7JEaWOJ6SfWLB4fcDhpJ4tpEpzEUmxxt1+AzSR1L5P4RAJdGx64FcCcz7wJwZ/MeAN4GYFfztxfADd2Y2Y620kVuN0xJnrmOWyrDSBG6ZQHWKiFtwq6NseqXel5Lv99d4YOgTta5M/MXAcQ/cH05gI82rz8K4NeD4x/jFf8F4BQi2tGVsRZKFjdL80wd67oci0OV6pdyEqldOSnpJ7QlfD0lp9OlLUM4CUl2C4+PZZfTD1PoK7Wa+xnM/Hjz+gkAZzSvzwTwaJDucHPsOIhoLxFtEdHWU8eerTQjTW5xUCP3YLRtipY959K1OZlofUySZSTHETuP+NqSmcXUdsjMfR+4JHmtcYdex1TawpSktdYLqrz6/oLi7zBg5n3MvIeZ95x+2ra2ZryA1MIjoH/cO7XApU2bU07U0tikhd5cvVL5aHp6aieOlF6qayjlTK0TzZXSwd/RmYIzBdLbqseg1rk/uZZbmv9Hm+NHAJwVpNvZHBsMbSeMdftZaieDJZ/SkVvakhnboJUbX5uqsyYHaLaGjbVLqasNc17Y1XbDzLE+zvFMpW3WOvfbAFzVvL4KwK3B8Xc1u2YuBPC9QL4ZhZL
|
2019-12-08 03:13:45 +00:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"kx = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]) / 4\n",
|
|
|
|
"ky = np.array([[1, 2, 1], [0, 0, 0], [-1, -2, -1]]) / 4\n",
|
|
|
|
"\n",
|
2019-12-08 22:19:30 +00:00
|
|
|
"grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n",
|
2019-12-08 03:13:45 +00:00
|
|
|
"\n",
|
|
|
|
"blur = convolve2d(grey, np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]]) / 9)\n",
|
|
|
|
"\n",
|
|
|
|
"dx_grey = convolve2d(grey, kx)\n",
|
|
|
|
"dy_grey = convolve2d(grey, ky)\n",
|
|
|
|
"\n",
|
|
|
|
"dx_blur = convolve2d(blur, kx)\n",
|
|
|
|
"dy_blur = convolve2d(blur, ky)\n",
|
|
|
|
"\n",
|
|
|
|
"dx = np.concatenate((dx_grey, dx_blur[1:-1, 1:-1]), axis=1)\n",
|
|
|
|
"dy = np.concatenate((dy_grey, dy_blur[1:-1, 1:-1]), axis=1)\n",
|
|
|
|
"\n",
|
2019-12-08 22:19:30 +00:00
|
|
|
"x = np.sqrt(dx**2 + dy**2) > 20\n",
|
|
|
|
"plt.imshow(x)"
|
2019-12-08 03:13:45 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "Python 3",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
"version": "3.7.4"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 4
|
|
|
|
}
|