改变示波器TDS3054D图片颜色
2022-06-23 来源:eefocus
■ 问题由来
在 截取示波器网络图片 中给出了PYTHON程序来自动截取 Tektronix示波器的网络图片的方法。但是前两个通道的曲线中,第二个通道显示为青色,颜色不是很明显。如果能够通过颜色改变,增加该图片的对比度。
下图是前两个通道显示的图片。
01颜色调整方案
对组成图片的RGB进行如下的调整:
编程如下对比比较鲜艳的图片:
02图片处理程序
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# TEST1.PY -- by Dr. ZhuoQing 2020-08-06
#
# Note:
#============================================================
from headm import *
import matplotlib.image as mpimg
imageid = 5
imagefile = tspgetdopfile(imageid)
printf(imagefile)
imagergb = mpimg.imread(imagefile)
#printf(shape(imagergb))
#printf(type(imagergb))
#printf(imagergb.dtype)
#imagelist = imagergb.tolist()
#printf(shape(imagelist), type(imagelist))
imagelist = []
imagelist.append((imagergb[:,:,1]).tolist())
imagelist.append((imagergb[:,:,0]).tolist())
imagelist.append((imagergb[:,:,2]).tolist())
printf(shape(imagelist))
#------------------------------------------------------------
imageshape = shape(imagergb)
imagewidth = imageshape[1]
imageheight = imageshape[0]
#for h in range(imageheight):
# for w in range(imagewidth):
# r,g,b = imagergb[h,w,:]
# if r == 0xff and g == 0xff and b == 0xff:
# imagelist[h][w][:] = r,g,b
# continue
# if b == 0xff and g == 0xff and r < 0xff:
# g = r
# b = r
# r = 0xff
# elif g == 0xff and b < 0xff and r < 0xff:
# g = 0x80
# r = r // 2
# b = b // 2
# elif b == 0xff and r == 0xff and g < 0xff:
# b = 0x80
# r = 0x80
# g = g//2
# imagelist[h][w][:] = r, g, b
imagergb = array(imagelist)
imagergb = swapaxes(imagergb, 0, 2)
imagergb = swapaxes(imagergb, 0, 1)
plt.imshow(imagergb)
plt.show()
#------------------------------------------------------------
# END OF FILE : TEST1.PY
#============================================================