-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c617028
commit f2db4b4
Showing
26 changed files
with
473 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from frr.core import FastReflectionRemoval | ||
from frr.utils import FileWriter | ||
import matplotlib.pyplot as plt | ||
import argparse | ||
|
||
def main(args): | ||
frr = FastReflectionRemoval(h=args.h, debug_writer=FileWriter(path="logs") if args.debug else None) | ||
|
||
# read image and normalize it into [0, 1] | ||
img = plt.imread(args.input_path) / 255 | ||
|
||
# remove reflection | ||
result_img = frr.remove_reflection(img) | ||
|
||
# store image | ||
plt.imsave(args.output_path, result_img) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--input_path", default=None, type=str) | ||
parser.add_argument("--output_path", default=None, type=str) | ||
parser.add_argument("--debug", action="store_true", default=None) | ||
|
||
parser.add_argument("--h", default=0.03, type=float) | ||
args = parser.parse_args() | ||
|
||
main(args) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
PYTHON="venv/bin/python" | ||
|
||
install: | ||
@ ${PYTHON} -m pip install -r requirements.txt | ||
|
||
compile: | ||
@ ${PYTHON} -m piptools compile requirements.in | ||
|
||
sync: | ||
@ ${PYTHON} -m piptools sync requirements.txt | ||
@ ${PYTHON} -m pip install -e . | ||
|
||
clean_logs: | ||
@ rm -r logs && mkdir logs && touch logs/.keep |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
pylint==2.7.4 | ||
#pylint==2.7.4 | ||
autopep8==1.5.6 | ||
pytest==6.2.3 | ||
pytest==6.2.3 | ||
numpy==1.21.2 | ||
scipy==1.7.1 | ||
matplotlib==3.4.3 | ||
argparse==1.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,53 @@ | ||
# | ||
# This file is autogenerated by pip-compile | ||
# This file is autogenerated by pip-compile with python 3.8 | ||
# To update, run: | ||
# | ||
# pip-compile | ||
# pip-compile requirements.in | ||
# | ||
astroid==2.5.6 | ||
# via pylint | ||
argparse==1.4.0 | ||
# via -r requirements.in | ||
attrs==21.2.0 | ||
# via pytest | ||
autopep8==1.5.6 | ||
# via -r requirements.in | ||
cycler==0.10.0 | ||
# via matplotlib | ||
iniconfig==1.1.1 | ||
# via pytest | ||
isort==5.8.0 | ||
# via pylint | ||
lazy-object-proxy==1.6.0 | ||
# via astroid | ||
mccabe==0.6.1 | ||
# via pylint | ||
kiwisolver==1.3.2 | ||
# via matplotlib | ||
matplotlib==3.4.3 | ||
# via -r requirements.in | ||
numpy==1.21.2 | ||
# via | ||
# -r requirements.in | ||
# matplotlib | ||
# scipy | ||
packaging==20.9 | ||
# via pytest | ||
pillow==8.4.0 | ||
# via matplotlib | ||
pluggy==0.13.1 | ||
# via pytest | ||
py==1.10.0 | ||
# via pytest | ||
pycodestyle==2.7.0 | ||
pycodestyle==2.8.0 | ||
# via autopep8 | ||
pylint==2.7.4 | ||
# via -r requirements.in | ||
pyparsing==2.4.7 | ||
# via packaging | ||
# via | ||
# matplotlib | ||
# packaging | ||
pytest==6.2.3 | ||
# via -r requirements.in | ||
python-dateutil==2.8.2 | ||
# via matplotlib | ||
scipy==1.7.1 | ||
# via -r requirements.in | ||
six==1.16.0 | ||
# via | ||
# cycler | ||
# python-dateutil | ||
toml==0.10.2 | ||
# via | ||
# autopep8 | ||
# pylint | ||
# pytest | ||
wrapt==1.12.1 | ||
# via astroid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import numpy as np | ||
from typing import Tuple | ||
from scipy.fftpack import dct, idct | ||
|
||
def gradient(A: np.ndarray, append_zeros=False) -> Tuple[np.ndarray]: | ||
""" | ||
Computes gradients of input numpy array. Returns tuple, where the first | ||
part is gradient in direction of axis 0 (rows), then axis 1 (columns),... | ||
Args: | ||
f (np.ndarray): Input numpy array. | ||
Returns: | ||
Returns tuple of numpy arrays denoting gradients in different directions. | ||
""" | ||
|
||
rows, cols = A.shape | ||
|
||
grad_x = np.zeros_like(A) | ||
grad_x[:, 0: cols - 1] = np.diff(A, axis=1) | ||
|
||
grad_y = np.zeros_like(A) | ||
grad_y[0:rows - 1, :] = np.diff(A, axis=0) | ||
|
||
B = np.concatenate((grad_x[..., np.newaxis], grad_y[..., np.newaxis]), axis=-1) | ||
|
||
return B | ||
|
||
def divergence(A): | ||
m, n, _ = A.shape | ||
B = np.zeros(shape=(m, n)) | ||
|
||
T = A[:, :, 0] | ||
T1 = np.zeros(shape=(m, n)) | ||
T1[:, 1:n] = T[:, 0:n-1] | ||
|
||
B = B + T - T1 | ||
|
||
T = A[:, :, 1] | ||
T1 = np.zeros(shape=(m, n)) | ||
T1[1:m, :] = T[0:m-1, :] | ||
|
||
B = B + T - T1 | ||
return B | ||
|
||
|
||
def laplacian(f, h: float = None): | ||
rows, cols = f.shape | ||
dims = 2 | ||
|
||
grads = gradient(f) | ||
|
||
if h is not None: | ||
# remove edges (gradients) smaller than 0 | ||
# norm = np.sqrt(np.sum(grads * grads, axis=-1)) | ||
norm = np.linalg.norm(grads, axis=-1) | ||
|
||
mask = (norm < h)[..., np.newaxis].repeat(dims, axis=-1) | ||
grads[mask] = 0 | ||
|
||
# and compute its divergence by summing the second-order gradients | ||
laplacian = divergence(grads) | ||
|
||
return laplacian | ||
|
||
|
||
def dct2(block): | ||
return dct(dct(block.T, norm='ortho').T, norm='ortho') | ||
|
||
def idct2(block): | ||
return idct(idct(block.T, norm='ortho').T, norm='ortho') |
Oops, something went wrong.