function varargout = work(varargin)
% WORK MATLAB code for work.fig
% WORK, by itself, creates a new WORK or raises the existing
% singleton*.
%
% H = WORK returns the handle to a new WORK or the handle to
% the existing singleton*.
%
% WORK('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in WORK.M with the given input arguments.
%
% WORK('Property','Value',...) creates a new WORK or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before work_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to work_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help work
% Last Modified by GUIDE v2.5 25-May-2015 01:00:55
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @work_OpeningFcn, ...
'gui_OutputFcn', @work_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before work is made visible.
function work_OpeningFcn(hObject, eventdata, 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)
% varargin command line arguments to work (see VARARGIN)
% Choose default command line output for work
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes work wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = work_OutputFcn(hObject, eventdata, 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 GUIDATA)
% Get default command line output from handles structure
%设置背景
varargout{1} = handles.output;
backgroundImage = importdata('background3.jpg');
axes(handles.axes4);
image(backgroundImage);
axis off;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes3);
I=getimage;
I=double(I)/255;
global val;
w = 5; % bilateral filter half-width
sigma = [3 val]; % bilateral filter standard deviations
I1=bfilter2(I,w,sigma);
axes(handles.axes2);
imshow(I1);
guidata(hObject,handles);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% 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)
axes(handles.axes3);
im=getimage;
im1=rgb2ycbcr(im);%将图片的RGB值转换成YCbCr值%
Lu=im1(:,:,1);
Cb=im1(:,:,2);
Cr=im1(:,:,3);
[x y z]=size(im);
tst=zeros(x,y);
%计算Cb、Cr的均值Mb、Mr%
Mb=mean(mean(Cb));
Mr=mean(mean(Cr));
%计算Cb、Cr的均方差%
Db=sum(sum(Cb-Mb))/(x*y);
Dr=sum(sum(Cr-Mr))/(x*y);
%根据阀值的要求提取出near-white区域的像素点%
cnt=1;
for i=1:x
for j=1:y
b1=Cb(i,j)-(Mb+Db*sign(Mb));
b2=Cr(i,j)-(1.5*Mr+Dr*sign(Mr));
if (b1<abs(1.5*Db) & b2<abs(1.5*Dr))
Ciny(cnt)=Lu(i,j);
tst(i,j)=Lu(i,j);
cnt=cnt+1;
end
end
end
cnt=cnt-1;
iy=sort(Ciny,'descend');%将提取出的像素点从亮度值大的点到小的点依次排列%
nn=round(cnt/10);
Ciny2(1:nn)=iy(1:nn);%提取出near-white区域中10%的亮度值较大的像素点做参考白点%
%提取出参考白点的RGB三信道的值%
mn=min(Ciny2);
for i=1:x
for j=1:y
if tst(i,j)<mn
tst(i,j)=0;
else
tst(i,j)=1;
end
end
end
R=im(:,:,1);
G=im(:,:,2);
B=im(:,:,3);
R=double(R).*tst;
G=double(G).*tst;
B=double(B).*tst;
%计算参考白点的RGB的均值%
Rav=mean(mean(R));
Gav=mean(mean(G));
Bav=mean(mean(B));
global val2;
Ymax=double(max(max(Lu)))*val2;%计算出图片的亮度的最大值%
%计算出RGB三信道的增益%
Rgain=Ymax/Rav;
Ggain=Ymax/Gav;
Bgain=Ymax/Bav;
%通过增益调整图片的RGB三信道%
im(:,:,1)=im(:,:,1)*Rgain;
im(:,:,2)=im(:,:,2)*Ggain;
im(:,:,3)=im(:,:,3)*Bgain;
axes(handles.axes2);
imshow(im);
guidata(hObject,handles);
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
global val;
val=get(hObject,'Value');
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
set(hObject,'Value',0.2);
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider2 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
global val2;
val2=get(hObject,'Value');
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
set(hObject,'Value',0.1);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes3);
img=getimage;
img_r=img(:,:,1);
img_g=img(:,:,2);
img_b=img(:,:,3);l
[m,n]=size(img_r);
Rave=sum(sum(img_r));
Rave=Rave/(m*n);
Gave=sum(sum(img_g));
Gave=Gave/(m*n);
Bave=sum(sum(img_b));
Bave=Bave/(m*n);
Rave=mean(mean(img_r));
Gave=mean(mean(img_g));
Bave=mean(mean(img_b));
Kave=(Rave+Gave+Bave)/3;
img_R=(Kave/Rave)*img_r;
img_G=(Kave/Gave)*img_g;
img_B=(Kave/Bave)*img_b;
img_gw=cat(3,img_R,img_G,img_B);
axes(handles.axes2);% 显示图片
imshow(img_gw);
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata
- 1
- 2
- 3
前往页