function varargout = ImageMark(varargin)
% IMAGEMARK MATLAB code for ImageMark.fig
% IMAGEMARK, by itself, creates a new IMAGEMARK or raises the existing
% singleton*.
%
% H = IMAGEMARK returns the handle to a new IMAGEMARK or the handle to
% the existing singleton*.
%
% IMAGEMARK('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in IMAGEMARK.M with the given input arguments.
%
% IMAGEMARK('Property','Value',...) creates a new IMAGEMARK or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ImageMark_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ImageMark_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 ImageMark
% Last Modified by GUIDE v2.5 17-Apr-2021 22:57:16
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ImageMark_OpeningFcn, ...
'gui_OutputFcn', @ImageMark_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 ImageMark is made visible.
function ImageMark_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 ImageMark (see VARARGIN)
% Choose default command line output for ImageMark
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes ImageMark wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = ImageMark_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)
[filename, pathname] = uigetfile('G:\作业\数字版权与信息安全\实验\实验项目\*.bmp', '选择水印');
file = fullfile(pathname, filename);
img = imread(file);
axes(handles.axes1);
imshow(img);
% --- 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)
size=256; block=8; I_W=zeros(size);
I=imread('me6.jpg');
I=double(I)/256;
W=imread('water2.bmp');
%嵌入水印
for p=1:size/block
for q=1:size/block
x=(p- 1)*block+1;
y=(q- 1)*block+1;
block_dct=I(x:x+block- 1, y:y+block- 1);
block_dct=dct2(block_dct);
if W(p, q)==0
a=- 1;
else
a=1;
end
block_dct(1, 1)=block_dct(1, 1)*(1+a*0.01);
block_dct=idct2(block_dct);
I_W(x:x+block- 1, y:y+block- 1)=block_dct;
end
end
%显示嵌入水印后的图像
axes(handles.axes3);
imshow(I_W);
function pushbutton4_Callback(hObject, eventdata, handles)
% 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)
size=256; block=8; I_W=zeros(size);
I=imread('me6.jpg');
I=double(I)/256;
W=imread('water2.bmp');
%嵌入水印
for p=1:size/block
for q=1:size/block
x=(p- 1)*block+1; y=(q- 1)*block+1;
block_dct=I(x:x+block- 1, y:y+block- 1);
block_dct=dct2(block_dct);
if W(p, q)==0
a=- 1;
else
a=1;
end
block_dct(1, 1)=block_dct(1, 1)*(1+a*0.01);
block_dct=idct2(block_dct);
I_W(x:x+block- 1, y:y+block- 1)=block_dct;
end
end
%提取水印
for p=1:size/block
for q=1:size/block
x=(p- 1)*block+1; y=(q- 1)*block+1;
if (I_W(x, y)- I(x, y))>0
F(p, q)=1;
else
F(p, q)=0;
end
end
end
axes(handles.axes4);
imshow(F)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, 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)
[filename,pathname]=uigetfile('G:\作业\数字版权与信息安全\实验\实验项目\*.jpg', '选择图片');
file=fullfile(pathname,filename);
img=imread(file);
axes(handles.axes2);
imshow(img);
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global player_audio;
global Fs;
Fs = 44100;
[filename,pathname]=uigetfile({'*.wav'},'选择音频');
file=[pathname filename];
audio=audioread(file);
axes(handles.axes8);
plot(audio);
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.bmp'}, '选择水印');
file = fullfile(pathname, filename);
img = imread(file);
axes(handles.axes9);
imshow(img);
m=audioread('me_01.wav');%读取音频文件 m.wav
L=size(m);
p=imread('water2.bmp');
pw=im2bw(p);%将原始灰度图像转换为二值图像
imshow(pw);%显示该二值图像
size(pw)
m1=32;
m2=32;%统计水印二值图像的行列数据位数
%音频信号分段处理, 用于嵌入水印的音频数据部分等分成
% (m1*m2)个音频数据段
n=10;
length=m1*m2*n;
i=1:length;
j=(1);
me=m(i,j);
i=length+1:L;
mr=m(i,j);
k=1;
B=cell(m1*m2,1);%建立元胞 B
while(k<m1*m2*n)
i=k:(k+9);
s=(k+9)/10;
B{s,1}=me(i,j);
k=k+10;
end
%水印二值图像(pw)降维处理
C=reshape(pw,1,m1*m2);
%将水印嵌入数字音频信号中
D=cell(m1*m2,1);
for i=1:m1*m2
D{i,1}=dct(B{i,1});%离散余弦变换
end
E=cell(m1*m2,1);
E=D;
for i=1:m1*m2
E{i,1}(3)=D{i,1}(3)*(1+2*C(i));
end
F=cell(m1*m2,1);
for i=1:m1*m2
F{i,1}=idct(E{i,1}); %离散余弦逆变换
end
G=[F{1,1};F{2,1}];
for i=3:m1*m2
G=[G;F{i,1}];
end
G=[G;mr];%获得嵌入水印的数字音频信号
%采用适当带通滤波显示加水印前后音频信号的波形图比较,并
% 回放比较声音质量
axes(handles.axes10);
plot(G);
- 1
- 2
- 3
- 4
前往页