模版匹配定位跟蹤原始碼
%% Find Green Object
% This script reads in an image file and then attempts to find a green
% object in the image. It is designed to find one green ball and highlight
% that ball on the original image
% Copyright 2013 The MathWorks, Inc.
%% Housekeeping
clear all; close all; clc;
%% Step 1: Read image into MATLAB
% First we read the specified image from the file and bring it into MATLAB
% as a variable. We also display the image to ensure it is correct.
greenBall1 = imread('greenBall1.jpg');
t = imtool(greenBall1);
%%
close(t);
%% Step 2: Identify Unique Characteristics of Object of Interest
%%
% Extract each color
% Next we using indexing to extract three 2D matrices from the 3D image
% data corresponding to the red, green, and blue components of the image.
r = greenBall1(:, :, 1);
g = greenBall1(:, :, 2);
b = greenBall1(:, :, 3);
%%
% View different color planes
figure, colormap gray
subplot(2,2,1),imagesc(r)
subplot(2,2,2),imagesc(g)
subplot(2,2,3),imagesc(b)
%%
% Calculate Green
% Then we perform an arithmetic operation on the matrices as a whole to try
% to create one matrix that represents an intensity of green.
justGreen = g - r/2 - b/2;
colorPlanesPlot(r,g,b,justGreen);
%%
close all
%% Step 3: Isolate Object of Interest
%%
% Threshold the image
% Now we can set a threshold to separate the parts of the image that we
% consider to be green from the rest.
bw = justGreen > 50;
figure;
imagesc(bw);
colormap(gray);
%%
% Remove small unwanted objects
% We can use special functions provided by the Image Processing toolbox to
% quickly perform common image processing tasks. Here we are using
% BWAREAOPEN to remove groups of pixels less than 30.
ball1 = bwareaopen(bw, 30);
figure;
imagesc(ball1);
%% Step 4: Find center of green object
% Now we are using REGIONPROPS to extract the centroid of the group of
% pixels representing the ball.
figure;
s = regionprops(ball1, {'centroid','area'});
if isempty(s)
error('No ball found!');
else
[~, id] = max([s.Area]);
hold on, plot(s(id).Centroid(1),s(id).Centroid(2),'wp','MarkerSize',20,'MarkerFaceColor','r'), hold off
disp(['Center location is (',num2str(s(id).Centroid(1),4),', ',num2str(s(id).Centroid(2),4),')'])
end
%% Step 5: Verify estimated location
% Finally we will plot the center on the original image to clearly evaluate
% how well we have found the center.
figure;
imagesc(greenBall1);
hold on, plot(s(id).Centroid(1),s(id).Centroid(2),'wp','MarkerSize',20,'MarkerFaceColor','r'), hold off
相關文章
- Java原始碼跟蹤閱讀技巧Java原始碼
- [原始碼分析] OpenTracing之跟蹤Redis原始碼Redis
- IDEA之如何Debug原始碼跟蹤Idea原始碼
- spring security 認證原始碼跟蹤Spring原始碼
- [20211013]閱讀ldd原始碼跟蹤.txt原始碼
- Qt - 原始碼跟蹤一個QtCreator就夠了QT原始碼
- spring security 授權方式(自定義)及原始碼跟蹤Spring原始碼
- spring security之 預設登入頁原始碼跟蹤Spring原始碼
- spring security 之自定義表單登入原始碼跟蹤Spring原始碼
- Java高精度定位系統原始碼 UWB定位系統原始碼 定位系統原始碼Java原始碼
- PostgreSQL 原始碼解讀(15)- Insert語句(執行過程跟蹤)SQL原始碼
- 二進位制入門--動態跟蹤原始碼和反彙編程式碼原始碼
- 強盜利用Apple Watch定位功能跟蹤毒販,劫走50萬美元APP
- 可變形曲面跟蹤,亮風臺新出基於圖匹配的方法
- PostgreSQL 原始碼解讀(21)- 查詢語句#6(PlannedStmt詳解-跟蹤分析)SQL原始碼
- Android 程式碼跟蹤到native怎麼辦Android
- 追蹤解析 Disruptor 原始碼原始碼
- 追蹤解析 ThreadPoolExecutor 原始碼thread原始碼
- 螞蟻金服分散式鏈路跟蹤元件取樣策略和原始碼 | 剖析分散式元件原始碼
- sp_trace_setfilter sqlserver篩選跟蹤或跟蹤過濾FilterSQLServer
- 婚紗攝影網站模版原始碼案例網站原始碼
- 【YashanDB知識庫】windows配置ODBC跟蹤日誌, 使用日誌定位問題Windows
- slate原始碼解析(三)- 定位原始碼
- 主力跟蹤戰法
- 反跟蹤技術
- Laravel Route(路由)匹配原始碼分析Laravel路由原始碼
- git的跟蹤分支和遠端跟蹤分支學習筆記Git筆記
- 追蹤解析 Netty IntObjectHashMap 原始碼NettyObjectHashMap原始碼
- druid查詢原始碼追蹤UI原始碼
- [20190402]跟蹤vmstat.txt
- Linux 跟蹤器之選Linux
- SQLServer進行SQL跟蹤SQLServer
- 會話跟蹤技術會話
- 跟蹤執行命令T
- 除錯跟蹤利器---strace除錯
- 定位系統原始碼,採用UWB技術開發的人員定位系統原始碼原始碼
- 像跟蹤分散式服務呼叫那樣跟蹤 Go 函式呼叫鏈分散式Go函式
- 追蹤原始碼的方式歸納原始碼