获取图像的ROI模板区域

前言

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

 

% /************************************************************************
% * 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 2017-03-21 09:08  鹅要长大  阅读(593)  评论(0编辑  收藏  举报

导航