0

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?

Amro
  • 123,847
  • 25
  • 243
  • 454

1 Answers1

0

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')
Amro
  • 123,847
  • 25
  • 243
  • 454
  • ??? Index exceeds matrix dimensions. Error in ==> ind2rgb at 27 r = zeros(size(a)); r(:) = cm(a,1); – user2354586 May 07 '13 at 07:49
  • I'm sorry, it worked, wrong input file. Unfortunately it doesn't work. It does do the conversion but it does not decrease the image quality like paint does. Therefor it doesn't equal almost likely colors to 1 color. An other option would be to open paint (that works) and to control paint using matlab. Is this possible? – user2354586 May 07 '13 at 07:53
  • Found a way to work around it. The code you gave is a good adding to this, otherwise it might not have have worked. I found an other way to export my files to .tif which have no shading and therefor no need to be converted by paint. Thanks – user2354586 May 07 '13 at 13:29
  • @user2354586: I'm not sure I get what the problem is, but I'm glad I could help. – Amro May 07 '13 at 17:24