Matlab: Load .tif > convert bmp 256 > convert bmp 24-bit

2.3k Views Asked by At

For some coding I would like to do the following:

  • Read .tif file
  • Convert to .bmp with 256 colours (got this from paint, can't find it in matlab!)
  • Convert to .bmp with 24-bit (normal conversion to .bmp is 24-bit, this works)

The problem is within step 2. I need this step since it reduces the image quality and therewith it makes the section colors less advanced. With this a section will have the same value as it should instead of 4 types of dark blue'ish which you can't see with the bare eye.

Part of the code in which conversion happends:

%Reads image
[XX,map] = imread('Test_Script.tif');

%Convert to 256 bmp?

%Write image first if needed
%imwrite()
%Read new image
%[ZZ,map] = imread()

%Converts to rgb 8-bit
YY=ind2rgb8(XX,map);

%writes image
imwrite(YY, map, 'Test_Script_new.bmp','bmp');

Well I can't figure it out, maybe you have an idea?

1

There are 1 best solutions below

4
On

Try the following:

[img,map] = imread('canoe.tif');
rgb = im2uint8(ind2rgb(img,map));

%imshow(img,map)
%imshow(rgb)

imwrite(img, map, '8bpp.bmp', 'bmp')
imwrite(rgb, '24bpp.bmp', 'bmp')