⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 algorithmtest.m

📁 outlook express反垃圾邮件插件
💻 M
字号:
%#    mffmsilhouette : Silhouette extraction algorithm%#    Copyright (C) 2003  Matt Flax, Regina%#%#    This program is free software; you can redistribute it and/or modify%#    it under the terms of the GNU General Public License as published by%#    the Free Software Foundation; either version 2 of the License, or%#    (at your option) any later version.%#%#    This program is distributed in the hope that it will be useful,%#    but WITHOUT ANY WARRANTY; without even the implied warranty of%#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%#    GNU General Public License for more details.%#%#    You should have received a copy of the GNU General Public License%#    along with this program; if not, write to the Free Software%#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA%#%#%#    Matt Flax <flatmax@ieee.org>function algorithmTestglobal whichFrame; whichFrame=1; %#This is onyl for loading files may be removed with real cameraglobal maxFrame; maxFrame=21; %#This is onyl for loading files may be removed with real camera%# this file pieces all of the algorithm steps togetherF=200; %# The number of frames to averge over initially should be F=200F=maxFrame;%# get the first frame to set up the constants[frameR,frameG,frameB]=grabFrame;[r,c]=size(frameR);[r c]m_Y=zeros(r,c);  %# Set up the mean valuesm_I=zeros(r,c);m_Q=zeros(r,c);%# average estimation = background de-noisingfor j=1:F    [yFrame,iFrame,qFrame]=rgb2yiq(frameR,frameG,frameB); %# Convert to yiq        m_Y=m_Y+yFrame/F; %# create the YIQ averages    m_I=m_I+iFrame/F;    m_Q=m_Q+qFrame/F;        if j<F %# avoid grabbing too many frames        [frameR,frameG,frameB]=grabFrame; %#get the RGB's    end    endif 0 %# look at this to check the average background    figure(1); title('Y')    image(m_Y)    figure(2); title('I')    image(m_I)    figure(3); title('Q')    image(m_Q)    returnend%# set up the variablesL=256; %# 8 bit quantisation = 256 levels%# evaluate the histograms[f_Y,f_I,f_Q]=evalHistograms(yFrame,iFrame,qFrame, L);%# evaluate the original thresholds from the averagesT_p=10; %# Global threshold as a percentageT_p=T_p/100; %# Global threshold as a fraction%# main loop here for silhouette extraction%#for l=1:maxFrame-Fwhile 1    %#  while 1 %# never stop - change to this for continuous operation    %#first grab a frame and convert to YIQ    [frameR,frameG,frameB]=grabFrame; %#get the RGB's    [yFrame,iFrame,qFrame]=rgb2yiq(frameR,frameG,frameB); %# Convert to yiq        %# evaluate the histograms    [f_Y,f_I,f_Q]=evalHistograms(yFrame,iFrame,qFrame, L);        if 0 %# use this to see the histograms for each        figure(1); title('Y'); plot(f_Y);        figure(2); title('I'); plot(f_I);        figure(3); title('Q'); plot(f_Q);    end        T_Y=evaluateThreshold(f_Y,m_Y,F,T_p); %#evaluate the thresholds    T_I=evaluateThreshold(f_I,m_I,F,T_p);    T_Q=evaluateThreshold(f_Q,m_Q,F,T_p);        %# extracting a silhouette    %# eval Eq. 3 for each Y,I and Q    truthMatrix_Y=equation3(yFrame,m_Y,T_Y);    truthMatrix_I=equation3(iFrame,m_I,T_I);    truthMatrix_Q=equation3(qFrame,m_Q,T_Q);        if 0 %# look at this to see the truthMatrix_Y        figure(1); plot(truthMatrix_Y)        return;    end        %# eval each of the three conditions    truthMatrix=zeros(r,c); %# silhouette truth vector        %# Condition a]:    truthMatrix=truthMatrix|(truthMatrix_I&truthMatrix_Q);    %# Condition b]:    truthMatrix=truthMatrix|((truthMatrix_I&truthMatrix_Y)|(truthMatrix_Q&truthMatrix_Y));    %# Condition c]:    T_s=0.5*100;    truthMatrix_s=equation3(yFrame,m_Y,T_s);    truthMatrix=truthMatrix|((~truthMatrix_I & ~truthMatrix_Q) & truthMatrix_s);        %# convert the truth vector to a matrix    truthMatrix=reshape(truthMatrix,r,c);    %# any element of truthMatrix>0 implies a silhouette pixel        if 1%# this will let you see the silhouette        scale=max(max(truthMatrix));        if scale==0            scale=1;        end        figure(1); image(truthMatrix/scale*256);        if any(any(truthMatrix))            input(' foreground present: please press any key');        else            input(' No forground: please press any key');        end    endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -