Metadata-Version: 2.1
Name: segment-image
Version: 0.0.3
Summary: A package used to segment an image
Home-page: https://github.com/MyDuan/segment_image
Author: yu.duan
Author-email: dy1226130575@163.com
License: UNKNOWN
Project-URL: Bug Tracker, https://github.com/MyDuan/segment_image/issues
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

# segment_image

### Abstract

- A lib can be used to segment image https://pypi.org/project/segment-image/
- The first version just has k_means algorithm.

### install

- python >= 3.6
- install
```
$ pip install segment-image
```


### how to use 

- `cv2`need to be installed by
`
pip install opencv-python
`

- Kmeans
```
import segment_image
import cv2

img = cv2.imread("./sample_imgs/lena.png")
k = 2 # number of segments
k_means = segment_image.Kmeans(img, k)
iteration = 10
convergence_radius = 1e-6
k_means.run(iteration, convergence_radius)

```

- gvf_snake (The speed is so slow, so I use small `max_iteration_gvf` and `max_iteration_gvf`. if you want to get great results, pleas adjust them)
```
import segment_image
import cv2

img = cv2.imread("./sample_imgs/star.png")
max_iteration_gvf = 10
max_iteration_snake = 10
gvf_snake = segment_image.GVFSnake(img, max_iteration_gvf, max_iteration_snake)
gvf_snake.run(save=True)

```

### example

- https://github.com/MyDuan/segment_image/blob/main/examples/example_of_kmeans.py
- https://github.com/MyDuan/segment_image/blob/main/examples/example_of_gvf_snake.py
- results:
    - kmeans:

    ![kmeans_re](https://user-images.githubusercontent.com/19246998/113019886-04c81500-91bd-11eb-8075-016c64f5161b.png)

    - gvf_snake
    <img width="300" alt="star_re" src="https://user-images.githubusercontent.com/19246998/135444069-82e60a2d-7f99-4266-990e-5c4e99ccf76b.png">

    


