【发布时间】:2021-10-28 22:35:51
【问题描述】:
我正在研究问题所在的加密:
对于图像的每个像素,将像素十进制值转换为二进制 8 位。然后将每个 8 位像素的 MSB 和 LSB 分开,并转换成十进制。
我已将图像转换为每个像素的 8 位二进制文件。现在我不知道如何分离 MSB 和 LSB。
这是我的代码:
#taking input image
input = cv2.imread('test.webp')
#print("before\n\n")
cv2.imshow('image before',input)
#Get input size converting to a fixed size
height, width = input.shape\[:2\]
#Desired "pixelated" size
w, h = (256, 256)
#Resize input to "pixelated" size
temp = cv2.resize(input, (w, h), interpolation=cv2.INTER_LINEAR)
print(temp)
#Initialize output image
#the converted pixed into 8bit image
output = cv2.resize(temp, (width, height), interpolation=cv2.INTER_NEAREST)
cv2.imwrite("pixelate.jpg", output)
#print(output)
#output
print('after\n\n')
cv2.imshow('image after',output)
cv2.waitKey(0)
cv2.destroyAllWindows()][1]
【问题讨论】:
标签: python-3.x opencv image-processing binary 8-bit