Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename variables #33

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ Initialize object
cnn = pycnn()

# object variables:
# m: width of the image (number of columns)
# n: height of image (number of rows)
# width: width of the image (number of columns)
# height: height of image (number of rows)
```

```python
Expand Down
18 changes: 9 additions & 9 deletions pycnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ class pycnn(object):


Attributes:
n (int): Height of the image.
m (int): Width of the image.
height (int): Height of the image.
width (int): Width of the image.
"""

def __init__(self):
"""Sets the initial class attributes m (width) and n (height)."""
self.m = 0 # width (number of columns)
self.n = 0 # height (number of rows)
"""Sets the initial class attributes width (width) and height (height)."""
self.width = 0 # width (number of columns)
self.height = 0 # height (number of rows)

def f(self, x, t, Ib, Bu, tempA):
"""Computes the derivative of x at t.
Expand All @@ -75,9 +75,9 @@ def f(self, x, t, Ib, Bu, tempA):
tempA (:obj:`list` of :obj:`list`of :obj:`float`): Feedback
template.
"""
x = x.reshape((self.n, self.m))
x = x.reshape((self.height, self.width))
dx = -x + Ib + Bu + sig.convolve2d(self.cnn(x), tempA, 'same')
return dx.reshape(self.m * self.n)
return dx.reshape(self.width * self.height)

def cnn(self, x):
"""Piece-wise linear sigmoid function.
Expand Down Expand Up @@ -129,15 +129,15 @@ def imageprocessing(self, inputlocation, outputlocation,
representing time points.
"""
gray = img.open(inputlocation).convert('RGB')
self.m, self.n = gray.size
self.width, self.height = gray.size
u = np.array(gray)
u = u[:, :, 0]
z0 = u * initialcondition
Bu = sig.convolve2d(u, tempB, 'same')
z0 = z0.flatten()
z = self.cnn(sint.odeint(
self.f, z0, t, args=(Ib, Bu, tempA), mxstep=1000))
l = z[z.shape[0] - 1, :].reshape((self.n, self.m))
l = z[z.shape[0] - 1, :].reshape((self.height, self.width))
l = l / (255.0)
l = np.uint8(np.round(l * 255))
# The direct vectorization was causing problems on Raspberry Pi.
Expand Down