当前位置: 首页>>代码示例>>Python>>正文


Python Encoder.convertToGray方法代码示例

本文整理汇总了Python中Encoder.convertToGray方法的典型用法代码示例。如果您正苦于以下问题:Python Encoder.convertToGray方法的具体用法?Python Encoder.convertToGray怎么用?Python Encoder.convertToGray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Encoder的用法示例。


在下文中一共展示了Encoder.convertToGray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: replaceWithGrayCodeBinary

# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import convertToGray [as 别名]
def replaceWithGrayCodeBinary(matrix, numberOfBits):
	bitValues = BG.generateBitList(numberOfBits - 2);
	grayValues = []
	for bitValue in bitValues: 
		grayValues.append(BSH.charListToString(Encoder.convertToGray(bitValue)))

	for i in range(0,12):
		for j in range(0,12):
			if matrix[i][j] != None and matrix[i][j] != ' ':
				matrix[i][j] = grayValues[int(matrix[i][j])]
开发者ID:RossCasey,项目名称:Mod-Demod,代码行数:12,代码来源:QAM.py

示例2: createMod4GrayLookupTable

# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import convertToGray [as 别名]
def createMod4GrayLookupTable():
	table = LookupTable()
	values = BG.generateBitList(2)

	stringValues = []
	for value in values: 
		stringValues.append(BSH.charListToString(Encoder.convertToGray(value)))

	points = generatePointsMatrix(2)
	nextString = 0
	for i in range(0, 2):
		for j in range(0, 2):
			table.add(stringValues[nextString], points[i][j])
			nextString += 1

	return table
开发者ID:RossCasey,项目名称:Mod-Demod,代码行数:18,代码来源:QAM.py

示例3: createMod32LookupTable

# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import convertToGray [as 别名]
def createMod32LookupTable(encoding):
	table = LookupTable()

	points = generatePointsMatrix(6)
	baseBitStrings = generateBaseBitStringMatrixMod32()
	
	if encoding == LINEAR:
		linearList = BG.generateBitList(5)
		index = 0
		for i in range(0, 6):
			for j in range(0, 6):
				if baseBitStrings[i][j] != None:
					baseBitStrings[i][j] = BSH.charListToString(linearList[index])
					index += 1

	else:
		linearList = BG.generateBitList(3)
		grayList = []
		for value in linearList:
			grayList.append(BSH.charListToString(Encoder.convertToGray(value)))

		baseBitStrings[0][0] = None
		baseBitStrings[0][1] = grayList[4]
		baseBitStrings[0][2] = grayList[3]
		baseBitStrings[1][0] = grayList[5]
		baseBitStrings[1][1] = grayList[6]
		baseBitStrings[1][2] = grayList[7]
		baseBitStrings[2][0] = grayList[2]
		baseBitStrings[2][1] = grayList[1]
		baseBitStrings[2][2] = grayList[0]

		# With QAM levels that are an odd power of 2 it is no longer possible
		# to arrange the values such that no 2 differ by more than 1 bit. The 
		# above pattern is the best that can be done. It gives 8 adjacent pairs
		# that differ by more than 1 bit. This pattern is scaled up to be used 
		# in 128 and 512 QAM. 
		mirrorTopLeftQuadrant(baseBitStrings)

	for i in range(0, 6):
		for j in range(0, 6):
			if baseBitStrings[i][j] != None:
				table.add(baseBitStrings[i][j], points[i][j])	 

	return table
开发者ID:RossCasey,项目名称:Mod-Demod,代码行数:46,代码来源:QAM.py

示例4: generateSquareMatrix

# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import convertToGray [as 别名]
def generateSquareMatrix(numberOfBits, encoding):
	bitsPerSide = int(math.sqrt(2 ** numberOfBits))
	linearList = BG.generateBitList(int(math.log(bitsPerSide,2)))
	grayList = []
	listToUse = linearList
	if encoding == GRAY:
		for value in linearList:
			grayList.append(Encoder.convertToGray(value))
		listToUse = grayList	

	stringList = []
	for value in listToUse:
		stringList.append(BSH.charListToString(value))

	matrix = []
	for i in range(0,bitsPerSide):
		nextRow = []
		for j in range(0, bitsPerSide):
			newValue = stringList[i] + stringList[j]
			nextRow.append(newValue)
		matrix.append(nextRow)
	return matrix
开发者ID:RossCasey,项目名称:Mod-Demod,代码行数:24,代码来源:QAM.py

示例5: createMod8LookupTable

# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import convertToGray [as 别名]
def createMod8LookupTable(encoding):
	table = LookupTable()
	values = BG.generateBitList(3)

	stringValues = []
	for value in values: 
		if encoding == LINEAR:
			stringValues.append(BSH.charListToString(value))
		else:
			stringValues.append(BSH.charListToString(Encoder.convertToGray(value)))

	bitMatrix = []

	nextRow = []
	nextRow.append(stringValues[0])
	nextRow.append(stringValues[1])
	nextRow.append(stringValues[2])
	bitMatrix.append(nextRow)

	nextRow = []
	nextRow.insert(0, stringValues[3])
	nextRow.insert(0, None)
	nextRow.insert(0, stringValues[7])
	bitMatrix.append(nextRow)

	nextRow = []
	nextRow.append(stringValues[6])
	nextRow.append(stringValues[5])
	nextRow.append(stringValues[4])
	bitMatrix.append(nextRow)

	points = generatePointsMatrix(3)

	for i in range(0,3):
		for j in range(0,3):
			table.add(bitMatrix[i][j], points[i][j])
			
	return table
开发者ID:RossCasey,项目名称:Mod-Demod,代码行数:40,代码来源:QAM.py

示例6:

# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import convertToGray [as 别名]
import Encoder
import BitGenerator as BG
import BitStringHelper as BSH

index = 0
values = BG.generateBitList(5)
for i in values:
	print index, BSH.charListToString(Encoder.convertToGray(i))
	index += 1
开发者ID:RossCasey,项目名称:Mod-Demod,代码行数:11,代码来源:32.py

示例7: range

# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import convertToGray [as 别名]
for i in range(0, 6):
	for j in range(0, 6):
		if baseBitStrings[i][j] != None:
			baseBitStrings[i][j] = BSH.charListToString(linearList[index])
			index += 1

print "32 QAM Linear"
differByOneByOnly(baseBitStrings)
print "\n\n"


# 32 QAM Gray 
linearList = BG.generateBitList(3)
grayList = []
for value in linearList:
	grayList.append(BSH.charListToString(Encoder.convertToGray(value)))

baseBitStrings[0][0] = None
baseBitStrings[0][1] = grayList[4]
baseBitStrings[0][2] = grayList[3]
baseBitStrings[1][0] = grayList[5]
baseBitStrings[1][1] = grayList[6]
baseBitStrings[1][2] = grayList[7]
baseBitStrings[2][0] = grayList[2]
baseBitStrings[2][1] = grayList[1]
baseBitStrings[2][2] = grayList[0]

QAM.mirrorTopLeftQuadrant(baseBitStrings)

print "32 QAM Gray"
differByOneByOnly(baseBitStrings)
开发者ID:RossCasey,项目名称:Mod-Demod,代码行数:33,代码来源:test.py


注:本文中的Encoder.convertToGray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。