python坐标轴拉伸_Numpy,Python中的“拉伸”直方图(级别)

更新时间:2023-05-21 17:03:40 阅读: 评论:0

python坐标轴拉伸_Numpy,Python中的“拉伸”直⽅图(级别)这是⼀种⽅法-
服务格言def stretch(a,lower_thresh,upper_thresh):
r = 255.0/(upper_thresh-lower_thresh+2) # unit of stretching
out = np.round(r*(a-lower_thresh+1)).astype(a.dtype) # stretched values
out[a
out[a>upper_thresh] = 255
return out
根据OP,设置的标准是:
>将246以上的每个像素“移动”到255,因此247及以上的像素应变为255.加速英文
> 186以下的每个像素都为零,因此185以下的像素应变为0.
凤凰神兽>因此,基于上述两个要求,186应该变为⼤于0的值,依此类推,直到246应该⼩于255.
施罗德
另外,我们也可以使⽤np.where使它更紧凑-
def stretch(a,upper_thresh):
抱团打天下r = 255.0/(upper_thresh-lower_thresh+2) # unit of stretching
out = np.round(r*np.where(a>=lower_thresh,a-lower_thresh+1,0)).clip(max=255)
溢价发行债券
return out.astype(a.dtype)
样品运⾏-
# check out first row input,output for variations
In [216]: a
陈嘉庚子女Out[216]:
array([[186,187,188,246,247],[251,195,103,9,211],[ 21,242,36,87,70]],dtype=uint8)
In [217]: stretch(a,lower_thresh=186,upper_thresh=246)
晕车穴位
Out[217]:
array([[ 4,8,12,251,255],[255,41,107],[ 0,234,0]],dtype=uint8)

本文发布于:2023-05-21 17:03:40,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/922202.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:应该   像素   溢价   拉伸   格言   设置   穴位
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图