Matlab图像处理

1.读入图像文件

1
tmp = imread('lena.jpg');

2.将彩色图像转化为灰度图像

1
img = rgb2gray(tmp);

3.显示图像

1
imshow(img);

4.将图像文件转化为double

1
I = im2double(img);

5.将矩阵转为灰度图

1
img = mat2gray(I);

6.保存为图片

1
imwrite(img,'img.jpg');

7.相关函数

| gray2ind | Convert grayscale or binary image to indexed image |
| ind2gray | Convert indexed image to grayscale image |
| mat2gray | Convert matrix to grayscale image |
| rgb2gray | Convert RGB image or colormap to grayscale |
| ind2rgb | Convert indexed image to RGB image |
| label2rgb | Convert label matrix into RGB image |
| demosaic | Convert Bayer pattern encoded image to truecolor image |

| imbinarize | Binarize image by thresholding |
| imquantize | Quantize image using specified quantization levels and output values |
| multithresh | Multilevel image thresholds using Otsu’s method |
| adaptthresh | Adaptive image threshold using local first-order statistics |
| otsuthresh | Global histogram threshold using Otsu’s method |
| im2bw | Convert image to binary image, based on threshold |
| graythresh | Global image threshold using Otsu’s method |
| grayslice | Convert grayscale image to indexed image using multilevel thresholding |

| im2double | Convert image to double precision |
| im2int16 | Convert image to 16-bit signed integers |
| im2java2d | Convert image to Java buffered image |
| im2single | Convert image to single precision |
| im2uint16 | Convert image to 16-bit unsigned integers |
| im2uint8 | Convert image to 8-bit unsigned integers |

Examples and How To

Concepts

您的支持将是我前进的不懈动力