MATLAB学习笔记——影像处理进阶

前言

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

MATLAB对图像进阶处理

图片转换成二进制图

I = imread('rice.png'); level=graythresh(I); 
bw=im2bw(I, level); subplot(1,2,1); imshow(I); 
subplot (1,2,2); imshow(bw);

graythresh - Global image threshold(阈值) using Otsu’s method
This MATLAB function computes a global threshold T from grayscale image I, using Otsu’s method [1].
im2bw - Convert(转换) image to binary image, based on threshold
This MATLAB function converts the grayscale image I to binary image BW, by replacing all pixels in the input image with luminance greater than level with the value 1 (white) and replacing all other pixels with the value 0 (black).
在这里插入图片描述
背景图估计

I = imread('rice.png'); 
BG = imopen(I, strel('disk', 15));
imshow(BG);

imopen - Morphologically(心态) open image
This MATLAB function performs morphological opening on the grayscale or binary image I, returning the opened image, J.
在这里插入图片描述
去除背景

I = imread('rice.png'); 
subplot(1,3,1); imshow(I); 
BG = imopen(I, strel('disk', 15));
subplot(1,3,2); imshow(BG);
I2 = imsubtract(I, BG);
subplot(1,3,3); imshow(I2);

imsubtract - Subtract one image from another or subtract constant from image(减法)
This MATLAB function subtracts each element in array Y from the corresponding element in array X and returns the difference in the corresponding element of the output array Z
在这里插入图片描述
基于阈值把背景去除(更精确)

I = imread('rice.png'); level=graythresh(I);
bw = im2bw(I, level); subplot (1,2,1); 
imshow(bw); BG = imopen(I, strel('disk', 15));
I2 = imsubtract(I, BG); level=graythresh(I2); 
bw2 = im2bw(I2, level); 
subplot(1,2,2); imshow(bw2);

在这里插入图片描述
通过连通区域标记

I=imread('rice.png');
BG=imopen(I, strel('disk', 15));
I2=imsubtract(I, BG); level=graythresh(I2); 
BW=im2bw(I2, level); 
[labeled, numObjects]=bwlabel(BW, 8);

bwlabel - Label connected components(区域) in 2-D binary image
This MATLAB function returns the label matrix(矩阵) L that contains labels for the 8-connected objects found in BW.
在这里插入图片描述
可以看出,最后计算出来的numObjects为99,所以连通的区域(白色部分)有99,可应用于图像识别的计数。
给图片上色

I=imread('rice.png');
BG=imopen(I, strel('disk', 15));
I2=imsubtract(I, BG); level=graythresh(I2); 
BW=im2bw(I2, level); 
[labeled, numObjects]=bwlabel(BW, 8);
RGB_label=label2rgb(labeled); imshow(RGB_label);

label2rgb - Convert label matrix into RGB image
This MATLAB function converts a label matrix, L, such as those returned by labelmatrix, bwlabel, bwlabeln, or watershed, into an RGB color image for the purpose of visualizing the labeled regions.
在这里插入图片描述
交互式选择

I=imread('rice.png'); level=graythresh(I);
BG=imopen(I, strel('disk', 15));
I2=imsubtract(I, BG); BW=im2bw(I2, graythresh(I2)); 
ObjI = bwselect(BW); imshow(ObjI);

bwselect - Select objects in binary image
This MATLAB function returns a binary image containing the objects that overlap the pixel (r,c), where n specifies the connectivity.
在这里插入图片描述
选择你要扣出的区域,然后右键
在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Matlab数字信号处理85个实用案例精讲》是一本面向数字信号处理初学者和进阶者的实用案例教程。书中以实际案例为主线,结合数字信号处理的理论知识,全面介绍了Matlab在数字信号处理领域的应用技巧。该书共分为三个部分,分别是基础篇、进阶篇和应用篇。 在基础篇中,书中首先介绍了Matlab的基本操作和数字信号处理的基本概念,包括信号的基本特征、采样与重构、时域分析和频域分析等内容。通过具体案例的讲解,读者可以系统地学习Matlab中数字信号处理的基本知识,并能够掌握常用的信号处理方法和技巧。 进阶篇则深入介绍了Matlab在数字信号处理中的高级应用,包括数字滤波器设计、信号的时频分析、小波分析等内容。通过学习这部分内容,读者可以进一步提高对Matlab数字信号处理工具箱的应用水平,能够独立地进行数字信号处理的设计和实现。 最后的应用篇则通过多个实际案例,如语音信号处理、图像处理和通信系统仿真等,展示了Matlab数字信号处理在各个领域的实际应用。通过这些案例的学习,读者可以更加深入地理解Matlab数字信号处理在各个领域的应用场景,为以后的工程实践做好准备。 总的来说,《Matlab数字信号处理85个实用案例精讲》涵盖了数字信号处理的入门到进阶所需的知识和技能,并通过丰富的案例教学帮助读者更好地理解和掌握数字信号处理的实际应用。无论是初学者还是已有一定基础的读者,都可以从中受益匪浅。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值