Write image to file
ret=imwrite(im, filename)
im can be an M-by-N (greyscale image) or M-by-N-by-3 (color image) matrix. If im is not of class uint8, imwrite will convert the datatype before writing using im2uint8(im) .
A string that specifies the name of the output file.
Return value. If the image is successfully writed into a file, ret will be 1.
imwrite writes a matrix into a image file. The format of the file is inferred from the extension in the filename parameter. Currently the following file formats are supported:
im = rand(200,300); imwrite(im, 'rand.png'); S = imread('rand.png'); imshow(S); | ![]() | ![]() |