将图像中圆环区域展开成矩形长条的方法Python实现

本文介绍了一种使用Python将图像中圆环区域转换为矩形长条的方法,涉及图像处理和数学变换的知识,适合图像处理初学者参考。
摘要由CSDN通过智能技术生成
def get_huan_by_circle(img,circle_center,radius,radius_width):
    black_img = np.zeros((radius_width,int(2*radius*math.pi),3),dtype='uint8')
    for row in range(0,black_img.shape[0]):
        for col in range(0,black_img.shape[1]):
            theta = math.pi*2/black_img.shape[1]*(col+1)
            rho = radius-row-1
            p_x = int(circle_center[0] + rho*math.cos(theta)+0.5)
            p_y = int(circle_center[1] - rho*math.sin(theta)+0.5)
            
            black_img[row,col,:] = img[p_y,p_x,:]
            
    IM.fromarray(black_img).show()
    return black_img

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

南七小僧

打赏后,可以添加微信一对一咨询

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值