Datasets
Standard Dataset
WSG_v.1.05 software for neural structure morphometry, including on-chip mapping
- Citation Author(s):
- Submitted by:
- Oleg Gradov
- Last updated:
- Wed, 01/16/2019 - 03:45
- DOI:
- 10.21227/fnrx-3t19
- License:
- Categories:
Abstract
This code was used in some previous our articles, such as:
- A. V. Notchenko and O. V. Gradov. A five-axis arm-manipulator laser system & an algorithm for digital processing of output data for recording and morpho-topological identification of cells and tissue structures. Visualization, Image Processing and Computation in Biomedicine, 2(1), 2013. DOI: 10.1615/VisualizImageProcComputatBiomed.2013005967
- A. V. Notchenko and O. V. Gradov. Elementary morphometric labs-on-a-chip based on hemocytometric chambers with radiofrequency culture identification and relay of spectrozonal histochemical monitoring. Visualization, Image Processing and Computation in Biomedicine, 2(1), 2013. DOI: 10.1615/VisualizImageProcComputatBiomed.2013005968
function varargout = weight_sweep_gui(varargin)
% WEIGHT_SWEEP_GUI M-file for weight_sweep_gui.fig
% WEIGHT_SWEEP_GUI, by itself, creates a new WEIGHT_SWEEP_GUI or raises the existing
% singleton*.
%
% H = WEIGHT_SWEEP_GUI returns the handle to a new WEIGHT_SWEEP_GUI or the handle to
% the existing singleton*.
%
% WEIGHT_SWEEP_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in WEIGHT_SWEEP_GUI.M with the given input arguments.
%
% WEIGHT_SWEEP_GUI('Property','Value',...) creates a new WEIGHT_SWEEP_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before weight_sweep_gui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to weight_sweep_gui_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 weight_sweep_gui
% Last Modified by GUIDE v2.5 16-Oct-2011 12:00:46
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @weight_sweep_gui_OpeningFcn, ...
'gui_OutputFcn', @weight_sweep_gui_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
end
% --- Executes just before weight_sweep_gui is made visible.
function weight_sweep_gui_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% varargin command line arguments to weight_sweep_gui (see VARARGIN)
% Choose default command line output for weight_sweep_gui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes weight_sweep_gui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
set(handles.imag_axes,'xticklabel',[],'xticklabelmode','manual','yticklabel'...
,[],'yticklabelmode','manual','Ticklength',[0 0],'tag','imag_axes');
set(handles.proc_axes,'xticklabel',[],'xticklabelmode','manual','yticklabel'...
,[],'yticklabelmode','manual','Ticklength',[0 0],'tag','proc_axes'...
,'ButtonDownFcn',@SelCon);%,'NextPlot','Replacechildren');
set(hObject,'name','CellCounter v1');
%---------------------------------------------------------
clear global mcount;
global figz;
figz=zoom;
set(figz,'ActionPostCallback',@zoom_callback,'enable','off');
%---------------------------------------------------------
end
% --- Outputs from this function are returned to the command line.
function varargout = weight_sweep_gui_OutputFcn(~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT)
% Get default command line output from handles structure
varargout{1} = handles.output;
end
% --- Executes on slider movement.
%------------------SLIDERS-------------------------------------------------
function red_slider_Callback(~, ~, handles)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
%disp(get(hObject,'value'));
refpic(handles);
end
function red_slider_CreateFcn(hObject, ~, ~)
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
end
function green_slider_Callback(~, ~, handles)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
refpic(handles);
end
function green_slider_CreateFcn(hObject, ~, ~)
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
end
function blue_slider_Callback(~, ~, handles)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
refpic(handles);
end
function blue_slider_CreateFcn(hObject, ~, ~)
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
end
%------------------LISTBOX-------------------------------------------------
function pic_list_Callback(hObject, ~, handles)
% Hints: contents = cellstr(get(hObject,'String')) returns pic_list contents as cell array
% contents{get(hObject,'Value')} returns selected item from pic_list
axes(handles.imag_axes);
selected_position=get(hObject,'value');
names=get(hObject,'string');
imdata=imread([get(handles.folder_edit,'string'),names{selected_position}]);
image(imdata);
set(handles.imag_axes,'xticklabel',[],'yticklabel',[],'Ticklength',[0 0],'userdata',imdata);
title(names{selected_position});
refpic(handles);
end
function pic_list_CreateFcn(hObject, ~, ~)
% Hint: listbox 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
end
%------------------TEXT_EDIT-----------------------------------------------
function folder_edit_Callback(~, ~, ~)
% Hints: get(hObject,'String') returns contents of folder_edit as text
% str2double(get(hObject,'String')) returns contents of folder_edit as a double
end
function folder_edit_CreateFcn(hObject, ~, ~)
% 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
end
%------------------BUTTONS-------------------------------------------------
function scan_button_Callback(hObject,eventdata, handles)
folder_way=get(handles.folder_edit,'string');
if folder_way(end)~='\'
folder_way=[folder_way,'\'];
set(handles.folder_edit,'string',folder_way);
end
direc=dir(folder_way);
names={};
for i=3:length(direc)
temp_var=direc(i).name(end-2:end);
if strcmp(temp_var,'jpg')||strcmp(temp_var,'tif')||strcmp(temp_var,'bmp')||strcmp(temp_var,'png')
names=cat(2,names,{direc(i).name});
end
end
if isempty(names)
return
end
%sorting names array with numerical substrings
for i=1:length(names)
temp_var=[];
for j=1:size(names{i},2)
if (int16(names{i}(j))>=48)&&(int16(names{i}(j))<=57)
temp_var=[temp_var,names{i}(j)];
end
end
num_var(i)=str2double(temp_var);
end
[~,perm]=sort(num_var);
clear num_var temp_var not_var ;
names=names(perm);
set(handles.pic_list,'string',names);
end
function anim_button_Callback(~, ~, handles)
names=get(handles.pic_list,'string');
images=cell(size(names));
for i=1:length(names)
images{i}=imread([get(handles.folder_edit,'string'),names{i}]);
end
axes(handles.imag_axes);
for i=1:12
image(images{i});
set(handles.imag_axes,'xticklabel',[],'yticklabel',[]);
title(names{i});
pause(1/1.5);
end
end
function smoothbtn_Callback(~, ~, ~)
% F = [.05 .1 .05; .1 .4 .1; .05 .1 .05];
% ZC = conv2(ZN,F,'same');
disp('derp_write_a_function');
end
%------------------List----------------------------------------------------
function lvlsld_Callback(hObject, eventdata, handles)
refpic(handles);
end
function lvlsld_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
end
%------------------Falling_List--------------------------------------------
% --- Executes on selection change in contour_width.
function contour_width_Callback(~, ~, handles)
refpic(handles);
end
function contour_width_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
%------------------checkboxes----------------------------------------------
function checkbox1_Callback(hObject, eventdata, handles)
end
%------------------other_functions-----------------------------------------
function refpic(handles)
axes(handles.proc_axes);
names=get(handles.pic_list,'string');
if ~isempty(names)
way=[get(handles.folder_edit,'string'),names{get(handles.pic_list,'value')}];
else
errordlg('Image files most be loaded with SCAN !');
return
end
pic=imread(way);
I = get(handles.red_slider,'value')*pic(:,:,1)+get(handles.green_slider,'value')...
*pic(:,:,2)+get(handles.blue_slider,'value')*pic(:,:,3);
imagesc(max(max(I))-I);hold on;
sli_lvl=double(min(min(I))+(max(max(I))-min(min(I)))*get(handles.lvlsld,'Value'));
%n_sli=get(handles.n_of_slices,'Value');
l_wid=1+(get(handles.contour_width,'value')-1)/2;
if get(handles.lvlsld,'Value')~=0
[conar,conhand]=imcontour(I,[sli_lvl 0]); hold off;
end
set(findobj('type','hggroup'),'linewidth',l_wid);
set(handles.proc_axes,'xticklabel',[],'yticklabel',[],'Ticklength',[0 0],...
'ButtonDownFcn',@SelCon,'xlim',get(handles.imag_axes,'xlim')...
,'ylim',get(handles.imag_axes,'ylim'));
set(handles.proc_axes,'userdata',max(max(I))-I);
set(handles.imag_axes,'tag','imag_axes');
set(handles.proc_axes,'tag','proc_axes');
achpa=allchild(handles.proc_axes);
for i=achpa
set(i,'hittest','off');
end
%set(findobj(gcf,'tag','proc_axes'),'ButtonDownFcn',@SelCon);
% set(handles.slid_value,'string',...
% num2str([get(handles.red_slider,'value'),get(handles.green_slider,'value')...
% ,get(handles.blue_slider,'value')]));
end
function SelCon(obj,~)
%flag=true;
ut_sel=findobj(get(obj,'parent'),'tag','ut_sel');
proc_axes=obj;
if strcmp(get(ut_sel,'state'),'on')
cp=get(proc_axes,'currentpoint');
cp=cp(1,1:2)';
chlist=allchild(findobj('type','hggroup'));
mincon=cell(size(chlist));
mindist=zeros(size(chlist));
for i=1:length(chlist)
mincon{i}=[get(chlist(i),'xdata')';get(chlist(i),'ydata')'];
%mindist(i)=min(min(abs(mincon{i}-cp*ones(1,length(mincon{i})))));
mindist(i)=min(sum((mincon{i}-cp*ones(1,length(mincon{i}))).^2,1));
end
mini=find(mindist==min(mindist));
axes(proc_axes);hold on;
plot(mincon{mini(1)}(1,:),mincon{mini(1)}(2,:),'linewidth',3,...
'color',[0 0 0]);
hold off;
centpoint=mean(mincon{mini}(:,1:end-1),2);
contarea=polyarea(mincon{mini}(1,1:end-1),mincon{mini}(2,1:end-1));
text(centpoint(1),centpoint(2),num2str(contarea),...
'LineWidth',2,'color','white','FontSize',12,...
'parent',proc_axes);
end
end
%------------------Zoom_and_toolbar----------------------------------------
function [flag]=zoom_callback(obj,event_obj)
flag=true;
imaxob=findobj(obj,'tag','imag_axes');
praxob=findobj(obj,'tag','proc_axes');
if strcmp(get(event_obj.Axes,'tag'),'imag_axes')
set(praxob,'xlim',get(event_obj.Axes,'xlim'),'ylim',get(event_obj.Axes,'ylim'));
else
set(imaxob,'xlim',get(event_obj.Axes,'xlim'),'ylim',get(event_obj.Axes,'ylim'));
end
end
function ut_in_OffCallback(~, ~, handles)
global figz
if strcmp(get(figz,'enable'),'on')&&strcmp(get(figz,'direction'),'in')
return
else
set(figz,'enable','off','direction','in');
end
set(handles.imag_axes,'tag','imag_axes');
set(handles.proc_axes,'tag','proc_axes');
end
function ut_in_OnCallback(~, ~, handles)
global figz
set(figz,'enable','on','direction','in');
set(handles.imag_axes,'tag','imag_axes');
set(handles.proc_axes,'tag','proc_axes');
end
function ut_out_OffCallback(~, ~, handles)
global figz
if strcmp(get(figz,'enable'),'on')&&strcmp(get(figz,'direction'),'out')
return
else
set(figz,'enable','off','direction','out');
end
set(handles.imag_axes,'tag','imag_axes');
set(handles.proc_axes,'tag','proc_axes');
end
function ut_out_OnCallback(~, ~, handles)
global figz
set(figz,'enable','on','direction','out');
set(handles.imag_axes,'tag','imag_axes');
set(handles.proc_axes,'tag','proc_axes');
end
function dir_btn_Callback(~, ~, handles)
folder_name = uigetdir(cd);
set(handles.folder_edit,'string',folder_name);
end
function tbbtn_Callback(hObject, eventdata, handles)
if ~isempty(findobj('name','contour information'))
delete(findobj('name','contour information'));
end
if get(handles.lvlsld,'Value')==0
errordlg('select contouring level!');
return
end
tbfg=figure('name','contour information','position',[403 246 840 420],'resizefcn',@figure1_ResizeFcn);
chlist=allchild(findobj(handles.proc_axes,'type','hggroup'));
dat=cell(length(chlist),2);
for i=1:length(chlist)
dat{i,1}=i;
xd=get(chlist(i),'xdata');
yd=get(chlist(i),'ydata');
dat{i,2}=polyarea(xd(1:end-1),yd(1:end-1));
end
columnname={'contour number' , 'area'};
columnformat = {'numeric','numeric'};
columneditable = [false false];
tbhand = uitable(tbfg,'Units','normalized','Position',[.05 .05 .3 .9],...
'Data', dat,'ColumnName', columnname,...
'ColumnFormat', columnformat,...
'ColumnEditable', columneditable,...
'RowName',[],'userdata', dat,...
'CellSelectionCallback',@rscb);
ex=get(tbhand,'extent');
tbpos=get(tbhand,'position');
tbpos(3)=ex(3);%+.028;
set(tbhand,'position',tbpos);
minarhand=uicontrol('tag','ed1','style','edit','units','normalized','position',...
[sum(tbpos([1,3]))+.05 .05 .1 .05],'string','400','callback',@slcb);
maxarhand=uicontrol('tag','ed2','style','edit','units','normalized','position',...
[sum(tbpos([1,3]))+.2 .05 .1 .05],'string','5000','callback',@slcb);
slcb();
miapos=get(minarhand,'position');
%maapos=get(maxarhand,'position');
tpapos=[sum(tbpos([1,3]))+.05 sum(miapos([2,4]))+.05 0 0];
tpapos(3)=(1-tpapos(1)+.025)/2-.05;
tpapos(4)=(1-tpapos(2)-.05);
tiapos=tpapos;
tiapos(1)=sum(tpapos([1,3]))+.025;
tab_proc_axes=axes('xticklabel',[],'xticklabelmode','manual','yticklabel'...
,[],'yticklabelmode','manual','Ticklength',[0 0],'tag','tab_proc_axes'...
,'units','normalized','position',tpapos);
tab_imag_axes=axes('xticklabel',[],'xticklabelmode','manual','yticklabel'...
,[],'yticklabelmode','manual','Ticklength',[0 0],'tag','tab_imag_axes'...
,'units','normalized','position',tiapos);
notcellhand=uicontrol('tag','ncb1','style','pushbutton','units','normalized','position',...
[sum(tbpos([1,3]))+.35 .075 .075 .05],'string','not Cell','callback',@nccb);
isacellhand=uicontrol('tag','icb1','style','pushbutton','units','normalized','position',...
[sum(tbpos([1,3]))+.425 .075 .075 .05],'string','is a Cell','callback',@iccb);
mancellhand=uicontrol('tag','mcb1','style','pushbutton','units','normalized','position',...
[sum(tbpos([1,3]))+.35 .025 .15 .05],'string','manual input','callback',@mccb);
textboxhand=uicontrol('tag','tb1','style','text','units','normalized','position',...
[sum(tbpos([1,3]))+.5 .025 .2 .12],'string','select an option');
%------------------------------------------------------------------------
%------------------------------------------------------------------------
end
function slcb(obj,event_obj)
tbh=findobj(1,'type','uitable');
tbe1=findobj(1,'tag','ed1');
tbe2=findobj(1,'tag','ed2');
%-------------------------------------------
chlist=allchild(findobj(0,'type','hggroup'));
dat=zeros(length(chlist),2);
for i=1:length(chlist)
dat(i,1)=i;
xd=get(chlist(i),'xdata');
yd=get(chlist(i),'ydata');
dat(i,2)=polyarea(xd(1:end-1),yd(1:end-1));
end
%-------------------------------------------
%dat=cell2mat(get(tbh,'userdata'));
tdat=dat(:,2)';
val=[str2double(get(tbe1,'string')) str2double(get(tbe2,'string'))];
mask=(tdat<=val(2))&(val(1)<=tdat);
tdat=tdat(mask);
numr=dat(mask',1);
pcdat=[numr,tdat'];
%cdat=mat2cell(pcdat,ones(1,l),[1 1]);
cdat=num2cell(pcdat);
set(tbh,'data',cdat);
end
function rscb(obj,event_obj)
tab_proc_axes=findobj(get(obj,'parent'),'tag','tab_proc_axes');
tab_imag_axes=findobj(get(obj,'parent'),'tag','tab_imag_axes');
proc_axes=get(findobj(0,'type','hggroup'),'parent');
imag_axes=findobj(0,'tag','imag_axes');
imdat=get(proc_axes,'userdata');
fulimdat=get(imag_axes,'userdata');
imsiz=size(imdat);
h=1.5;
global selrow;
try
selrow=event_obj.Indices(1,1);
catch exception
return
end
dat=cell2mat(get(obj,'data'));
conum=dat(selrow,1);
%------------------------------------------------------------
chlist=allchild(findobj(0,'type','hggroup'));
mycont=chlist(conum);
xd=get(mycont,'xdata');
yd=get(mycont,'ydata');
imbox=[floor(min(xd)) ceil(max(xd)) floor(min(yd)) ceil(max(yd))];
imagesc(imdat,'parent',tab_proc_axes);
axes(tab_proc_axes);
hold on;plot(xd,yd,'color','k','linewidth',2);hold off;
dh=sum(imbox.*[-1 1 0 0]);dv=sum(imbox.*[0 0 -1 1]);
fr=zeros(1,4);
if imbox(1)-h*dh>1
fr(1)=floor(imbox(1)-dh);
else
fr(1)=1;
end
if imbox(2)+h*dh<imsiz(2)
fr(2)=ceil(imbox(2)+dh);
else
fr(2)=imsiz(2);
end
if imbox(3)-h*dv>1
fr(3)=floor(imbox(3)-dv);
else
fr(3)=1;
end
if imbox(4)+h*dv<imsiz(1)
fr(4)=ceil(imbox(4)+dv);
else
fr(4)=imsiz(1);
end
axes(tab_imag_axes);
image(fulimdat);
set(tab_proc_axes,'xlim',fr(1:2),'ylim',fr(3:4));%,'userdata',fr);
set(tab_imag_axes,'xlim',fr(1:2),'ylim',fr(3:4),'userdata',fr);
set(tab_proc_axes,'xticklabel',[],'xticklabelmode','manual','yticklabel'...
,[],'yticklabelmode','manual','Ticklength',[0 0],'tag','tab_proc_axes','userdata',mycont);
set(tab_imag_axes,'xticklabel',[],'xticklabelmode','manual','yticklabel'...
,[],'yticklabelmode','manual','Ticklength',[0 0],'tag','tab_imag_axes');
end
function nccb(hObject, eventdata, handles)
frame=get(findobj(1,'tag','tab_imag_axes'),'userdata');
if frame
mycont=get(findobj(1,'tag','tab_proc_axes'),'userdata');
status='not_cell';
xyar=[get(mycont,'xdata'),get(mycont,'ydata')]';
xyar=xyar(:,1:end-1);
saved_struct=struct('status',status,'contours',{xyar},'frame',frame);
save_data(saved_struct);
%--------------------cell removal------------------------------
global selrow;
tbh=findobj(1,'type','uitable');
alldat=cell2mat(get(tbh,'userdata'));
dat=cell2mat(get(tbh,'data'));
conum=dat(selrow,1);
dat=[dat(1:selrow-1,:);dat(selrow+1:end,:)];
alldat=[alldat(1:conum-1,:);alldat(conum+1:end,:)];
set(tbh,'data',num2cell(dat),'userData',num2cell(alldat));
%--------------------END---------------------------------------
else
errordlg('YOU MUST SELECT SOMETHING IN THE TABLE!');
return
end
end
function iccb(hObject, eventdata, handles)
frame=get(findobj(1,'tag','tab_imag_axes'),'userdata');
if frame
status='is_a_cell';
mycont=get(findobj(1,'tag','tab_proc_axes'),'userdata');
xyar=[get(mycont,'xdata'),get(mycont,'ydata')]';
xyar=xyar(:,1:end-1);
saved_struct=struct('status',status,'contours',{xyar},'frame',frame);
save_data(saved_struct);
%--------------------cell removal------------------------------
global selrow;
tbh=findobj(1,'type','uitable');
alldat=cell2mat(get(tbh,'userdata'));
dat=cell2mat(get(tbh,'data'));
conum=dat(selrow,1);
dat=[dat(1:selrow-1,:);dat(selrow+1:end,:)];
alldat=[alldat(1:conum-1,:);alldat(conum+1:end,:)];
set(tbh,'data',num2cell(dat),'userData',num2cell(alldat));
%--------------------END---------------------------------------
else
errordlg('YOU MUST SELECT SOMETHING IN THE TABLE!');
return
end
end
function mccb(hObject, eventdata, handles)
frame=get(findobj(1,'tag','tab_imag_axes'),'userdata');
if frame
textb=findobj(1,'style','text');
%--------------------------------------------------------------
global i p n;
delete(findobj(handles.figure1,'type','line'));
i=1;
n=0;
p=[];
firsttext='Выделете первый контур (ставить точки нажатием левой клавиши мыши) по часовой стрелке. когда закончите нажмите пробел';
set(textb,'String',firsttext);
set(handles.mainaxes,'buttonDownFcn',@clickfcn);%,'nextplot','add');,'xlimmode','manual','ylimmode','manual');
set(findobj(handles.mainaxes,'type','image'),'hitTest','off');
set(1,'WindowKeyPressFcn',@keypressfcn);
k = waitforbuttonpress ;
%--------------------cell removal------------------------------
global selrow;
tbh=findobj(1,'type','uitable');
alldat=cell2mat(get(tbh,'userdata'));
dat=cell2mat(get(tbh,'data'));
conum=dat(selrow,1);
dat=[dat(1:selrow-1,:);dat(selrow+1:end,:)];
alldat=[alldat(1:conum-1,:);alldat(conum+1:end,:)];
set(tbh,'data',num2cell(dat),'userData',num2cell(alldat));
%--------------------END---------------------------------------
else
errordlg('YOU MUST SELECT SOMETHING IN THE TABLE!');
return
end
end
%--------------------------------------------------------------------------
function clickfcn(ar1,ar2)
global i n p;
r=get(ar1,'currentPoint');
r=r(1,1:2);
if n==0
col='b';
else
col='r';
end
plot(gca,r(1),r(2),[col '*']);%text(r(1),r(2),num2str(i));
i=i+1;
p=[p,r'];
if size(p,2)>1
line(p(1,i-2:i-1),p(2,i-2:i-1),'color',col,'linewidth',1.5);
end
end
function keypressfcn(ar1,ar2)
if ~strcmp(ar2.Key,'space')
return
end
global i p n ps;
per=@(p)sum(sqrt(sum(([p(:,2:end) p(:,1)]-p).^2,1)));
ntext='выделите внутренний контур, и нажмите пробел';
set(findobj(ar1,'type','uicontrol'),'string',ntext);
if size(p,2)<3
ntext='выделите контур';
set(findobj(ar1,'type','uicontrol'),'string',ntext);
return
end
if n==0
col='b';
else
col='r';
end
line(p(1,[size(p,2) 1]),p(2,[size(p,2) 1]),'color',col,'linewidth',1.5);
if n==0
ps=p;
i=1;
p=[];
n=1;
else
ps=flipdim(ps,2);
p=flipdim(p,2);
poly=discrip(ps);
verd=true;
for j=1:size(p,2)
if ~poly(p(:,j))
verd=false;
break
end
end
if ~verd
nntext=['красный контур (Пл: ',num2str(polyarea(p(1,:),p(2,:))),...
',Пер.: ' num2str(per(p)) ') не вложен в зелёный (Пл: ',...
num2str(polyarea(ps(1,:),ps(2,:))),',Пер.: ',num2str(per(ps)) ')'];
set(findobj(ar1,'type','uicontrol'),'string',nntext);
else
nntext=['красный контур (Пл: ',num2str(polyarea(p(1,:),p(2,:))),...
',Пер.: ' num2str(per(p)) ') вложен в зелёный (Пл: ',...
num2str(polyarea(ps(1,:),ps(2,:))),',Пер.: ',num2str(per(ps)) ')'];
set(findobj(ar1,'type','uicontrol'),'string',nntext);
end
set(findobj(ar1,'type','axes'),'buttonDownFcn',[]);
set(ar1,'WindowKeyPressFcn',[]);
end
end
function save_data(saved_struct)
global mcount fcname;
if mcount
save(fcname,'saved_struct','-append');
mcount=mcount+1;
else
original_image=get(findobj(0,'tag','imag_axes'),'userdata');
id=num2str(sum(sum(sum(original_image))));
cond1=0;
for ind=1:length(dirstruct)
if all(ismember(dirstruct(ind).name,'filecontainer'))
cond1=cond1+1;
end
end
if cond1
fcname=['filecontainer_',id,'_',cond1,'.mat'];
else
fcname=['filecontainer_',id,'.mat'];
end
save(fcname,'original_image');
mcount=1;
end
end
%--------------------------------------------------------------------------
function figure1_ResizeFcn(hObject, eventdata, handles)
tbhand=findobj(1,'type','uitable');
tab_proc_axes=findobj(1,'tag','tab_proc_axes');
tab_imag_axes=findobj(1,'tag','tab_imag_axes');
tbpos=get(tbhand,'position');
ex=get(tbhand,'extent');
tbpos(3)=ex(3);%+.028;
set(tbhand,'position',tbpos);
hspan=((1-sum(tbpos([1 3]))-2*.05)-.05)/2;
tpappos=get(tab_proc_axes,'position');
tpappos(1)=sum(tbpos([1 3]))+.05 ;
tpappos(3)=hspan;
set(tab_proc_axes,'position',tpappos);
tiappos=get(tab_imag_axes,'position');
tiappos(1)=sum(tpappos([1 3]))+.05 ;
tiappos(3)=hspan;
set(tab_imag_axes,'position',tiappos);
%----------------------------------------------
ed1=findobj(1,'tag','ed1');
ed2=findobj(1,'tag','ed2');
ed1_pos=[sum(tbpos([1,3]))+.05 .05 .1 .05];
set(ed1,'position',ed1_pos);
ed2_pos=[sum(ed1_pos([1,3]))+.05 .05 .1 .05];
set(ed2,'position',ed2_pos);
end
Documentation
Attachment | Size |
---|---|
Схема алгоритма.pdf | 41.49 KB |