first of all, sorry for my bad english, im a spanish speaker so Im gonna try my best to explain my problem.
I have a normalized ([0-255]) dicom image, and I want to display 8 images, but changing the bit depth, I mean like: 1bit image, 2bit image, 3bit image, etc. my code is just to open and normalize the image, because I have no clue on what should I do to get what I want, maybe transform all pixel values to binary but I don't really know that much, Im starting to learn digital image processing. this is my code
import numpy as np
import matplotlib.pyplot as plt
import pydicom as dicom
IM = r"C:\Users\Nico\Desktop\tarea2\MR-cerebro-ANON\IM.dcm"
data = dicom.read_file(IM)
imagen = data.pixel_array[200]
img_norm = []
for pixel in imagen:
img_norm.append((pixel/np.amax(imagen)*255))
plt.imshow(img_norm,cmap='bone'),plt.axis('off')
plt.title('Imagen normalizada')
plt.show()
UPDATE:
I finally get what I was looking for, so Im gonna put my code here in case anyone wants to improve it because I know it might not be so optimized, but I'm a starter so this is what I did, if anyone wants to optimize it, feel free to do it. Also, maybe with this result my question is clearer now, and It works with all 8-bits just modifing the int function on the second "for".Those are some images that I get normalized Image, 1 bit image,6 bits image
bin1 = []
bin11 = []
for i in c:
for j in i:
bin1.append('00000000'+bin(j)[2::])
for b in bin1:
bin11.append(int(b[-1:],2))
plt.imshow(np.reshape(bin22,(480,480)),cmap='gray')
plt.title('Imagen de 1 bits')
plt.show()