How to create an image with 5 or 4 bits for each pixel

I have an image with which consists of 8 bits for each pixel, how I can create new picture that consists of 5 bits for each pixel using python and OpenCV?

You can’t, because the computer memory is organised in bytes, which consist of 8 bits.

However you can use only 5 bits of 8 (values 0-32 for each pixel) by dividing the image by 8.

why do you want to do this ?
(please dont answer: “my customer wants it”, that’s so silly)

are you aware of bgr565 formats ? (3 channels packed into 2 bytes)

I am learning digital image processing using OpenCV and Python, so I met this exercise online and I get stuck.

please present the entire exercise. link to it. present context.