A list,
Automatic target system based on MATLAB GUI
Ii. Source code
function varargout = shoot_system(varargin)
% SHOOT_SYSTEM M-file forShoot_system. FIG % military target system main function gui_Singleton =1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @shoot_system_OpeningFcn, ...
'gui_OutputFcn', @shoot_system_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
function shoot_system_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject; guidata(hObject, handles); Function varargout = shoot_system_OutputFcn(hObject, eventData, handles) varargout{function varargout = shoot_system_OutputFcn(hObject, eventData, handles) varargout{1} = handles.output; % -- Load image, this target image has no bullet marksfunction pushbutton1_Callback(hObject, eventdata, handles)
global before
global num
num=0;
B=imread('b1.jpg'); axes(handles.axes1); imshow(B) before=B; % -- In image processing, noise removal, center coordinates and detection of each target ring interval.function pushbutton2_Callback(hObject, eventdata, handles)
global before
global rc
global x_center
global y_center
global lamda
J=double(im2bw(before,0.5));
J=medfilt1(J,4);
B=[0 1 0;1 1 1;1 0 1];
A=imdilate(J,B);
[x,y]=size(A);
[L,m] = bwlabel(A,8);
zuobiao=zeros(m,2);
n=1;
for i=1:m [r,c] = find(L==i); rc=[r c]; a1=max(r); a2=min(r); a=a1-a2; % r1 = a /2;
test1=(a1+a2)/2; b1=max(c); b2=min(c); b=b1-b2; % r2 = b /2;
test2=(b1+b2)/2;
deta=abs(b-a); % if(deta/((a+b)/2) <1/100 && (a1-a2)/x<0.8)
zuobiao(n,1)=test1;
zuobiao(n,2)=test2;
banjing(n,1)=r1;
banjing(n,2)=r2;
n=n+1;
end
end
n=n- 1;
x_count=0;
y_count=0;
for j=1:n
x_count=x_count+zuobiao(j,1);
y_count=y_count+zuobiao(j,2);
end
x_center=x_count/n;
y_center=y_count/n;
banjing_1=zeros(1,n);
for i=1:n
banjing_1(i)=(banjing(i,1)+banjing(i,2)) /2;
end
banjing_2=sort(banjing_1);
count=0;
for i=1:(n- 1)
count=count+abs(banjing_2(i)-banjing_2(i+1));
end
lamda=count/(n- 1);
msgbox('Done! '-- Simulation of target shooting, the method is to have bullet point image superimposed on the source imagefunction pushbutton3_Callback(hObject, eventdata, handles)
global num
global after
num=num+1;
NUM=7;
for i=1:NUM
switch num
case{1}
after=imread('b2.jpg');
axes(handles.axes1);
imshow(after);
break
case{2}
after=imread('b3.jpg');
axes(handles.axes1);
imshow(after);
break
case{3}
after=imread('b4.jpg');
axes(handles.axes1);
imshow(after);
break
case{4}
after=imread('b5.jpg');
axes(handles.axes1);
imshow(after);
break
case{5}
after=imread('b6.jpg');
axes(handles.axes1);
imshow(after);
break
case{6}
after=imread('b7.jpg');
axes(handles.axes1);
imshow(after);
break
case{7}
after=imread('b8.jpg');
axes(handles.axes1);
imshow(after);
end
end
Copy the code
3. Operation results
Fourth, note
Version: 2014 a