




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上基于matlab 的HSV陰影消除代碼,畢設(shè)所用,用完貢獻(xiàn)先給代碼 后有說明function varargout = untitled(varargin)% UNTITLED M-file for untitled.fig% UNTITLED, by itself, creates a new UNTITLED or raises the existing% singleton*.% H = UNTITLED returns the handle to a new UNTITLED or the handle to% the existing singleton*.%
2、 UNTITLED(CALLBACK,hObject,eventData,handles,.) calls the local% function named CALLBACK in UNTITLED.M with the given input arguments.% UNTITLED(Property,Value,.) creates a new UNTITLED or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before un
3、titled_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to untitled_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIH
4、ANDLES% Edit the above text to modify the response to help untitled% 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_Singleton, gui_Singleton, . gui_OpeningFcn, untitled_OpeningFcn, . gui_OutputF
5、cn, untitled_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 gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes j
6、ust before untitled is made visible.function untitled_OpeningFcn(hObject, , handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% va
7、rargin command line arguments to untitled (see VARARGIN)% Choose default command line output for untitledhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes untitled wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function
8、are returned to the command line.function varargout = untitled_OutputFcn(, , handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDA
9、TA)% Get default command line output from handles structurevarargout1 = handles.output;% - Executes on button press in pushbutton1.function pushbutton1_Callback(, , )handles=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,i
10、w,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)置直接用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),i
11、mshow(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,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
12、 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(ok);title(提取前景圖像); % %第三幅 前景圖count2=count2*1.25;e1=num2str(count2);sc=共,e1;sc=sc,點(diǎn);set(handles.text16,String,sc);g=rgb2hsv(mea
13、n); % 將背景圖像由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(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(a
14、i,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),imshow(BHuidu);title(提取前景圖像); % %第三幅 前景圖%figure,imshow(QHuidu);%figure,imshow(BHuidu);Yyu=double(QHuidu(:,:,1)-double(BHuidu(:,:
15、,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);YUVhecheng=Uyu;Q=(UVErzhihua=1)&(YErzhihua=1); %Y分量和UV分量的圖像合成YUVhecheng(Q)=1;Q=(UVErzhihua=0)|(YErzhihua=0);YUVhecheng(Q)=
16、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(YUV陰影消除);% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% h
17、andles structure with handles and user data (see GUIDATA)% - Executes on button press in pushbutton3.function pushbutton3_Callback(, , )clc;close all;close(gcf);clear;% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with
18、handles and user data (see GUIDATA)ai% - Executes on button press in pushbutton4.function pushbutton4_Callback(, , )h1=figure(toolbar,none,name,Shadow Removal); % 讀取受損圖像FileName,PathName=uigetfile( *.avi,avi (*.avi);*.*,All Files (*.*),Open video sequence );if isequal(FileName,PathName,0,0) return;e
19、lse 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 fn;%fn=11; % hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% h
20、andles 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 of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of edi
21、t1 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, , )% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty
22、 - 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 edit2_Callback(hObjec
23、t, , 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)% Hints: get(hObject,String) returns contents of edit2 as text% str2double(get(hObject,String) returns contents of edit2 as a
24、 doubleinput = str2num(get(hObject,String);if (isempty(input) set(hObject,String,11)endguidata(hObject, handles) % - Executes during object creation, after setting all properties.function edit2_CreateFcn(hObject, , )% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future
25、 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);
26、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 version of MATLAB% handles structure with handles and user data (see GUIDATA)global fn;global e;e=num2str(e);sc=共,e;sc=s
27、c,幀;%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 handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles
28、 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 edit3 as text% str2double(get(hObject,String) returns contents of edit3 as a double% - Executes during object creation,
29、 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 empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Win
30、dows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction edit4_Callback(hObject, , handles)% hObject handle to edit4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB%
31、 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 edit4 as text% str2double(get(hObject,String) returns contents of edit4 as a double% - E
32、xecutes during object creation, after setting all properties.function edit4_CreateFcn(hObject, , )% hObject handle to edit4 (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
33、 have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction edit5_Callback(hObject, , handles)% hObject handle to edit5 (see GCBO)% eventdata reserved - to be defined
34、 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(hObject, handles)% Hints: get(hObject,String) returns contents of edit5 as text% str2double(get(hObject,String) returns con
35、tents of edit5 as a double% - Executes during object creation, after setting all properties.function edit5_CreateFcn(hObject, , )% hObject handle to edit5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns call
36、ed% 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 edit6_Callback(hObject, , handles)% hObject handle to edit6 (see GCBO)% eve
37、ntdata 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,0.32)endguidata(hObject, handles)% Hints: get(hObject,String) returns contents of edit6 as text% str2doub
38、le(get(hObject,String) returns contents of edit6 as a double% - Executes during object creation, after setting all properties.function edit6_CreateFcn(hObject, , )% hObject handle 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 button press in push
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(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)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 山西省忻州市部分學(xué)校2025屆九年級(jí)下學(xué)期中考二模數(shù)學(xué)試卷(含解析)
- 疼痛醫(yī)療服務(wù)行業(yè)行業(yè)痛點(diǎn)與創(chuàng)新解決方案案例分析報(bào)告
- 2025年工業(yè)污染場地修復(fù)技術(shù)選擇與成本效益評(píng)估與政策實(shí)施效果報(bào)告
- 醫(yī)藥流通行業(yè)供應(yīng)鏈成本控制與可持續(xù)發(fā)展研究
- 2025年新能源汽車廢舊電池回收利用產(chǎn)業(yè)技術(shù)創(chuàng)新趨勢(shì)預(yù)測與市場前景分析報(bào)告
- 綠色轉(zhuǎn)型對(duì)資源型城市生態(tài)環(huán)境保護(hù)的推動(dòng)與影響報(bào)告
- 零售私域流量運(yùn)營實(shí)戰(zhàn)技巧與用戶忠誠度管理報(bào)告
- 食品飲料包裝行業(yè)可持續(xù)發(fā)展目標(biāo)與路徑規(guī)劃報(bào)告
- 2025年環(huán)境影響評(píng)價(jià)公眾參與機(jī)制與環(huán)境保護(hù)公眾參與效果評(píng)估指標(biāo)體系創(chuàng)新報(bào)告
- 2025年四川省德陽市中考理綜物理試題【含答案、解析】
- 房顫的規(guī)范化治療
- 2024-2030年中國伊利石行業(yè)經(jīng)銷模式及競爭策略展望分析報(bào)告版
- 二位數(shù)乘二位數(shù)的計(jì)算題50道
- 2024高速養(yǎng)護(hù)工區(qū)標(biāo)準(zhǔn)化建設(shè)指南
- 【課件】動(dòng)詞的時(shí)態(tài)、語態(tài)和主謂一致 課件-2025屆高三英語上學(xué)期一輪復(fù)習(xí)專項(xiàng)
- 小學(xué)生常用急救知識(shí)課件
- 物業(yè)服務(wù)外包合同
- 企業(yè)注銷登記申請(qǐng)書(適用于公司、非公司企業(yè)法人、合伙企業(yè)、個(gè)人獨(dú)資企業(yè))
- NBT 33015-2014 電化學(xué)儲(chǔ)能系統(tǒng)接入配電網(wǎng)技術(shù)規(guī)定
- 《人工智能導(dǎo)論》(第2版)高職全套教學(xué)課件
- GB/T 44260-2024虛擬電廠資源配置與評(píng)估技術(shù)規(guī)范
評(píng)論
0/150
提交評(píng)論