MATLAB学习笔记——影像处理入门

前言

本次主要是为了记录下学习和复习MATLAB中的知识点,以此来巩固一下自己薄弱的知识体系,MATLAB前面基础零散的小知识点就暂时先不管,这次直接奔向画图模块,事先声明,本人是跟着的B站上的教程视频 MATLAB教程_台大郭彦甫(14课)原视频补档,所以博客中的大部分案例也都来自郭老师得教案。

读取与展示图片

I = imread('pout.tif'); %read
imshow(I); %show

pout.tif为MATLAB内置的图片。
在这里插入图片描述

读取图片详细详细

imageinfo('pout.tif')

在这里插入图片描述

imtool('pout.tif')

在这里插入图片描述
查看每个像素点的数值。

MATLAB处理图像

图像乘法

I=imread('rice.png'); 
subplot(1,2,1); imshow(I);
J=immultiply(I, 1.5);
subplot(1,2,2); imshow(J);

immultiply - Multiply two images or multiply image by constant
This MATLAB function multiplies each element in array X by the corresponding element in array Y and returns the product in the corresponding element of the output array Z.(图像内每个数值都乘以传进去的参数,像上面例子就乘以1.5——放亮1.5倍)
在这里插入图片描述
图像加法

I=imread('rice.png'); 
J=imread('cameraman.tif'); K=imadd(I,J); 
subplot(1,3,1); imshow(I); 
subplot(1,3,2); imshow(K);
subplot(1,3,3); imshow(J); 

imadd - Add two images or add constant to image
This MATLAB function adds each element in array X with the corresponding element in array Y and returns the sum in the corresponding element of the output array Z
注意:两张图片必须一样,即矩阵一样,不然无法相加。相加的原理即刚刚矩阵内的值相加,所以无论两张原图有多暗,相加后都会变亮,因为相加后值变大了。
在这里插入图片描述
展示灰度值

I = imread('pout.tif');
imhist(I);

imhist - Histogram of image data
This MATLAB function calculates the histogram(柱状图) for the grayscale(灰度值) image I.
在这里插入图片描述
提高对比度

I = imread('pout.tif'); I2 = histeq(I);
subplot(1,4,1); imhist(I);
subplot(1,4,2); imshow(I);
subplot(1,4,3); imshow(I2);
subplot(1,4,4); imhist(I2);

histeq - Enhance contrast(对比度) using histogram equalization(均衡)
This MATLAB function transforms the grayscale image I so that the histogram of the output grayscale image J with length(hgram) bins approximately(大约) matches(匹配) the target histogram hgram.
在这里插入图片描述
旋转图片

I = imread('rice.png'); subplot(1,2,1); 
imshow(I); J = imrotate(I, 35, 'bilinear'); 
subplot(1,2,2); imshow(J);
size(I)
size(J)

imrotate - Rotate(旋转) image
This MATLAB function rotates image I by angle degrees in a counterclockwise direction(逆时针方向) around its center point.
在这里插入图片描述

保存图片

imwrite(I, 'pout2.png');

imwrite - 将图像写入图形文件
此 MATLAB 函数 将图像数据 A 写入 filename 指定的文件,并从扩展名推断出文件格式。imwrite 在当前文件夹中创建新文件。输出图像的位深度取决于 A 的数据类型和文件格式。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值