Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Can I keep the original image format by saving tif image stack in matlab?
Can I keep the original image format by saving tif image stack in matlab?
Sometimes we need to save the number matrix in TIFF format. In the process of saving, sometimes the picture will be white when it is opened. Never mind, here's the solution.

Save the image matrix in TIFF format with MATLAB. First, we use the Imread function to open a picture I = IMREAD ('c: \ users \ hzf \ documents \ MATLAB \ data \ Lena.jpg').

Use the imwrite function to save the image in TIFF format. If the image is img, you can use imwrite(img,' result.tiff').

Sometimes you will see that the saved image is white. In imwrite(A, filemane), if the image is a, there are two possibilities.

1)A data is an integer from 0 to 255;

2) Double precision type, with the value range of 0-1.0; Save the displayed image as blank, which means that A should be an integer, but it is actually a double type. If the value exceeds the specified value 1.0, it will be displayed in white.

Solution:

1) double can be converted into integer data between [0-255] by using the uint8 function.

2) you can scale A = A/255 to [0- 1] and then imwrite(A, filemane).