简体   繁体   中英

How to Draw countours in this image

在此处输入图像描述

In the above image how i can draw the counters for that dark circle area or any idea which technique i should use.please help .

You can use PIL module to draw contours on an image, Load your image eg (img = Image.open("myImage.png")) Pass you image in ImageDraw

import math
from PIL import Image, ImageDraw
from PIL import ImagePath 
  
side = 8
xy = [
    ((math.cos(th) + 1) * 90,
     (math.sin(th) + 1) * 60)
    for th in [i * (2 * math.pi) / side for i in range(side)]
    ]  
  
image = ImagePath.Path(xy).getbbox()  
size = list(map(int, map(math.ceil, image[2:])))
  
img = Image.new("RGB", size, "# f9f9f9") 
img1 = ImageDraw.Draw(img)  
img1.polygon(xy, fill ="# eeeeff", outline ="blue") 
  
img.show()

Countours Foramt

[(x1,y1), (x2,y2) .... (x^n, y^n )]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM