Common functions of matlab for digital image processing

1. imread (specific path string)

Function: read image

Two, rgb2gray (specific color image)

Function: Convert color image to grayscale image

3. imhist (specific pictures)

Function: display the histogram corresponding to the picture

4. imshow (specific pictures)

Function: display pictures

5. histeq (specific picture, specific gray scale after equalization)

Function: Pass in two parameters, the function is to equalize the picture

6. im2double (specific picture)

Function: convert the data type of the image into a double-precision floating-point number

Note: To supplement the important point , if we convert the image to double, and then use imshow (specific picture), we will find that the display may be a white image.

Reason analysis: The range of double type in matlab is (0~1), while the original image is usually unit8 type (0~255) by default

When using imshow(), when it is greater than 1, it is displayed as 1, and it is all white.

Solution: When displaying pictures

1. Either convert the double type to unit8 type, and then display the picture, as follows:

imshow(unit8(具体数据类型为double的图片));
%转成unit8型

2. Either when using the imshow() function to display pictures, normalize to between 0 and 1, as follows:

imshow(具体图片/255);
%将图片矩阵转化为0~1之间

 3. Supplement: The range of data can be automatically adjusted for easy display:

imshow(I,[具体范围参数]);

Seven, fspecial (the type of filter template, a template that multiplies several times)

Function: construct filter

Take a chestnut:

AFilter = fspecial('average',[5,5]);
% 构造5*5的均值滤波器

Eight, imfilter (specific pictures, constructed filter templates)

Function: Use a filter to smooth the image

Take a chestnut:

%读入彩色图像
ImageC = imread('文件夹路径\自己的图片名');

%构造5*5的均值平滑滤波器
HFilter = fspecial('average',[5,5]);

%使用均值滤波器对彩色图像进行平滑
ImageFC = imfilter(ImageC,HFilter); 

Nine, title (the name of the picture that needs to be noted)

Function: Remark the name of the picture displayed by imshow(), and it will be displayed above the picture. Put the string inside. Take a chestnut: title('Original Image')

Guess you like

Origin blog.csdn.net/zhan_qian/article/details/127945489