I would like to purchase a BARCO monitor which is capable of displaying 10 (or 12) bits of grayscale. This means the monitor has 1024 (or 4096) levels of gray instead of the usual 256. This is useful for displaying medical images. Is MATLAB able to make use of the additional shades of gray? Could I use the "image" or "imagesc" functions or do I need to call a different function?
MATLAB: Does MATLAB support 10-bit or 12-bit monitors
MATLAB
Related Solutions
To convert a 16-bit monocromatic image (no colors, black and white) to 32-bit, the below procedure can be followed with gray scale image as reference. Here, Image.png is an RGB image.
Gray = imread('Image.png');Gray = rgb2gray(Gray);imwrite(Gray,'imagegrey.png');grey_info = imfinfo('imagegrey.png');Grey_BitDepth = grey_info.BitDepthimwrite(Gray,'imagegrey16.png','BitDepth', 16);grey16_info = imfinfo('imagegrey16.png');Grey16_BitDepth = grey16_info.BitDepth
In the above code, maximum valid bit depth for a gray scale image is 16. Also, bit depths 24, 32 and 48 are supported for RGB images in MATLAB. A grayscale image is monochrome. Use this link for reference. https://www.mathworks.com/matlabcentral/answers/78417-can-i-convert-one-image-in-grayscale-to-monochrome
Bit depth of an image:
The image has a bit depth that is shown in the properties of original image under details tab in the file manager i.e. 32 as MATLAB supports only few bit depths that are specific to image file format. An image which has 1456*1936 unit16 value implies that the image has 16 bits/sample. Number of samples for a gray scale image is one and number of samples for rgb image are three.
Use the given link for reference.
Here's one way:
% Demo to extract and swap bitplanes in a gray scale image.
clc; % Clear the command window.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');button = menu('Use which demo image?', 'CameraMan', 'Moon', 'Eight', 'Coins', 'Pout');if button == 1 baseFileName = 'cameraman.tif';elseif button == 2 baseFileName = 'moon.tif';elseif button == 3 baseFileName = 'eight.tif';elseif button == 4 baseFileName = 'coins.png';else baseFileName = 'pout.tif';end% Read in a standard MATLAB gray scale demo image.folder = fullfile(matlabroot, '\toolbox\images\imdemos');% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);if ~exist(fullFileName, 'file') % Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file') % Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName); uiwait(warndlg(errorMessage)); return; endendgrayImage = imread(fullFileName);% Get the dimensions of the image. numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);% Display the original gray scale image.
subplot(2, 1, 1);imshow(grayImage, []);title('Original Grayscale Image', 'FontSize', fontSize);% Get the 3rd bitplane
bitPlane3Image = bitget(grayImage, 3);% Get the 5th bitplane
bitPlane5Image = bitget(grayImage, 5);% Make the 3rd bitplane the 5th one.
grayImage = bitset(grayImage, 3, bitPlane5Image);% Make the 5th bitplane the 3rd one.
grayImage = bitset(grayImage, 5, bitPlane3Image);% Display the original gray scale image.subplot(2, 1, 2);imshow(grayImage, []);title('Modified Grayscale Image', 'FontSize', fontSize);fprintf('Done running %s.m.\n', mfilename);msgbox('Done with demo');
Best Answer