Computer Vision_Matlab (1)

1 Loading Images from Files

Ia=imread('rooster.jpg');
Ib=imread('elephant.png');

1.1 Intensity images

double---0.0(black)-1.0(white)

unit 8---0-255

The class uint8 only requires roughly 1/8 of the storage compared to the class double.

1.2 Binary images

 0 or 1

1.3 RGB images

3-dimensional matrix

red green and blue

floating-point numbers or as integer values

1.4 Indexed images

two matrices

the first matrix has the same size as the image and one number for each pixel

the second matrix is called the colour map and its size may be different from the image

I1=rand(1000,1000);
I2=rand(1000,1000);
Isum=I1+I2;
ImultA=I1*I2;
ImultB=I1.*I2;
Ia=imread('rooster.jpg');
Ib=imread('elephant.png');

type whos

2 Image Display

Ia=imread('rooster.jpg');
Ib=imread('elephant.png');
figure(1), subplot(2,2,1), imagesc(Ia); title('RGB image'); 

Ia=imread('rooster.jpg');
Ib=imread('elephant.png');
figure(1), subplot(2,2,1), imagesc(Ia); title('RGB image'); 
subplot(2,2,2), imagesc(Ia(:,:,1)); title('red channel'); colorbar
subplot(2,2,3), imagesc(Ia(:,:,2)); title('green channel'); colorbar
subplot(2,2,4), imagesc(Ia(:,:,3)); title('blue channel'); colorbar

colormap('gray')

figure(2), imagesc(Ib); colorbar
colormap('gray');

figure(2), axis('off')

axis('equal')

# This reshapes the image so that both the x- and y-axes are scaled equally

3 Reading Values From An Image

Ib
Ib (3,:)   # 3rd row
Ib (:,3)   # 3rd column
Ib (1:6; 1:4)   # 1-6 row and 1-4 column (6*4 matrix)
Ia (1:6,1:4,1)   # red channel
Ia (1:6,1:4,2)   # green channel
Ib (3,4)   #  row 3 and column 4
# from RGB format to indexed format
rgb2ind()

# from RGB format to intensity format
rgb2gray()

# from RGB format to binary format
im2bw()

# from indexed format to RGB format
ind2rgb()

# from indexed format to intensity format
ind2gray()

# from indexed format to binary format
im2bw()

# from intensity format to indexed format
gray2ind()

# from intensity format to binary format
im2bw()

# from a matrix to intensity format by scaling
mat2gray()

# from uint8 to double data type
im2double()

# from double to uint8 data type
im2uint8()

# from RGB to HSV format
rgb2hsv()

# from RGB to Lab format
rgb2lab()

4 Saving Images and Variables to Files

Iag=rgb2gray(Ia);
Iagd=im2double(Iag);

imwrite(Iagd,'rooster_gray.jpg','jpg')    # save a MATLAB image as a file

figure(1)   # save figure
print -dpdf rooster_RGB.pdf   # creat a .pdf file
help print    

save   # save the variables in your current MATLAB session so that you can
       # continue work with them a later date
save('cv_cw1_variables.mat');
load

Addition

A.1 

I1=rand(1000,1000)

I2=rand(1000,1000);

The first command (without the semi-colon) prints lots of numbers to the screen, while the second command (with the semi-colon) does not.

A.2

ImultA=I1*I2;

ImultA=I1*I2;

# Be sure to use .* instead of * when you are multiplying two images together element-by-element.

A.3

Reading an image into MATLAB is performed by the function imread . This function supports a number of image file formats (these formats can be listed by executing the command imformats

### 如何在MATLAB中安装和配置Computer Vision Toolbox #### 安装步骤概述 为了在MATLAB中使用Computer Vision Toolbox的功能,可以通过官方渠道下载并安装工具箱。如果需要额外支持OpenCV或其他第三方库,则需进一步完成特定的集成操作。 #### 使用内置Computer Vision Toolbox MATLAB自带的Computer Vision Toolbox提供了丰富的图像处理与计算机视觉功能。要启用此工具箱,只需确保已购买并激活相应的许可证[^1]。 通过以下方式验证是否已安装: ```matlab ver % 查看当前MATLAB环境中所有可用工具箱列表 ``` 若未发现`Computer Vision Toolbox`,则可通过MathWorks账户重新获取许可或联系技术支持团队解决。 #### 配置OpenCV接口 当希望扩展MATLAB的能力至外部C++库(如OpenCV),可以按照如下方法设置环境变量以及加载必要的函数模块[^2]: - 下载 `Computer Vision Toolbox Interface for OpenCV in MATLAB` 并解压到本地磁盘; - 将路径添加至MATLAB全局搜索范围之内,并确认编译器兼容性良好以便顺利运行测试脚本; #### Piotr’s Computer Vision Matlab Toolbox 的补充作用 对于某些高级需求而言,单独依靠标准发行版可能不足以为用户提供足够的灵活性或者效率提升空间。此时引入开源项目成为一种可行方案之一——即采用由加州大学圣地亚哥分校开发维护的一套轻量级框架作为辅助手段来弥补差距[^4]。 具体做法包括但不限于访问官方网站下载最新版本源码包、依照指示文档逐步调整系统参数直至最终生效为止[^5]: ##### 关键点提示 - **依赖关系管理**: 确认目标平台满足最低硬件/软件规格要求之前不要贸然行动; - **权限控制机制**: 如果遇到任何关于读写受限区域报错现象, 可尝试切换工作目录再试一次; ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值