I am working on encryption in which the problem says:
For each pixel of the image, convert the pixel decimal value into binary 8 bits. Then separate the MSB and LSB of each 8-bit pixel and convert that into decimal.
I have converted the image into an 8-bit binary for each pixel. Now I don't how to separate the MSB and LSB.
Here is my code:
#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]