Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

computing the diagonal matrix for 2-D edge detection.

  • Loading branch information...
commit 8e5a6f55999b03adc51cb9bf4b645a5fe19805d3 1 parent 45ebeae
@svaksha authored
Showing with 43 additions and 0 deletions.
  1. +43 −0 edgeDetection/diagonalEdge.py
View
43 edgeDetection/diagonalEdge.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+##*************************************************************************
+## COPYRIGHT © 2012-Now. VidAyer <svaksha|AT|gmail*com> All Rights Reserved.
+## LICENSE
+# AGPLv3 LICENSE <http://www.gnu.org/licenses/agpl.html>
+# See LICENSE.md file. The above Copyright notice and this permission notice
+# must be included in all copies or substantial portions of the Software.
+##*************************************************************************
+
+import numpy
+import numpy as np
+from numpy import array, newaxis
+import Image
+import glob, sys
+
+pix = Image.open("/home/m/Envs/jna/chaya/images/P1010218.JPG")
+pix.show()
+im = pix.convert('L')
+
+# converting the greyscale image into a floating type
+# shades of gray are coded as unsigned one-byte integer values with 0
+# corresponding to black and 255 corresponding to white.
+bmap = np.array(im, dtype=float)
+df = bmap / 256 # converts my image to floating types bet 0 to 1
+print df
+
+def diaM(dist=5):
+ """
+ The distance can be increased or decreased for finer or coarse edge detection.
+ """
+ tLbR = abs(np.subtract(df[0:-dist,0:-dist] , df[dist:,dist:]))
+ print "tlbr", tLbR
+ bLtR = abs(np.subtract(df[0:-dist,dist:] , df[dist:,0:-dist]))
+ print "bLtR", bLtR
+ diaDD = tLbR + bLtR
+ return diaDD
+diaMatriX = diaM(5)
+#diagonal computation output of a (n-1) X (n-1) matrix:
+print "Output of the diagonal MatriX", diaMatriX
+
+diaMatriX = Image.fromarray(diaMatriX*256)
+diaMatriX.show()
Please sign in to comment.
Something went wrong with that request. Please try again.