Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Edges detection of an image using Numpy, PIL, Math and Requests packages

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

One simple program using Python for detecting edges.
The following gist offers a program scaled in seven parts:

  1. Import Numpy and related packages
  2. Load image remotely and define scaling variables
  3. Create output image
  4. Convert image to grayscale
  5. Compute intensity convolution using a for loop
  6. Draw magnitude in black and white
  7. Print out input and output images

Getting Started

This Python program built in 21 lines helps you render edges from a given image. The below instructions will help you run this Python program on your local machine for development and testing purposes, as well as in third party sites hosted in the cloud.

  • (#) and (''') are used to comment the following gist.


I am using Jupyter Notebook on localhost (Ubuntu 18.04 bionic).
You can use Python IDEs and code editors on remote servers (see Tips).


If you are not using Linux/Unix and still want to try this simple Python program:

Basic commands in Jupyter

  • Note that in Jupyter you add new lines by typing "b" from your keyboard whilst the notebook is opened.
  • Avoid runing the entire code in a single cell in order to understand the steps.
  • Use "ctrl + enter" to execute each line if you want to get the output.
  • Use "dd" outside a cell to delete it.
  • Use "a" outside a cell to add a new cell above it.
  • Use "b" outside as cell to add a new cell below it.
  • Running the last cell should execute the permutations as program output.

Running the tests

  • I used Ubuntu (18.04 bionic) to launch Jupyter Notebook on localhost.
  • Localhost instantiates while using $ jupyter notebook in the terminal.
  • Check if Jupyter is correctly installed: $ jupyter --version

Built With

  • Jupyter - An open source software for creating notebooks
  • Numpy - The fundamental package for scientific computing with Python
  • Math - Mathematical functions defined by the C standar
  • PIL - Create images, annotate, retouch existing ones
  • Requests - A non-GMO HTTP library for Python, safe for human consumption


I used no vesioning system for this gist, which repos status is flagged as concept because it is intended to be a demo or POC (proof-of-concept).


  • Isaac Arnault - Suggesting a way to render edges for specific images such as: coins, architecture images.


Store the below image remotely (on your IDE / PC) and try to detect edges using Python.



One simple program using Python for detecting an image edges.







No releases published


No packages published