How to read .BMP file as matrix or to access values grater than 255.

I wannt to display the .bmp file showing actual intensity value. but using the : imread or fileopn command are getting me image with only values upto 255 limitation. while the intensity above the 255 are not displayed in plot.
Please help to get the intensity as the .bmp image is upto 4000 value of intensity in actual

 Accepted Answer

That image is a .bmp that is an indexed RGB image. The intensities appear to be stored as 8 bits per component, and are retrieved by imread as integers divided by 255. The maximum number of bits per component that the BMP file format can store in indexed images is 8.
The image appears to be read correctly by imread(): the file itself appears not to be what you expect it to be.

4 Comments

Hi I see that the grayImage = imread(fullFileName); give me the following values for the GreyImage matrix plot- values:
There is no peak above 255, which shows that for all values grater than 255 it read only 255 instead of true value
[indimage, rgbmap] = imread(fullfilename);
now look at size(indimage) and notice that it is 2D not 3D, so you are dealing with an indexed image. Look at size(rgbmap) and see that it 256 * 3, which is appropriate for a colormap of 256 entries. Look at max(rgbmap(:)) to see that the maximum value is 1. Look at rgbmap * 255 and see that the results are all integral with maximum 255, so all of the entries in rgbmap are nonnegative integers times 1/255.
The maximum 255 that you see for your "grayImage" is because your image is indexed 256 entries and indexing with uint8 datatype has a maximum value that is 1 less than the number of entries in the table (because entry #0 is the first entry).
The maximum 255 you retrieve from your file is an index. The maximum 1 that you pull out of the color table is 255/255 as all of the entries are in the range (0:255)/255.
There is no intensity in your image that is greater than 255.
Look at the results of imfinfo('2141.bmp')
BitDepth: 8
ColorType: 'indexed'
FormatSignature: 'BM'
NumColormapEntries: 256
Colormap: [256x3 double]
Indexed. Colormap Entries. Not the grayscale image you believed you were working with.
Why do you believe it should have values up to 4000? Do you have knowledge of how it was made? Maybe it was a 16 bit image and someone just wrote it out wrong.
yes I got it know , the image was wrongly created by software

Sign in to comment.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Asked:

on 4 Aug 2015

Commented:

on 30 Aug 2015

Community Treasure Hunt

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

Start Hunting!