Tải bản đầy đủ - 0 (trang)
2 Nội dung chương trình

2 Nội dung chương trình

Tải bản đầy đủ - 0trang

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

function select_image_OpeningFcn(hObject, eventdata, handles, varargin)

%chon anh de nen

handles.name='Y'

Y=handles.name

handles.Y=handles.name;

%chon phuong phap nen

handles.meth='X'

X=handles.meth;

handles.X= handles.meth;

handles.output = hObject;

guidata(hObject, handles);

function varargout = select_image_OutputFcn(hObject, eventdata, handles)

varargout{1} = handles.output;

function pushbutton1_Callback(hObject, eventdata, handles)

%lựa chọn anh đầu vào

name=uigetfile('*.png','select_image');

handles.name=name

handles.Y=imread(handles.name);

set(handles.text7,'visible','off');

subplot(2,2,1); axis off; colormap gray(255);imagesc(handles.Y);

title('anh goc');

I=imread(handles.name);

hist(handles.axes1,double(I));

guidata(hObject, handles);

function pushbutton2_Callback(hObject, eventdata, handles)

%meth = 'ezw';

%Nén anh với 2 thuật toán EZW và SPIHT

val1=get(handles.edit1,'string')

val1=str2num(val1);

wname = 'haar';

nbloop = val1;



51



[CR,BPP] = wcompress('c',handles.name,'mask.wtc',handles.meth,'maxloop', nbloop,

'wname',wname);

Yc = wcompress('u','mask.wtc');

subplot(2,2,2); axis off; colormap gray(255);imagesc(Yc);

title('anh da nen');

xlabel({['Compression Ratio: ' num2str(CR,'%1.2f %%')],['BPP: '

num2str(BPP,'%3.2f')]})

set(handles.edit2,'string',BPP);

set(handles.edit3,'string',CR);

Y=imread(handles.name);

D = abs(double(Y)-double(Yc)).^2;

mse = sum(D(:))/numel(Y)

psnr = 10*log10(255*255/mse)

set(handles.edit4,'string',psnr);

hist(handles.axes2,Yc);

function edit1_Callback(hObject, eventdata, handles)

function edit1_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'),

get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

function uipanel1_CreateFcn(hObject, eventdata, handles)

function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)

%lựa chọn các thuật toán

switch get(eventdata.NewValue,'tag')

case 'radiobutton1'

handles.meth='ezw'

case 'radiobutton2'

handles.meth='spiht'

end

guidata(hObject, handles);



function edit2_Callback(hObject, eventdata, handles)

function edit2_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'),

get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

function edit3_Callback(hObject, eventdata, handles)

function edit3_CreateFcn(hObject, eventdata, handles)



52



if ispc && isequal(get(hObject,'BackgroundColor'),

get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end



function edit4_Callback(hObject, eventdata, handles)

function edit4_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'),

get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end.

function pushbutton3_Callback(hObject, eventdata, handles)

%Biến đổi wavelet

n = 256; Jmin = 1;

I = load_image('lena');

open('biendoi_wavelet.fig');

% 2D wavelet transform

Iw = perform_wavelet_transform(I,Jmin,+1); % computation until scale Jmin

clf;

subplot(3,3,1);

imagesc(I); axis image; axis off; colormap gray(256); title('anh goc');

subplot(3,3,2);

plot_wavelet(Iw, Jmin); colormap gray(256); title('bien doi voi Jmin=1');

Jmin=2;

Iw1=perform_wavelet_transform(I,Jmin,+1);

subplot(3,3,3);

plot_wavelet(Iw1, Jmin); colormap gray(256); title('bien doi voi Jmin=2');

Jmin=3;

Iw2=perform_wavelet_transform(I,Jmin,+1);

subplot(3,3,4);

plot_wavelet(Iw2, Jmin); colormap gray(256); title('bien doi voi Jmin=3');

Jmin=4;

Iw4=perform_wavelet_transform(I,Jmin,+1);

subplot(3,3,5);

plot_wavelet(Iw4, Jmin); colormap gray(256); title('bien doi voi Jmin=4');

Jmin=5;

Iw5=perform_wavelet_transform(I,Jmin,+1);

subplot(3,3,5);

plot_wavelet(Iw5, Jmin); colormap gray(256); title('bien doi voi Jmin=5');

Jmin=6;

Iw6=perform_wavelet_transform(I,Jmin,+1);

subplot(3,3,6);

53



plot_wavelet(Iw6, Jmin); colormap gray(256); title('bien doi voi Jmin=6');

Jmin=7;

Iw7=perform_wavelet_transform(I,Jmin,+1);

subplot(3,3,7);

plot_wavelet(Iw7, Jmin); colormap gray(256); title('bien doi voi Jmin=7');

Jmin=8;

Iw8=perform_wavelet_transform(I,Jmin,+1);

subplot(3,3,8);

plot_wavelet(Iw8, Jmin); colormap gray(256); title('bien doi voi Jmin=8');

function text7_CreateFcn(hObject, eventdata, handles).

function pushbutton4_Callback(hObject, eventdata, handles)

exit

function pushbutton5_Callback(hObject, eventdata, handles)

% khao nghiệm với anh Lena.png

open('khao_nghiem.fig');

A=[0.0025 0.004 0.0095 0.024 0.057 0.134 0.23 0.61 1.18 2.21];

B=[16.42 18.24 20.2 22.4 24.81 27.45 30.47 33.82 37.34 41.15];

subplot(1,2,1);

axis square

plot(A,B);

xlabel('BPP')

ylabel('PSNR');

title('PHUONG PHAP SPIHT');

C=[0.0064 0.014 0.034 0.084 0.192 0.44 0.91 1.76 3.26 5.24];

D=[18.5 20.5 22.73 25.22 27.94 31.09 34.57 38.15 41.96 44.63];

subplot(1,2,2);axis square;

plot(C,D);

xlabel('BPP');

ylabel('PSNR');

title('PHUONG PHAP EZW');



54



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

2 Nội dung chương trình

Tải bản đầy đủ ngay(0 tr)

×