⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmoviemaker.m

📁 Edge detection in microscopy images using curvelets
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = cmoviemaker(varargin)% CMOVIEMAKER M-file for cmoviemaker.fig%      CMOVIEMAKER, by itself, creates a new CMOVIEMAKER or raises the existing%      singleton*.%%      H = CMOVIEMAKER returns the handle to a new CMOVIEMAKER or the handle to%      the existing singleton*.%%      CMOVIEMAKER('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in CMOVIEMAKER.M with the given input arguments.%%      CMOVIEMAKER('Property','Value',...) creates a new CMOVIEMAKER or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before cmoviemaker_OpeningFcn gets called.  An%      unrecognized property name or invalid value makes property application%      stop.  All inputs are passed to cmoviemaker_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 cmoviemaker% Last Modified by GUIDE v2.5 28-Nov-2007 11:42:18% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @cmoviemaker_OpeningFcn, ...                   'gui_OutputFcn',  @cmoviemaker_OutputFcn, ...                   'gui_LayoutFcn',  [] , ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})    gui_State.gui_Callback = str2func(varargin{1});endif 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 cmoviemaker is made visible.function cmoviemaker_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 cmoviemaker (see VARARGIN)% Choose default command line output for cmoviemakerhandles.output = hObject;% set default values for handle structurehandles.filenames = {};handles.pathname = '';handles.lastsavefilename = '';handles.lastsavepath = '';handles.hfig = [];handles.computeinfo = struct('xlim',[],'ylim',[],'invert',0,'thrshtype',1,'thrshval',0,'levels',[],'dirs',{{}});handles.layout = [1 1];handles.plotinfo = struct('type', {1}, 'pos', {1}, 'transform', {1}, 'value', {1}, 'colorbar', {1});% Update handles structureguidata(hObject, handles);setpath;% UIWAIT makes cmoviemaker wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = cmoviemaker_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 structurevarargout{1} = handles.output;% --- Executes on button press in button_loadimages.function button_loadimages_Callback(hObject, eventdata, handles)% hObject    handle to button_loadimages (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('*.*','Select images',handles.pathname,'MultiSelect','on');if ~(isequal(filename,0) || isequal(pathname,0)),    if ischar(filename),        handles.filenames = {filename};    else        handles.filenames = filename;    end    handles.pathname = pathname;        % init filename listbox    set(handles.listbox_images, 'String', handles.filenames);        % show first image    im1 = displayfile(1, handles);    % initialize levels and dirs listboxes    handles = initlistboxes(size(im1), handles);        % save handles    guidata(gcbo, handles);end% --- Executes on selection change in listbox_images.function listbox_images_Callback(hObject, eventdata, handles)% hObject    handle to listbox_images (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)nr = get(hObject, 'Value');if nr > 0,    im = displayfile(nr, handles);    nlev = floor(log2(min(size(im)))) - 3;    handles = reinitlistboxes(nlev, handles);    guidata(hObject, handles);end% --- Executes during object creation, after setting all properties.function listbox_images_CreateFcn(hObject, eventdata, handles)% hObject    handle to listbox_images (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% 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');endfunction edit_xlim_Callback(hObject, eventdata, handles)% hObject    handle to edit_xlim (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)str = get(hObject, 'String');xlim = eval(str);if (length(xlim) == 2 && xlim(2) > xlim(1) && xlim(1) >= 1) ...        || isempty(xlim),    handles.computeinfo.xlim = xlim;    im = displaycurrentfile(handles);    nlev = floor(log2(min(size(im)))) - 3;    handles = reinitlistboxes(nlev, handles);    guidata(hObject, handles)else    errordlg('Bad values for x-limits','CMovieMaker error')end% --- Executes during object creation, after setting all properties.function edit_xlim_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_xlim (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');endfunction edit_ylim_Callback(hObject, eventdata, handles)% hObject    handle to edit_ylim (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)str = get(hObject, 'String');ylim = eval(str);if (length(ylim) == 2 && ylim(2) > ylim(1) && ylim(1) >= 1) ...        || isempty(ylim),    handles.computeinfo.ylim = ylim;    im = displaycurrentfile(handles);    nlev = floor(log2(min(size(im)))) - 3;    handles = reinitlistboxes(nlev, handles);    guidata(hObject, handles)else    errordlg('Bad values for y-limits','CMovieMaker error')end% --- Executes during object creation, after setting all properties.function edit_ylim_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_ylim (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 selection change in listbox_levels.function listbox_levels_Callback(hObject, eventdata, handles)% hObject    handle to listbox_levels (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)handles.computeinfo.levels = get(handles.listbox_levels, 'Value');nlev = length(get(handles.listbox_levels, 'String'));handles = reinitlistboxes(nlev, handles);guidata(hObject, handles);% --- Executes during object creation, after setting all properties.function listbox_levels_CreateFcn(hObject, eventdata, handles)% hObject    handle to listbox_levels (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% 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% --- Executes on selection change in listbox_dirs.function listbox_dirs_Callback(hObject, eventdata, handles)% hObject    handle to listbox_dirs (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)nrdirs = length(get(hObject,'String'));if get(handles.checkbox_symmdirs,'Value') == get(handles.checkbox_symmdirs,'Max') && ...         nrdirs > 1,    topitem = get(hObject, 'ListBoxTop');    dirsel = get(hObject,'Value');    dirsel = unique([dirsel mod(dirsel + nrdirs/2 - 1, nrdirs)+1]);    set(hObject,'Value',dirsel)        set(hObject, 'ListBoxTop', topitem)end% update computeinfofor k=handles.computeinfo.levels,    if ismember(k, [1 length(get(handles.listbox_levels, 'String'))]),        thisnrdirs = 1;    else        thisnrdirs = 16 * (2.^floor((k-1)/2));    end    step = round(thisnrdirs / nrdirs);    dirs = 1:thisnrdirs;    dirs = dirs(ismember(floor((dirs-1)/step) + 1, dirsel));    handles.computeinfo.dirs{k} = dirs;endguidata(hObject, handles);% --- Executes during object creation, after setting all properties.function listbox_dirs_CreateFcn(hObject, eventdata, handles)% hObject    handle to listbox_dirs (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% 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% --- Executes on button press in checkbox_symmdirs.function checkbox_symmdirs_Callback(hObject, eventdata, handles)% hObject    handle to checkbox_symmdirs (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of checkbox_symmdirs% --- Executes on button press in button_makemovie.function button_makemovie_Callback(hObject, eventdata, handles)% hObject    handle to button_makemovie (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)curdir = pwd;if ~isempty(handles.lastsavepath)    cd(handles.lastsavepath);end[filename, pathname, index] = uiputfile({'*.avi', 'AVI files (*.avi)'}, 'Save movie as...', handles.lastsavefilename);if index ==0,   return; % user pressed cancelendhandles.lastsavefilename = filename;handles.lastsavepath = pathname;cd(curdir);if isempty(handles.hfig) || ~ishandle(handles.hfig),    handles.hfig = figure;    guidata(hObject, handles);endif get(handles.popup_thresh, 'Value') == 4,   % get threshold from first image   handles = getthrshfromfirstimage(handles);endclear M;for k=1:length(handles.filenames),    hf = drawmovieframe(handles.hfig, fullfile(handles.pathname, handles.filenames{k}), ...            handles.layout, handles.plotinfo, handles.computeinfo);    pause(0.1);    M(k) = getframe(hf);endmovie2avi(M, fullfile(pathname, filename));function edit_thrshvalue_Callback(hObject, eventdata, handles)% hObject    handle to edit_thrshvalue (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)val = str2double(get(hObject, 'String'));if isnan(val) || val <= 0,    errordlg('Bad value for threshold/number of coefficients', 'CMovieMaker error');    return;endhandles.computeinfo.thrshval = val;guidata(hObject, handles)% --- Executes during object creation, after setting all properties.function edit_thrshvalue_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_thrshvalue (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 selection change in popup_thresh.function popup_thresh_Callback(hObject, eventdata, handles)% hObject    handle to popup_thresh (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)handles.computeinfo.thrshtype = get(hObject, 'Value');guidata(hObject, handles)edit_thrshvalue_Callback(handles.edit_thrshvalue, eventdata, handles);% --- Executes during object creation, after setting all properties.function popup_thresh_CreateFcn(hObject, eventdata, handles)% hObject    handle to popup_thresh (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: popupmenu 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');endfunction edit_thrshdisp_Callback(hObject, eventdata, handles)% hObject    handle to edit_thrshdisp (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes during object creation, after setting all properties.function edit_thrshdisp_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_thrshdisp (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% ------------------------------% custom helper functions%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -