Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
svaksha committed Sep 24, 2013
1 parent 1519c13 commit 0893fb8
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 14 deletions.
5 changes: 5 additions & 0 deletions AUTHORS.rst
@@ -0,0 +1,5 @@
AUTHORS
---------
Copyright © 2013 SVAKSHA, https://github.com/svaksha . AllRightsReserved.
~~~~~~~~~~~~~~~~~~~~~~~~~

3 changes: 3 additions & 0 deletions chAya/__init__.py
@@ -0,0 +1,3 @@
__version__ = "13.8.dev"

import diagonalGrid
70 changes: 70 additions & 0 deletions chAya/diagonalGrid.py
@@ -0,0 +1,70 @@
#!/usr/bin/env python3.3
###############################################################################
# Copyright © 2012-Now, SVAKSHA (https://github.com/svaksha) AllRightsReserved.
# License: AGPLv3 License <http://www.gnu.org/licenses/agpl.html>
# All copies must retain this permission notice with the copyright notice.
###############################################################################

import numpy
import numpy as np
from numpy import array, newaxis
from PIL import Image
import glob, sys
import os, os.path


def imageBuddha(image_path):
pix = Image.open(image_path)
pix.show()
img = pix.convert('L')
imcropd = img.crop([0,0,5,5])
imcropd.size
return img


def convFloat(imgcropd):
# 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(imgcropd, dtype=float)
df = bmap/256 # converts my image to floating types between 0 to 1
print (df)
return df


def diagonalMatrix(df, dist=5):
"""
The distance can be increased or decreased for finer or coarser edge
detection.
"""
topLeftbotRight = abs(np.subtract(df[0:-dist,0:-dist] , df[dist:,dist:]))
print ("topLeftbotRight", topLeftbotRight)
botLefttopRight = abs(np.subtract(df[0:-dist,dist:] , df[dist:,0:-dist]))
print ("botLefttopRight", botLefttopRight)
diaDD = topLeftbotRight + botLefttopRight
return diaDD


if __name__ == '__main__':
# build paths to import modules via pathya.py
full_path = os.path.realpath(__file__)
dir_path, prog_file = os.path.split(full_path)
parent_root = os.path.abspath(os.path.join(dir_path, os.pardir))
label_daemon = 'daemon'
pathya_path = os.path.join(parent_root, label_daemon)
sys.path.append(pathya_path)
import pathya

for count in range(3):
label_images = 'images'
images_path = os.path.join(parent_root, label_images)
image_path = pathya.imagePath(images_path, count)
img = imageBuddha(image_path)
df = convFloat(img)
diaMatriX = diagonalMatrix(df, 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()

108 changes: 108 additions & 0 deletions chAya/pxl_2connectGrid.py
@@ -0,0 +1,108 @@
#!/usr/bin/env python3.3
###############################################################################
# Copyright © 2012-Now, SVAKSHA (https://github.com/svaksha) AllRightsReserved.
# License: AGPLv3 License <http://www.gnu.org/licenses/agpl.html>
# All copies must retain this Copyright notice and this permission notice.
###############################################################################

import numpy
import numpy as np
from numpy import array, newaxis
import Image
import glob, sys
import os, os.path
import shutil as sh
import pathya
img_path = pathya.filePath()

def imageBuddha(image_path):
pix = Image.open(image_path)
pix.show()
img = pix.convert('L')
imcropd = img.crop([0,0,5,5])
imcropd.size
return img

def convFloat(imgcropd):
# 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(imgcropd, dtype=float)
df = bmap/256 # converts my image to floating types between 0 to 1
print (df)
return df

def diffRow():
newRow = np.array(imgcropd[:-1, :-1]) #last elem, lastElem
for row in range(len(newRow)):
for col in range(len(newRow)):
newRow[row][col] = imgcropd[row][col] - imgcropd[row+1][col]
continue
print ("printing newRow")
print (newRow)
# post computation output of a (n-1) X (n-1) matrix for each ROW
diffRow()
print (np.shape(diffRow))

def diffCol():
for row in range(len(a)):
for column in range(len(a[0])): #start from 0-th position
answer[row][column]=a[row][column]-a[row][column+1 ]

newCol = np.array(imgcropd[:-1, :-1]) #last elem, lastElem
for row in range(len(newCol)):
for col in range(len(newCol)):
newCol[row][col] = imgcropd[row][col] - imgcropd[row][col+1]
continue
print ("printing newCol")
print (newCol)
diffCol() #post computation output of a (n-1) X (n-1) matrix for each COLUMN
print (np.shape(diffRow[:,newaxis] + diffCol))


def gridRowCol(diffCol, diffRow):
"""
For a two-connected matrix, I'm adding the values of the two new arrays,
diffRow and diffCol to get a new grid, which will be the edge detected Picture.
"""
print "111"
#gridRC = np.concatenate([diffRow(), diffCol()])
#gridRC = np.add(diffCol(), diffRow())
#return gridRC
for row in newRow(): #return the number of items in a sequence.
#newRow = np.array(bmfloat[:-1, :-1])
for col in diffRow(): #
# newaxis index operator inserts a new axis into a,
# making it a two-dimensional 4x1 array.
gridRC = diffRow[:,newaxis] + diffCol[:,newaxis]
continue
print ("gridRC", gridRC)

gridRowCol(diffCol, diffRow)
for index in np.ndindex(3, 2, 1):
print (index)


if __name__ == '__main__':
# build paths to import modules via pathya.py
full_path = os.path.realpath(__file__)
dir_path, prog_file = os.path.split(full_path)
parent_root = os.path.abspath(os.path.join(dir_path, os.pardir))
label_daemon = 'daemon'
pathya_path = os.path.join(parent_root, label_daemon)
sys.path.append(pathya_path)
import pathya

for count in range(3):
label_images = 'images'
images_path = os.path.join(parent_root, label_images)
image_path = pathya.imagePath(images_path, count)
img = imageBuddha(image_path)
df = convFloat(img)
diaMatriX = diagonalMatrix(df, 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()

2 changes: 1 addition & 1 deletion ci/__init__.py
@@ -1,3 +1,3 @@
__version__ = "13.8.dev"

# from .diagonalEdge import *
# from .diagonalGrid import *
8 changes: 5 additions & 3 deletions daemon/pathya.py
Expand Up @@ -2,13 +2,13 @@
###############################################################################
# Copyright © 2012-Now, SVAKSHA (https://github.com/svaksha) AllRightsReserved.
# License: AGPLv3 License <http://www.gnu.org/licenses/agpl.html>
# All copies must retain this Copyright notice and this permission notice.
# All copies must retain this permission notice with the copyright notice.
###############################################################################

import glob, sys
import os, os.path

images_list = ['P1010214.png',
image_list = ['P1010214.png',
'P1010218.png',
'P1010221.png',
];
Expand All @@ -23,7 +23,9 @@ def dirPath():


def imagePath(dir_path, count):
image_dir = images_list[count]
image_dir = image_list[count]
image_filepath = os.path.join(dir_path, image_dir)
print (image_filepath)
return image_filepath


41 changes: 31 additions & 10 deletions setup.py
@@ -1,24 +1,44 @@
#!/usr/bin/env python3.3

from setuptools import setup, find_packages
import os
import os, sys
import shutil
import warnings

import chaya

def read():
with open('README.rst') as f:
return f.readfile()

setup(name = 'chaya',
version = chaya.__version__,
author = 'SVAKSHA',
PKGNAME = 'chaya',
VERSION=chaya.__version__,
AUTHOR = "SVAKSHA",
AUTHOR_EMAIL = "svaksha@gmail.com",
URL = 'https://github.com/svaksha/chaya',
DESCRIPTION ='Learning computer vision, edge detection',
LONG_DESCRIPTION=open('README.rst').read()
PACKAGES=['chaya'],
PACKAGE_DATA={'chaya': ['LICENSE.rst',
'AUTHORS.rst',
'MANIFEST.in',
'README.rst',
]}

setup(name=PKGNAME,
version=VERSION,
maintainer=AUTHOR,
author_email = 'svaksha@gmail.com',
url = 'https://github.com/svaksha/chaya',
description ='Learn computer vision, edge detection',
long_description = open('README.rst').read()
packages = ['chaya'],
package_data = {'chaya': ['LICENSE.rst',
'AUTHORS.rst',
'MANIFEST.in',
'README.rst',
]},
license = ('AGPL'),
packages=['chaya'],
package_data={'chaya': ['LICENSE.rst',
'AUTHORS.rst',
'MANIFEST.in',
'README.rst',
]},
include_package_data = True,
install_requires = ['Cython==0.19.1',
'Pillow==2.1.0',
Expand All @@ -31,6 +51,7 @@ def read():
'Topic :: Graphics :: Computer Vision',
],
packages = ['chaya',
'chaya.chAya',
'chaya.tests',
], #TODO
)
Expand Down

0 comments on commit 0893fb8

Please sign in to comment.