removed unwanted files + visualizer added

pull/11/head
Rahul 2023-07-22 14:35:24 +05:30
rodzic 1c41f56257
commit e9d687459d
16 zmienionych plików z 51 dodań i 1305 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
# linedraw
Convert images to vectorized line drawings for plotters.
![Alt text](./screenshots/1.png?raw=true "")
![Alt text](./docs/assets/1.png?raw=true "")
- Exports polyline-only svg file with optimized stroke order for plotters;
- Sketchy style powered by Perlin noise;
@ -9,44 +9,57 @@ Convert images to vectorized line drawings for plotters.
## Dependencies
Python 2 or 3, PIL/Pillow, numpy, OpenCV (Optional for better performance)
```shell
pip install -r requirements.txt
```
## Usage
Convert an image to line drawing and export .SVG format:
```shell
$ python linedraw.py -i input.jpg -o output.svg
python linedraw.py -i input.jpg -o output.svg
```
Command specs:
```
usage: linedraw.py [-h] [-i [INPUT_PATH]] [-o [OUTPUT_PATH]] [-b] [-nc] [-nh]
[--no_cv] [--hatch_size [HATCH_SIZE]]
[--contour_simplify [CONTOUR_SIMPLIFY]]
usage: linedraw.py [-h] [-i [INPUT_PATH]] [-o [OUTPUT_PATH]] [-r [RESOLUTION]] [-b] [-nc] [-nh] [--no-cv] [--hatch-size [HATCH_SIZE]] [--contour-simplify [CONTOUR_SIMPLIFY]] [-v]
[--save-settings]
Convert image to vectorized line drawing for plotters.
optional arguments:
options:
-h, --help show this help message and exit
-i [INPUT_PATH], --input [INPUT_PATH]
Input path
Input image path
-o [OUTPUT_PATH], --output [OUTPUT_PATH]
Output path.
-b, --show_bitmap Display bitmap preview.
-nc, --no_contour Don't draw contours.
-nh, --no_hatch Disable hatching.
--no_cv Don't use openCV.
--hatch_size [HATCH_SIZE]
Output image path
-r [RESOLUTION], --resolution [RESOLUTION]
Resolution of the output image
-b, --show-bitmap Display bitmap preview.
-nc, --no-contour Don't draw contours.
-nh, --no-hatch Disable hatching.
--no-cv Don't use openCV.
--hatch-size [HATCH_SIZE]
Patch size of hatches. eg. 8, 16, 32
--contour_simplify [CONTOUR_SIMPLIFY]
--contour-simplify [CONTOUR_SIMPLIFY]
Level of contour simplification. eg. 1, 2, 3
-v, --visualize Visualize the output using turtle
--save-settings To Save the settings to a json file
```
Python:
```python
import linedraw
linedraw.argument.resolution = 512 # set arguments
lines = linedraw.sketch("path/to/img.jpg") # return list of polylines, eg.
# [[(x,y),(x,y),(x,y)],[(x,y),(x,y),...],...]
linedraw.visualize(lines) # simulates plotter behavior
# draw the lines in order using turtle graphics.
# [[(x,y),(x,y),(x,y)],[(x,y),(x,y),...],...]
linedraw.visualize(lines) # simulates plotter behavior
# draw the lines in order using turtle graphics.
```
## Future Plans
1. Rasterised Output
2. GUI for the tool

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 1.4 MiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.4 MiB

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 463 KiB

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 526 KiB

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 112 KiB

Wyświetl plik

@ -0,0 +1 @@
from line_draw.helper import sketch

Wyświetl plik

@ -1,12 +1,12 @@
from PIL import Image, ImageOps, ImageDraw
import linedraw.perlin as perlin
import line_draw.perlin as perlin
from datetime import datetime
import os
from linedraw.filters import appmask, F_SobelX, F_SobelY
from linedraw.default import argument
from linedraw.util import distsum, is_image_file, extract_file_name_and_extension
from linedraw.strokesort import sortlines
from line_draw.filters import appmask, F_SobelX, F_SobelY
from line_draw.default import argument
from line_draw.util import distsum, is_image_file, extract_file_name_and_extension
from line_draw.strokesort import sortlines
def sketch(input_path, output_path:str):

Wyświetl plik

@ -1,6 +1,6 @@
from random import *
from PIL import Image, ImageDraw, ImageOps
from linedraw.util import *
from line_draw.util import *
def sortlines(lines):
@ -38,8 +38,8 @@ def visualize(lines):
turtle.mainloop()
if __name__=="__main__":
import linedraw
import line_draw
#linedraw.draw_hatch = False
lines = linedraw.sketch("Lenna")
lines = line_draw.sketch("Lenna")
#lines = sortlines(lines)
visualize(lines)

Wyświetl plik

@ -1,7 +1,8 @@
import argparse
from linedraw import sketch
from linedraw.default import argument
from line_draw import sketch
from line_draw.default import argument
from line_draw.strokesort import visualize
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Convert image to vectorized line drawing for plotters.')
@ -41,6 +42,10 @@ if __name__ == '__main__':
default=argument.contour_simplify, action='store', nargs='?', type=int,
help='Level of contour simplification. eg. 1, 2, 3')
parser.add_argument('-v', '--visualize', dest='visualize',
const=True, default=False, action='store_const',
help='Visualize the output using turtle')
parser.add_argument('--save-settings', dest='save_settings',
const=not argument.save_settings, default=argument.save_settings, action='store_const',
help='To Save the settings to a json file')
@ -57,4 +62,7 @@ if __name__ == '__main__':
argument.no_cv = args.no_cv
argument.resolution = args.resolution
argument.save_settings = args.save_settings
sketch(input_path, export_path)
lines = sketch(input_path, export_path)
if args.visualize:
if lines:
visualize(lines)

Wyświetl plik

@ -1 +0,0 @@
from linedraw.helper import sketch

Plik diff jest za duży Load Diff

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 163 KiB