Convert an 8 bit image to 12 bit

37 vues (au cours des 30 derniers jours)
Amir Cawich
Amir Cawich le 22 Août 2022
Commenté : Amir Cawich le 22 Août 2022
I am trying to convert an image from 8bit to 12 bit. I understand 8 bit can go from 0-256 while 12 can go from 0-4095 i believe. Basically i am using the bit value for analysis purpose so using a 12 bit image makes more sense for me. However I don't have a lot of experience with image processing. Can i simply multiply the 8 bit values by a fraction of 256 or something similar? If anyone has any experience doing this can provide some feedback. I have read about going from 12 bit to 8 bit but it is hard to find information on going the other way.

Réponse acceptée

Chunru
Chunru le 22 Août 2022
I = imread("peppers.png"); % 8-bit image
whos
Name Size Bytes Class Attributes I 384x512x3 589824 uint8 cmdout 1x33 66 char
I1 = double(I)/256; % 8->12bit
imwrite(I1, 'test.jpg', 'BitDepth', 12); % JPEG supports 12 bits
I2 = imread('test.jpg');
class(I2)
ans = 'uint16'
I2 = rescale(I2); % rescale
class(I2)
ans = 'double'
imshow(I2)
  1 commentaire
Amir Cawich
Amir Cawich le 22 Août 2022
Thank you so much. It works

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by