www.pudn.com > watermarking-with-Hus-moments.rar > guiproj.m, change:2015-06-28,size:9695b


function varargout = guiproj(varargin)
% GUIPROJ MATLAB code for guiproj.fig
%      GUIPROJ, by itself, creates a new GUIPROJ or raises the existing
%      singleton*.
%
%      H = GUIPROJ returns the handle to a new GUIPROJ or the handle to
%      the existing singleton*.
%
%      GUIPROJ('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUIPROJ.M with the given input arguments.
%
%      GUIPROJ('Property','Value',...) creates a new GUIPROJ or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before guiproj_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to guiproj_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 guiproj

% Last Modified by GUIDE v2.5 28-Jun-2015 16:58:51

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @guiproj_OpeningFcn, ...
                   'gui_OutputFcn',  @guiproj_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 guiproj is made visible.
function guiproj_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 guiproj (see VARARGIN)

% Choose default command line output for guiproj
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes guiproj wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = guiproj_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)
global f;
global c;
global s2;

clc;
set(handles.uipanel2,'Visible','off');
set(handles.uipanel3,'Visible','off');
[filename,pathname]=uigetfile('*','select file');

f=imread([pathname,filename]);
f=imresize(f,[400 400]);
image(f,'parent',handles.axes1);
axes(handles.axes1);
axis off;
F=ipl_find_circle(f);%bedast ovardan bozorgtarin daire tasvir
h=phiforregin(F);c=zeros(1,7);
maxh=max(h);minh=min(h); 
for i=1:7
    c(i)=floor(((h(i)-minh)/(maxh-minh))*400);
    
end
H=zeros(7,7);

for i=1:7
    H1 = phiforregin((calcir(f,c(i))));
    H(i,:)=H1;
end

C=bitget(h,1);
S=bitget(H,1);
s2=zeros(7,7);
for i=1:7
s2(i,:)=bitxor(C,S(i,:));
end
dd = imresize(s2, 10, 'nearest');
image(dd,'parent',handles.axes5);
axes(handles.axes5);
imshow(dd)
axis off;


% --- 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 f;
global c;

I=f;
I=imresize(I,[400 400]);
t = graythresh(I); 
BW = im2bw(I, t); 

% Step 2: Leave just "big" components on binary image
[L, num] = bwlabel(BW); 
stats = regionprops(L, 'Area', 'PixelIdxList');
area_vector = [stats(:).Area];
area_vector = sort(area_vector);
threshold_pos = floor(num * 0.98);
threshold = area_vector(threshold_pos);

for i=1:num
    if(stats(i).Area < threshold)
        BW(stats(i).PixelIdxList) = false;
    end
end

% Step 3: Dilate image with a circle of small radius
str = strel('disk', 7); 
BW = imdilate(BW, str); 

% Step 4: Take component with biggest area as the circle
L = bwlabel(BW); 
stats = regionprops(L, 'Area', 'BoundingBox', 'Centroid', 'EquivDiameter');
area_vector = [stats(:).Area];
[max_value, max_idx] = max(area_vector);
soi = stats(max_idx);

% Set output variable
circle = imcrop(I, soi.BoundingBox);

% Display results
% radius = soi.EquivDiameter/2;
radius = 80;
N = 1000;
theta = linspace(0, 2*pi, N);
rho = ones(1, N) * radius;
[X,Y] = pol2cart(theta, rho);
X1 = c(1) - X;
Y1 = c(1) - Y;
X2 = c(2) - X;
Y2 = c(2) - Y;
X3 = c(3) - X;
Y3 = c(3) - Y;
X4 = c(4) - X;
Y4 = c(4) - Y;
X5 = c(5) - X;
Y5 = c(5) - Y;
X6 = c(6) - X;
Y6 = c(6) - Y;
X7 = c(7) - X;
Y7 = c(7) - Y;
image(I,'parent',handles.axes3);
axes(handles.axes3);
axis off;
hold on;
plot(X1, Y1, '-r', 'LineWidth', 2);
hold on;
plot(X2, Y2, '-r', 'LineWidth', 2);
hold on;
plot(X3, Y3, '-r', 'LineWidth', 2);hold on;
plot(X4, Y4, '-r', 'LineWidth', 2);hold on;
plot(X5, Y5, '-r', 'LineWidth', 2);hold on;
plot(X6, Y6, '-r', 'LineWidth', 2);hold on;
plot(X7, Y7, '-r', 'LineWidth', 2);



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 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)


% --- Executes on button press in pushbutton4.
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)
global f;
global c;
global s2;
m=cat(1,s2,s2,s2,s2,s2,s2,s2,s2,s2);
n=cat(2,m,m);
message = char(get(handles.edit1,'String'));
L = length(message);
u = zeros(1,L);
 f(200,200) = L;
for i=1:L
    u(i) = abs(message(i));
end
if(L<=80)
  for i=1:L
        for j=1:8
         k=bitget(u(i),j);
         p=bitget(n(i,j),1);
        g= bitxor(k,p);
       if g == 0
         f(c(4)+i,j)= bitset(f(c(4)+i,j),1,0);
       else 
             f(c(4)+i,j)= bitset(f(c(4)+i,j),1,1);
       end
        end
  end
            else
    set(handles.edit1,'String','  ѐ ');  
end

imwrite(f,'output.bmp','bmp');
image(f,'parent',handles.axes4);
axes(handles.axes4);
axis off;

% Display filename under image
set(handles.text1,'String','output.bmp');


% --- 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)
global f;
type=f(100,200);
if (type==2)
f=flipdim(f,2);
end
if (type==3)
f=imrotate(f,-90,'bilinear');
end
L=f(200,200) ;
F=ipl_find_circle(f);%bedast ovardan bozorgtarin daire tasvir
h=phiforregin(F);

c=zeros(1,7);
maxh=max(h);minh=min(h); 
for i=1:7
    c(i)=floor(((h(i)-minh)/(maxh-minh))*400);
    
end
H=zeros(7,7);
for i=1:7
    H1 = phiforregin((calcir(f,c(i))));
    H(i,:)=H1;
end

C=bitget(h,1);
S=bitget(H,1);
s2=zeros(7,7);
for i=1:7
s2(i,:)=bitxor(C,S(i,:));
end
m=cat(1,s2,s2,s2,s2,s2,s2,s2,s2,s2);
n=cat(2,m,m);
u = zeros(1,L);
if(L<=80)
for i=1:L
   for j=1:8
       v = bitget(f(c(4)+i,j),1);
       if (v == 1)
           if(n(i,j)==1)
           u(i) = bitset(u(i),j,0);
       else
           u(i) = bitset(u(i),j,1);
           end
       elseif(n(i,j)==1)
           u(i) = bitset(u(i),j,1);
       else
           u(i) = bitset(u(i),j,0);
       end
       
   end
end

else
    set(handles.text2,'String','error');
  
end
set(handles.text2,'String',char(u));


% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.uipanel2,'Visible','on');

% --- 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)
set(handles.uipanel3,'Visible','on');