获取图像的ROI模板区域

前言

    项目需要得到视频帧图像的某一区域作为模板,首先需要确定ROI区域的坐标范围,很简单,直接上代码。

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% /************************************************************************
% * Copyright(c) 2017  ZRJ
% * All rights reserved.
% *
% * File:   templateCapture.m
% * Brief: 获取连续视频帧的ROI区域
% * Version: 1.0
% * Author: ZRJ
% * Email: happyamyhope@163.com
% * Date:   2017/02/28
% * Reference:
% * History:
% * 20160919:根据图片抠出感兴趣区域图像作为模板;
%
% ************************************************************************/
 
function [] = templateCapture( )
%程序功能:根据图片抠出感兴趣区域图像作为模板;
 
%输入input:
%    im --  image;
%输出output:
%    temp  --  template from input image;
 
%Parameter:
 
clc
clear
close all
 
 
path = 'E:\carriage_recognition\in_out_detection\avi2frame\avi2frame\03010000641000100_201612121326_redplate_snap\';
format = '*.jpg';
d = dir( [path, format] );
num = length(d);
for i = 1 : num
     im = imread([path, num2str(i), '.jpg']);
%      imtool(im) %确定ROI区域的坐标值
imCp = im( 930:1010, 25:90, :); %03010001492000000_201612201614_redplate_snap_template
%     imshow(imCp)
    imwrite(imCp, ['.\03010001830000000_201612231433_redplate_snap\03010001830000000_201612231433_redplate_snap_template_',num2str(i), '.jpg']);
end % end for
 
end % end function templateCapture

  注意:

     imtool函数是人机交互获取ROI区域的坐标值;

posted on   鹅要长大  阅读(601)  评论(0编辑  收藏  举报

编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示