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

📄 cviewer.m

📁 Edge detection in microscopy images using curvelets
💻 M
📖 第 1 页 / 共 4 页
字号:
function varargout = cviewer(varargin)% CVIEWER M-file for cviewer.fig%      CVIEWER, by itself, creates a new CVIEWER or raises the existing%      singleton*.%%      H = CVIEWER returns the handle to a new CVIEWER or the handle to%      the existing singleton*.%%      CVIEWER('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in CVIEWER.M with the given input arguments.%%      CVIEWER('Property','Value',...) creates a new CVIEWER or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before cviewer_OpeningFcn gets called.  An%      unrecognized property name or invalid value makes property application%      stop.  All inputs are passed to cviewer_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 cviewer% Last Modified by GUIDE v2.5 01-Jul-2008 20:36:17% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @cviewer_OpeningFcn, ...                   'gui_OutputFcn',  @cviewer_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 cviewer is made visible.function cviewer_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 cviewer (see VARARGIN)% Choose default command line output for cviewerhandles.output = hObject;% Set paths to curvelet functionssetpath;% set some default valueshandles.imdims = [256 256];handles.Cmod = {};handles.loadedim = zeros(handles.imdims);handles.im = zeros(handles.imdims);handles.fim = fftshift(fft2(handles.im));handles.rim = zeros(handles.imdims);handles.frim = fftshift(fft2(handles.rim));handles.errim = handles.rim - handles.im;handles.ferrim = handles.frim - handles.fim;handles.C = fdct_wrapping(handles.im,0);handles.stickyaxes = 0;handles.lastdisptype = [1 1];handles.curdirdata = struct('levels',[],'dirs',{},'values',{},'dothandle',[],'dotcoords',[]);handles.lastpath = '';% initialize the levels and dirs listboxeshandles = initlistboxes(handles.imdims, handles);% Update handles structureguidata(hObject, handles);% UIWAIT makes cviewer wait for user response (see UIRESUME)% uiwait(handles.cviewerfig);% --- Outputs from this function are returned to the command line.function varargout = cviewer_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 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 = reinitlistboxes(handles);guidata(hObject, handles);% if we view coefficients - plot directlydisptype_top = get(handles.displaymenu_top, 'Value');disptype_bottom = get(handles.displaymenu_bottom, 'Value');if any(disptype_top == [7 8]) || any(disptype_bottom == [7 8]),  % view coefficients in top or bottom    displaydata(handles)end% --- 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.chk_symmetric,'Value') == get(handles.chk_symmetric,'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% if we view coefficients - plot directlydisptype_top = get(handles.displaymenu_top, 'Value');disptype_bottom = get(handles.displaymenu_bottom, 'Value');if any(disptype_top == [7 8]) || any(disptype_bottom == [7 8]),  % view coefficients in top or bottom    displaydata(handles)end% --- 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 selection change in displaymenu_bottom.function displaymenu_bottom_Callback(hObject, eventdata, handles)% hObject    handle to displaymenu_bottom (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)dtype = get(handles.displaymenu_bottom,'Value');handles.stickyaxes = (isphysspace(dtype) == isphysspace(handles.lastdisptype(2)));showinaxis(handles.axes_bottom, dtype, 1, ...    get(handles.plottype_menu_bottom,'Value'), handles.stickyaxes, handles);handles.lastdisptype(2) = dtype;guidata(hObject, handles);% --- Executes during object creation, after setting all properties.function displaymenu_bottom_CreateFcn(hObject, eventdata, handles)% hObject    handle to displaymenu_bottom (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');end% --- Executes on selection change in displaymenu_top.function displaymenu_top_Callback(hObject, eventdata, handles)% hObject    handle to displaymenu_top (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)dtype = get(handles.displaymenu_top,'Value');handles.stickyaxes = (isphysspace(dtype) == isphysspace(handles.lastdisptype(1)));showinaxis(handles.axes_top, dtype, get(handles.menu_plot_curveletpos_top,'Value'), ...    get(handles.plottype_menu_top,'Value'), handles.stickyaxes, handles);handles.lastdisptype(1) = dtype;guidata(hObject, handles);% --- Executes during object creation, after setting all properties.function displaymenu_top_CreateFcn(hObject, eventdata, handles)% hObject    handle to displaymenu_top (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 cmax = getlargestcoeff(C)cmax = 0;for j=1:length(C),    for l = 1:length(C{j})        cmax = max([cmax; abs(C{j}{l}(:))]);    endend% --- Load image from file function loadimage(hObject, handles)% hObject    handle to button_loadimage (see GCBO)% handles    structure with handles and user data (see GUIDATA)curdir = pwd;if ~isempty(handles.lastpath)    cd(handles.lastpath)end[filename, pathname]=uigetfile({'*' 'All files (*.*)'}, 'Open image');if ~(isequal(filename,0) || isequal(pathname,0))    [pstr,nm,ext,ver] = fileparts(fullfile(pathname,filename));    if strcmp(ext,'.dcm')        im = dicomread(fullfile(pathname,filename));    elseif strcmp(ext,'.dat')        im = load(fullfile(pathname,filename));    else        im = imread(fullfile(pathname,filename));    end    if (ndims(im) > 2),        nzv = zeros(1,min(size(im,3),3));        for k=1:min(size(im,3),3),            nzv(k) = nnz(im(:,:,k));        end        [M,I] = max(nzv);        im = im(:,:,I);    end    handles.loadedim = double(im);        set(handles.cviewerfig, 'Name', ['CViewer - ' filename]);        if get(handles.radio_showimage,'Value') == get(handles.radio_showimage,'Max'),        handles.im = handles.loadedim;        handles.C = fdct_wrapping(handles.im, 0);        handles.fim = fftshift(fft2(handles.im));             handles.lastpath = pathname;        handles = reinitlistboxes(handles);        handles.stickyaxes = 0;        button_go_Callback(hObject, [], handles);  % do calculations        handles = guidata(hObject);  % get new handles, since button_go_Callback() changes them    endendguidata(hObject, handles)cd(curdir);function edit_thrsh_Callback(hObject, eventdata, handles)% hObject    handle to edit_thrsh (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 edit_thrsh as text%        str2double(get(hObject,'String')) returns contents of edit_thrsh as a double% --- Executes during object creation, after setting all properties.function edit_thrsh_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_thrsh (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 menu_thrshtype.function menu_thrshtype_Callback(hObject, eventdata, handles)% hObject    handle to menu_thrshtype (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns menu_thrshtype contents as cell array%        contents{get(hObject,'Value')} returns selected item from menu_thrshtype% --- Executes during object creation, after setting all properties.function menu_thrshtype_CreateFcn(hObject, eventdata, handles)% hObject    handle to menu_thrshtype (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');end% --- Executes on selection change in menu_plot_curveletpos_top.function menu_plot_curveletpos_top_Callback(hObject, eventdata, handles)% hObject    handle to menu_plot_curveletpos_top (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)showinaxis(handles.axes_top, get(handles.displaymenu_top,'Value'), get(handles.menu_plot_curveletpos_top,'Value'), ...    get(handles.plottype_menu_top,'Value'), 1, handles);% --- Executes during object creation, after setting all properties.

⌨️ 快捷键说明

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