




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、精品好資料學(xué)習(xí)推薦基于matlab 的HSV陰影消除代碼,畢設(shè)所用,用完貢獻(xiàn)先給代碼后有說明function varargout = untitled111111(varargin)% UNTITLED111111 M-file for untitled111111.fig% UNTITLED111111, by itself, creates a new UNTITLED111111 or raises the existing% singleton*.% H = UNTITLED111111 returns the handle to a new UNTITLED111111 or the
2、 handle to% the existing singleton*.% UNTITLED111111(CALLBACK,hObject,eventData,handles,.) calls the local% function named CALLBACK in UNTITLED111111.M with the given input arguments.% UNTITLED111111(Property,Value,.) creates a new UNTITLED111111 or raises the% existing singleton*. Starting from the
3、 left, property value pairs are% applied to the GUI before untitled111111_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to untitled111111_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose GUI allo
4、ws only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help untitled111111% Last Modified by GUIDE v2.5 31-Mar-2014 09:39:29% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui
5、_Singleton, gui_Singleton, . gui_OpeningFcn, untitled111111_OpeningFcn, . gui_OutputFcn, untitled111111_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else
6、 gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before untitled111111 is made visible.function untitled111111_OpeningFcn(hObject, , handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to b
7、e defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to untitled111111 (see VARARGIN)% Choose default command line output for untitled111111handles.output = hObject;% Update handles structureguidata(hObject, handles);% U
8、IWAIT makes untitled111111 wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout = untitled111111_OutputFcn(, , handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to fi
9、gure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout1 = handles.output;% - Executes on button press in pushbutton1.function pushbutton1_Callback(, , )handles
10、=guihandles();global s;global e;global fn;global mov;for i=s:e mov_gray(i).image=mov(i).cdata; % mov_gray(i).image為第i幀圖像endih,iw,id=size(mov_gray(1).image); % 取得視頻幀的大小% 計(jì)算1到第n幀的各個(gè)像素的均值for i=s:e u=mov_gray(i).image; h=u(:); % 轉(zhuǎn)置 t(i,:)=h(:); % median(t)是對(duì)列進(jìn)行取均值的end%close(figure(gcf)% %關(guān)閉初始化窗口 % 試試不用轉(zhuǎn)
11、置直接用u來進(jìn)行median(t);tmp=median(t); % 對(duì)t數(shù)組各列取均值global mean;mean=reshape(tmp,ih,iw,id); % 將n幀均值圖像恢復(fù)成h*w*d的圖像矩陣,得到背景subplot(2,2,1),imshow(uint8(mean);title(背景圖像); %第一幅背景圖 %取第fn幀作為對(duì)象subplot(2,2,2),imshow(uint8(mov_gray(fn).image);title(目標(biāo)圖像); %第二幅完整圖像global ok; ok=mean; %ok-背景%tmp(1:3)=0;di=15;th=ones(1,1
12、,3)*di; % 預(yù)設(shè)閥值diff=double(ok)-double(mov_gray(fn).image); % 計(jì)算第fn幀圖像與背景的差值diff1=abs(diff);count2=0;for ai=1:ih for bi=1:iw if abs(diff(ai,bi,1:3)=th(1,1,:) ok(ai,bi,1:3)=mov_gray(fn).image(ai,bi,1:3); count2=count2+1; else ok(ai,bi,1:3)=0; diff1(ai,bi,1:3)=0; end endend%subplot(2,2,3),imshow(uint8(o
13、k);title(提取前景圖像); % %第三幅前景圖count2=count2*1.25;e1=num2str(count2);sc=共,e1;sc=sc,點(diǎn);set(handles.text16,String,sc);g=rgb2hsv(mean); % 將背景圖像由RGB格式轉(zhuǎn)為HSV格式g1=rgb2hsv(ok); % 將前景圖像由RGB格式轉(zhuǎn)為HSV格式% 閥值分割global TH1;global TH2;global TS;global TV;count4=0;for ci=1:ih for di=1:iw if (g1(ci,di,3)/g(ci,di,3)TS|abs(g1
14、(ci,di,1)-g(ci,di,1)TH2&g1(ci,di,1)=th(1,1,:)% ok(ai,bi,1:3)=mov_gray(fn).image(ai,bi,1:3);% else% ok(ai,bi,1:3)=0;% diff1(ai,bi,1:3)=0;% end% end%end%subplot(2,2,3),imshow(uint8(ok);title(提取前景圖像); % %第三幅前景圖QHuidu=rgb2ycbcr(Qianjing); %RGB顏色空間轉(zhuǎn)換到Y(jié)UV顏色空間BHuidu=rgb2ycbcr(Beijing);%subplot(2,2,4),imsho
15、w(BHuidu);title(提取前景圖像); % %第三幅前景圖%figure,imshow(QHuidu);%figure,imshow(BHuidu);Yyu=double(QHuidu(:,:,1)-double(BHuidu(:,:,1); %Y分量的差分YErzhihua=Yyu;Q= abs(Yyu)10; %Y分量差分圖像的二值化YErzhihua(Q)=1;Q= abs(Yyu)10; %UV分量的圖像的合成UVErzhihua(Q)=1;Q= abs(Uyu)+abs(Vyu)=10;UVErzhihua(Q)=0;%figure,imshow(UVErzhihua);Y
16、UVhecheng=Uyu;Q=(UVErzhihua=1)&(YErzhihua=1); %Y分量和UV分量的圖像合成YUVhecheng(Q)=1;Q=(UVErzhihua=0)|(YErzhihua=0);YUVhecheng(Q)=0;YUV=YUVhecheng;for ci=1:ih for di=1:iw if YUV(ci,di)=1 ok(ci,di,1:3)=mov_gray(fn).image(ci,di,1:3); else ok(ci,di,1:3)=mean(ci,di,1:3); end endendsubplot(2,2,4),imshow(ok);title
17、(YUV陰影消除);% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% - Executes on button press in pushbutton3.function pushbutton3_Callback(, , )clc;close all;close(gcf);clear;% hObject ha
18、ndle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)ai% - Executes on button press in pushbutton4.function pushbutton4_Callback(, , )h1=figure(toolbar,none,name,Shadow Removal); % 讀取受損圖像FileName,P
19、athName=uigetfile( *.avi,avi (*.avi);*.*,All Files (*.*),Open video sequence );if isequal(FileName,PathName,0,0) return;else pic_path=fullfile(PathName,FileName); global mov; mov=aviread(pic_path);endn=size(mov,2); %計(jì)算視頻的幀數(shù)(試試用這個(gè)代替下面的)%n=100; % 讀取視頻幀數(shù)global s;s=1; % 起始為1global e;e=n; % 結(jié)束為n%global f
20、n;%fn=11; % hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)function edit1_Callback(, , )% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version
21、of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of edit1 as text% str2double(get(hObject,String) returns contents of edit1 as a double% - Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject,
22、 , )% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,Back
23、groundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction edit2_Callback(hObject, , handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hi
24、nts: get(hObject,String) returns contents of edit2 as text% str2double(get(hObject,String) returns contents of edit2 as a doubleinput = str2num(get(hObject,String);if (isempty(input) set(hObject,String,11)endguidata(hObject, handles)% - Executes during object creation, after setting all properties.f
25、unction edit2_CreateFcn(hObject, , )% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if
26、 ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end% - Executes on button press in pushbutton5.function pushbutton5_Callback(, , handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future
27、version of MATLAB% handles structure with handles and user data (see GUIDATA)global fn;global e;e=num2str(e);sc=共,e;sc=sc,幀;%a = get(handles.edit1,String);fn = str2double(get(handles.edit2,String);set(handles.text15,String,sc);e=str2double(e);function edit3_Callback(hObject, , handles)% hObject hand
28、le to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)input = str2num(get(hObject,String);if (isempty(input) set(hObject,String,1)endguidata(hObject, handles)% Hints: get(hObject,String) returns contents of
29、 edit3 as text% str2double(get(hObject,String) returns contents of edit3 as a double% - Executes during object creation, after setting all properties.function edit3_CreateFcn(hObject, , )% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles e
30、mpty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction edit4_Callback(hO
31、bject, , handles)% hObject handle to edit4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)input = str2num(get(hObject,String);if (isempty(input) set(hObject,String,1)endguidata(hObject, handles)% Hints: get(hObj
32、ect,String) returns contents of edit4 as text% str2double(get(hObject,String) returns contents of edit4 as a double% - Executes during object creation, after setting all properties.function edit4_CreateFcn(hObject, , )% hObject handle to edit4 (see GCBO)% eventdata reserved - to be defined in a futu
33、re version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white
34、);endfunction edit5_Callback(hObject, , handles)% hObject handle to edit5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)input = str2num(get(hObject,String);if (isempty(input) set(hObject,String,2)endguidata(hOb
35、ject, handles)% Hints: get(hObject,String) returns contents of edit5 as text% str2double(get(hObject,String) returns contents of edit5 as a double% - Executes during object creation, after setting all properties.function edit5_CreateFcn(hObject, , )% hObject handle to edit5 (see GCBO)% eventdata res
36、erved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) se
37、t(hObject,BackgroundColor,white);endfunction edit6_Callback(hObject, , handles)% hObject handle to edit6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)input = str2num(get(hObject,String);if (isempty(input) set(
38、hObject,String,0.32)endguidata(hObject, handles)% Hints: get(hObject,String) returns contents of edit6 as text% str2double(get(hObject,String) returns contents of edit6 as a double% - Executes during object creation, after setting all properties.function edit6_CreateFcn(hObject, , )% hObject handle
39、to edit6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end% - Executes on
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 風(fēng)電工程培訓(xùn)課件下載
- 腎內(nèi)科飲食護(hù)理宣教
- 愛護(hù)眼睛健康小班教育指南
- 大班學(xué)校安全教育
- 氣血淤積健康指導(dǎo)
- 2025年5山東省威海市中考招生考試數(shù)學(xué)真題試卷(真題+答案)
- 預(yù)防網(wǎng)戀主題班會(huì)課件
- 預(yù)防梅毒的課件模板
- 外科急腹癥患者術(shù)后護(hù)理
- 顧客管理課件
- 廠房分布式光伏系統(tǒng)施工進(jìn)度計(jì)劃橫道圖
- 社會(huì)工作流程圖
- 人工智能方法在土木工程監(jiān)測中的運(yùn)用
- 高效溝通之溝通的意義在于回應(yīng)
- 第五講柔性夾具
- 北京東城二中分校高一分班考試數(shù)學(xué)試題
- 周三多管理學(xué)5版課后答案
- 倫敦三一口語GESE3級(jí)內(nèi)部講義
- 1IEC62660-1中文電動(dòng)道路車輛用二次鋰離子蓄電池鋰離子電池性能試驗(yàn)
- HPE 3PAR8400、HPE 3000B SAN Switch安裝及維護(hù)手冊
- 汽輪機(jī)廠工業(yè)驅(qū)動(dòng)技術(shù)介紹
評(píng)論
0/150
提交評(píng)論