function varargout = images_improve(varargin)
% IMAGES_IMPROVE MATLAB code for images_improve.fig
% IMAGES_IMPROVE, by itself, creates a new IMAGES_IMPROVE or raises the existing
% singleton*.
%
% H = IMAGES_IMPROVE returns the handle to a new IMAGES_IMPROVE or the handle to
% the existing singleton*.
%
% IMAGES_IMPROVE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in IMAGES_IMPROVE.M with the given input arguments.
%
% IMAGES_IMPROVE('Property','Value',...) creates a new IMAGES_IMPROVE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before images_improve_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to images_improve_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 images_improve
% Last Modified by GUIDE v2.5 31-Jul-2021 12:04:03
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @images_improve_OpeningFcn, ...
'gui_OutputFcn', @images_improve_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 images_improve is made visible.
function images_improve_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 images_improve (see VARARGIN)
% Choose default command line output for images_improve
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes images_improve wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = images_improve_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;
% --- 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)
global site
Img = double(imread(site)); %读取路径下的图片
Hh =double(imguidedfilter(uint8(Img))) - Img + 128;
Gg = imfilter(Hh,fspecial('gaussian',[3 3],100));
opacity = 175;
Best = (Img*(100 - opacity)+(Img+2*Gg - 256)*opacity)/100;
imgG = uint8(Best);
img1=rgb2ycbcr(imgG);%转换成YCbCr值
YYY=img1(:,:,1);
CbB=img1(:,:,2);
CrR=img1(:,:,3);
[x y z]=size(imgG);
tst=zeros(x,y);
mb=mean(mean(CbB));
mr=mean(mean(CrR));
%计算均方差
Tb = CbB-mb;
Tr = CrR-mr;
Db=sum(sum((Tb).*(Tb)))/(x*y);
Dr=sum(sum((Tr).*(Tr)))/(x*y);
%根据像素点
cnt=1;
for i=1:x
for j=1:y
b1=CbB(i,j)-(mb+Db*sign(mb));
b2=CrR(i,j)-(1.5*mr+Dr*sign(mr));
if (b1<abs(1.5*Db) && b2<abs(1.5*Dr))
Ciny(cnt)=YYY(i,j);
tst(i,j)=YYY(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);
%提取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=imgG(:,:,1);
Gg=imgG(:,:,2);
B=imgG(:,:,3);
R=double(R).*tst;
Gg=double(Gg).*tst;
B=double(B).*tst;
%计算白点的RGB的均值
Rav=mean(mean(R));
Gav=mean(mean(Gg));
Bav=mean(mean(B));
Ymax=double(max(max(YYY)))*0.12;%亮度的最大值
%计算出RGB三信道的增益
Rgain=Ymax/Rav;
Ggain=Ymax/Gav;
Bgain=Ymax/Bav;
%通过增益调整图片的RGB三信道
imgG(:,:,1)=imgG(:,:,1)*Rgain;
imgG(:,:,2)=imgG(:,:,2)*Ggain;
imgG(:,:,3)=imgG(:,:,3)*Bgain;
axes(handles.axes2);
imshow(imgG);title('美化图'); %名称为美化图
function edit1_Callback(hObject, eventdata, handles)
% 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 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, eventdata, handles)
% 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,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- 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)
global site
I = imread(site); %读取路径下的图片
axes(handles.axes1); %在第一个轴中显示
imshow(I);title('原图'); %图片的名称为原图
function site_Callback(hObject, eventdata, handles)
% hObject handle to site (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 site as text
% str2double(get(hObject,'String')) returns contents of site as a double
global site
site=get(hObject,'String');
% --- Executes during object creation, after setting all properties.
function site_CreateFcn(hObject, eventdata, handles)
% hObject handle to site (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 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)
global site
I = imread(site); %读取路径下的图片
x = rgb2gray(I); %X等于对I进行灰度化
axes(handles.axes2); %将X在第二个轴中显示
imshow(x);title('灰度图'); %名称为灰度图
- 1
- 2
前往页