Convert an image with 16 bit depth to 32 or 62 bit in MATLAB?
21 views (last 30 days)
Show older comments
Happy PhD
on 27 Aug 2019
Answered: Devineni Aslesha
on 30 Aug 2019
How can i convert a 16-bit monocromatic image (no colors, black and white) to 32-bit ot 62-bit depth image?
Also, I have an .png image which has Bit depth 32. I upload it to MATLAB with function Imread. The variable has 1456x1936 uint16 value. Does it have bit depth 16 or 32 (as the orioginal image says in the properties under details tab in the file manager)? What is uint16?
imfinfo:
Format: 'png'
FormatVersion: []
Width: 1936
Height: 1456
BitDepth: 16
ColorType: 'grayscale'
FormatSignature: [137 80 78 71 13 10 26 10]
Colormap: []
Histogram: []
InterlaceType: 'none'
Transparency: 'none'
SimpleTransparencyData: []
BackgroundColor: 0
SignificantBits: 14
OtherText: {14×2 cell}
0 Comments
Accepted Answer
Devineni Aslesha
on 30 Aug 2019
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.BitDepth
imwrite(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.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!