我正在寻找一种可以将直线转换为弧线的图像转换。我的最终目标是生成“ Devanagari脚本”的弯曲文本。
请客气,我已经在Google上搜索并搜索,却找不到任何内容。
答案 0 :(得分:0)
def transform_desire(image,curveIntensity):
'''
will convert image to arc form.
im1 : image.
curveIntensity : How much curved text you desired.
'''
im1 = image
ratio = 0.0001*curveIntensity
## calculate the desired width of the image.
height,width,channel = im1.shape
x = np.linspace(0,width,width).astype(int)
y = (ratio * ((x-(width/2))**2)).astype(int)
## corrosponding to an x every point will get shifted by y amount.
## time to shift.
## create canvas for new image.
adder = 0
if ratio >= 0:
adder = max(y)
else:
adder = (-1)*min(y)
retImage = (np.ones((height+adder,width, channel))*0).astype(np.uint8)
if ratio >= 0:
adder = 0
for xs in range(width):
ys = y[xs]
for t in range(height):
retImage[t+ys+adder,xs,:] = im1[t,xs,:]
return retImage
这对我有用。如果需要,请帮助自己。