图片截图matlab
时间: 2023-08-27 12:12:24 浏览: 164
matlab图片RGB数据读取、截图
在MATLAB中,你可以使用以下代码来实现图片截图:
```matlab
I = imread('1.jpeg'); % 读取图片
[row,col = size(I); % 获取图片尺寸
imshow(I) % 显示图片
impixelinfo % 读取鼠标位置
L1 = [1641,2495]; % 左上顶点
L2 = [2153,2583]; % 右下顶点
L3 = L2 - L1;
hold on
rectangle('Position',[L1 L3],'LineWidth',1.5,'EdgeColor','r') % 绘制矩形框
hold off
S1 = I(L1(2):L2(2),L1(1):L2(1),1:1:3); % 截取矩形框内的图像
imwrite(uint8(S1),'test01.bmp'); % 保存截图为bmp格式
```
以上代码将读取名为'1.jpeg'的图片,然后在图片上绘制一个红色边框,框选区域由左上顶点L1和右下顶点L2确定。接下来,将选定区域的图像保存为'test01.bmp'。希望这能帮到你。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [【MATLAB】截取图片指定区域并另存为bmp图片](https://blog.csdn.net/hsdujdjrjrj/article/details/128244314)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* [改变figure大小存储图片(matlab)](https://blog.csdn.net/weixin_32374445/article/details/112837557)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文