matlab灰度反转代码
时间: 2023-07-02 09:16:34 浏览: 47
可以使用以下代码实现 Matlab 中的灰度反转:
```matlab
% 读取图像
img = imread('image.jpg');
% 灰度反转
img_reverse = 255 - img;
% 显示结果
subplot(1, 2, 1),imshow(img),title('原图');
subplot(1, 2, 2),imshow(img_reverse),title('灰度反转图');
```
其中,`imread` 函数用于读取图像,`255 - img` 表示将图像中每个像素的数值都取反,得到灰度反转的图像。最后使用 `subplot` 函数将原图和灰度反转图分别显示在两个子图中。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![xlsx](https://img-home.csdnimg.cn/images/20210720083732.png)
![xls](https://img-home.csdnimg.cn/images/20210720083658.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)