Skip to content
Snippets Groups Projects
Commit 451d79c3 authored by Marc Feger's avatar Marc Feger
Browse files

Add first version

parents
Branches
No related tags found
No related merge requests found
images/edit.jpeg

12.7 KiB

images/plain.jpeg

15 KiB

images/saturn.jpeg

6.68 KiB

images/white-plane-sky.jpeg

24.2 KiB

mask.py 0 → 100644
from filter import *
class Mask(object):
def __init__(self):
self.H = {
FILTER.gaussian.value: self._gaussian(),
FILTER.laplacian.value: self._laplacian(),
FILTER.mod_laplacian.value: self._modified_laplacian(),
FILTER.box.value: self._box()
}
@staticmethod
def _gaussian():
return [[0, 1, 2, 1, 0],
[1, 3, 5, 3, 1],
[2, 5, 9, 5, 2],
[1, 3, 5, 3, 1],
[0, 1, 2, 1, 0]]
@staticmethod
def _laplacian():
return [[0, 0, -1, 0, 0],
[0, -1, -2, -1, 0],
[-1, -2, 10, -2, -1],
[0, -1, -2, -1, 0],
[0, 0, -1, 0, 0]]
@staticmethod
def _modified_laplacian():
return [[0, 0, -1, 0, 0],
[0, -1, -200, -1, 0],
[-1, -200, 1000, -200, -1],
[0, -1, -200, -1, 0],
[0, 0, -1, 0, 0]]
@staticmethod
def _box():
return [[0, 0, 0, 0, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 0, 0, 0, 0]]
pixel.py 0 → 100644
from filter import *
class Pixel(object):
def __init__(self, image, v, u):
self.image = image
self.v = v
self.u = u
def filter_with(self, option: str):
if option == FILTER.empty.value:
return self.image[self.v, self.u]
elif option == FILTER.laplacian.value:
return Filter(self.image, self.v, self.u).use(FILTER.laplacian.value)
elif option == FILTER.mod_laplacian.value:
return Filter(self.image, self.v, self.u).use(FILTER.mod_laplacian.value)
elif option == FILTER.gaussian.value:
return Filter(self.image, self.v, self.u).use(FILTER.gaussian.value)
elif option == FILTER.box.value:
return Filter(self.image, self.v, self.u).use(FILTER.box.value)
elif option == FILTER.median.value:
return Filter(self.image, self.v, self.u).use(FILTER.median.value, linear=False, dim=(5, 5))
elif option == FILTER.min.value:
return Filter(self.image, self.v, self.u).use(FILTER.min.value, linear=False, dim=(5, 5))
elif option == FILTER.max.value:
return Filter(self.image, self.v, self.u).use(FILTER.max.value, linear=False, dim=(5, 5))
Pillow==6.0.0
scikit-image==0.15.0
numpy == 1.16.2
\ No newline at end of file
import os
import sys
from skimage import io
if __name__ == '__main__':
print('Both pictures must have the same size!')
im1 = io.imread(fname=sys.argv[1])
im2 = io.imread(fname=sys.argv[2])
im3 = io.imread(fname=sys.argv[1])
height, width, _ = im1.shape
print('Start...')
for v in range(height):
for u in range(width):
im3[v, u] = im1[v, u] - im2[v, u]
print('Done...')
io.imsave(fname=sys.argv[3], arr=im3)
import os
import sys
from skimage import io
if __name__ == '__main__':
print('Both pictures must have the same size!')
im1 = io.imread(fname=sys.argv[1])
im2 = io.imread(fname=sys.argv[1])
height, width, _ = im1.shape
print('Start...')
for v in range(height):
for u in range(width):
grey_value = sum(im1[v, u]) / 3
im2[v, u] = [grey_value, grey_value, grey_value]
print('Done...')
io.imsave(fname=sys.argv[2], arr=im2)
import os
import sys
from skimage import io
if __name__ == '__main__':
print('Both pictures must have the same size!')
im1 = io.imread(fname=sys.argv[1])
im2 = io.imread(fname=sys.argv[1])
threshold = int(sys.argv[2])
height, width, _ = im1.shape
print('Start...')
for v in range(height):
for u in range(width):
pix = im1[v, u]
if pix[0] <= threshold and pix[1] <= threshold and pix[2] <= threshold:
im2[v, u] = [255, 255, 255]
else:
im2[v, u] = [0, 0, 0]
print('Done...')
io.imsave(fname=sys.argv[3], arr=im2)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment