Load and Save 16bit image

My MatLab is R2009a. I don’t guarantee that this info. is same as other versions.

Suppose we have a 16bit image ‘test.tif’. What we want to do is, first read the image and then save the image as ‘res.tif’.
Simply speaking, default imread and imwrite are sufficient this purpose. When I load the image as follows, it’s loaded as unsigned 16bit image.

  • test = imread(‘test.tif’, ‘tif’);

Format of the image, “test”, is .
Then, call imwrite as follows to save it as ‘res.tif’.

  • imwrite(test, ‘res.tif’, ‘tif’);

Finally, we could duplicate the image.

When the image is loaded as double format as follows, the situation is drastically changed.

  • test = double(imread(‘test.tif’, ‘tif’));

Format of the image, “test”, is . When we save the image same as the case “uint16”, the image is saved as an 8bit image. We have to explicitly set saved image as 16bit as follows.

  • imwrite(uint16(test), ‘res.tif’, ‘tif’);

Thus, we can save double format image as 16bit image.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s