-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: deps upgrade * chore: deps upgrade * fix: mypy complains about types * chore: adds `make fmt` To run black on all python files. * test: updates to images After make test * feat: bump version to 0.3.0 * ci: Drop python 3.8
- Loading branch information
Showing
11 changed files
with
877 additions
and
868 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
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.
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 |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
__email__ = "[email protected]" | ||
|
||
from pathlib import Path | ||
import typing as T | ||
import cv2 as cv | ||
import numpy as np | ||
import numpy.typing as npt | ||
|
||
import tempfile | ||
|
||
|
@@ -31,18 +33,21 @@ def heal(orig): | |
|
||
|
||
def remove_grid( | ||
orig, num_iter=3, background_color: int = 255, grid_size: int = 2 | ||
orig: npt.ArrayLike, | ||
num_iter: int = 3, | ||
background_color: T.Sequence[int] = (255, 255, 255), | ||
grid_size: int = 2, | ||
) -> np.ndarray: | ||
img = orig.copy() | ||
img = np.array(orig, copy=True) | ||
thres = cv.threshold(img, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU)[1] | ||
# Remove horizontal lines | ||
horizontal_kernel = cv.getStructuringElement(cv.MORPH_RECT, (40, 1)) | ||
remove_horizontal = cv.morphologyEx( | ||
thres, cv.MORPH_OPEN, horizontal_kernel, iterations=num_iter | ||
) | ||
cnts = cv.findContours(remove_horizontal, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE) | ||
cnts = cnts[0] if len(cnts) == 2 else cnts[1] | ||
for c in cnts: | ||
contours = cnts[0] if len(cnts) == 2 else cnts[1] | ||
for c in contours: | ||
cv.drawContours(img, [c], -1, background_color, grid_size) | ||
|
||
# Remove vertical lines | ||
|
@@ -51,8 +56,8 @@ def remove_grid( | |
thres, cv.MORPH_OPEN, vertical_kernel, iterations=num_iter | ||
) | ||
cnts = cv.findContours(remove_vertical, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE) | ||
cnts = cnts[0] if len(cnts) == 2 else cnts[1] | ||
for c in cnts: | ||
contours = cnts[0] if len(cnts) == 2 else cnts[1] | ||
for c in contours: | ||
cv.drawContours(img, [c], -1, background_color, grid_size) | ||
return img | ||
|
||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "plotdigitizer" | ||
version = "0.2.3" | ||
version = "0.3.0" | ||
description = "Extract raw data from plots images" | ||
authors = ["Dilawar Singh <[email protected]>"] | ||
maintainers = ["Dilawar Singh <[email protected]>"] | ||
|
@@ -9,22 +9,22 @@ repository = "https://github.com/dilawar/PlotDigitizer" | |
license = "LGPL-3.0-or-later" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
opencv-python = "^4.5.1" | ||
numpy = "^1.23" | ||
matplotlib = "^3.3.4" | ||
python = ">=3.9,<=4" | ||
opencv-python = "^4.10" | ||
numpy = "^2.0.0" | ||
matplotlib = "^3.9.1" | ||
|
||
[tool.poetry.dev-dependencies] | ||
pytest = "^6.2.2" | ||
matplotlib = "^3.4.2" | ||
pytest = "^8.2.2" | ||
matplotlib = "^3.9.1" | ||
|
||
[tool.poetry.scripts] | ||
plotdigitizer = 'plotdigitizer.plotdigitizer:main' | ||
plotdigitizer-locate = 'plotdigitizer.locate:main' | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
mypy = "^0.982" | ||
pylint = "^2.15.5" | ||
mypy = "^1.10" | ||
pylint = "^3.2.5" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
|