ฉันไม่แน่ใจว่าอยู่ที่ไหน"เบองมี"มันมาจากทาง canny ขอบผมก็อาจจะสนใจอาชีพสืบส.
อย่างไรก็ตามที่แบบวงกลมข้อความห่อสามารถทำได้มากแค่ภาษาไพธอน/ตรวจค้นที่ใช้ ImageMagick. หรือหนึ่งสามารถทำอย่างนั้นภาษาไพธอน/OpenCV ใช้ cv2.remap และกำหนดการเปลี่ยแปลงครั้งแผนที่อยู่
นำเข้าข้อมูล:
1. ปลั๊กอินสำหรับไพธอนตรวจค้น
(พิมพ์ออกขนาดของตัดสินใจโดยอัตโนมัติจากข้อมูลขนาด)
from wand.image import Image
from wand.font import Font
from wand.display import display
with Image(filename='some_text.png') as img:
img.background_color = 'white'
img.virtual_pixel = 'white'
# 360 degree arc, rotated 0 degrees
img.distort('arc', (360,0))
img.save(filename='some_text_arc.png')
img.format = 'png'
display(img)
ผลลัพธ์:
2. ปลั๊กอินสำหรับไพธอน/OpenCV
import numpy as np
import cv2
import math
# read input
img = cv2.imread("some_text.png")
hin, win = img.shape[:2]
win2 = win / 2
# specify desired square output dimensions and center
hout = 100
wout = 100
xcent = wout / 2
ycent = hout / 2
hwout = max(hout,wout)
hwout2 = hwout / 2
# set up the x and y maps as float32
map_x = np.zeros((hout, wout), np.float32)
map_y = np.zeros((hout, wout), np.float32)
# create map with the arc distortion formula --- angle and radius
for y in range(hout):
Y = (y - ycent)
for x in range(wout):
X = (x - xcent)
XX = (math.atan2(Y,X)+math.pi/2)/(2*math.pi)
XX = XX - int(XX+0.5)
XX = XX * win + win2
map_x[y, x] = XX
map_y[y, x] = hwout2 - math.hypot(X,Y)
# do the remap this is where the magic happens
result = cv2.remap(img, map_x, map_y, cv2.INTER_CUBIC, borderMode = cv2.BORDER_CONSTANT, borderValue=(255,255,255))
# save results
cv2.imwrite("some_text_arc.jpg", result)
# display images
cv2.imshow('img', img)
cv2.imshow('result', result)
cv2.waitKey(0)
cv2.destroyAllWindows()
ผลลัพธ์:
wand
เป็นภาษาไพธอน wrapper อยู่ ImageMagick docs.wand-py.org/en/0.6.7