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

📄 imgspectrumexpofn.m

📁 非常好的数字处理教程
💻 M
字号:
%function imgspectrumexpofn(action,datastruct)    if nargin < 1        action='init';    end	name = mfilename;    figname = [name(1:end-2) '_fig'];    f=findobj('Tag',figname);    handles = get(f,'UserData');	% Make it so that you can grab just one line	% handles.vert keeps changing when plotting pixel vals and spectrum    switch action		case 'help'			display_help(figname);        case 'init'			setdefaults;			reset(handles.spectrum);			reset(handles.horizontal_spectrum);			reset(handles.vertical_spectrum);		case 'load'			handles.imagedata = load_imagedata;            if ~isfield(handles.imagedata, 'filenamepath')                return;            elseif isfield(handles,'figwin');				try,	                close(handles.figwin);				catch				end			end			            handles.figwin = showimage(handles.imagedata, ...				get(handles.scale,'Value'), get(handles.inverse,'Value'));            movegui(handles.figwin,'onscreen');            zoom(handles.figwin, 'off');			place_header(handles.figwin, handles);			handles = place_lines(handles.figwin, handles);            make2DSpecPlot(handles);            drawSpectra(handles);            figure(handles.figwin);		case 'readinput'			handles.imagedata = datastruct;            clear datastruct            setdefaults;            reset(handles.spectrum);			reset(handles.horizontal_spectrum);            reset(handles.vertical_spectrum);            handles.figwin = showimage(handles.imagedata, ...				get(handles.scale,'Value'), get(handles.inverse,'Value'));            movegui(handles.figwin,'onscreen');            zoom(handles.figwin, 'off');			place_header(handles.figwin, handles);			handles = place_lines(handles.figwin, handles);            make2DSpecPlot(handles);            drawSpectra(handles);            figure(handles.figwin);		case {'scale','inverse'}			if isfield(handles, 'imagedata')				figure(handles.figwin);				X = get(gca, 'XLim');				Y = get(gca, 'YLim');				showimage(handles.imagedata, get(handles.scale,'Value'), get(handles.inverse,'Value'), handles.figwin);				set(gca,'XLim',X,'YLim',Y);				handles.h = line(get(gca,'Xlim'), [handles.vert handles.vert],...					'Color','r','EraseMode','xor');				handles.v = line([handles.hori handles.hori], get(gca,'YLim'),...					'Color','r','EraseMode','xor');				handles.p = plot(handles.hori, handles.vert,'ro','MarkerSize',10,...					'ButtonDownFcn','imgspectrumexpofn point','EraseMode','xor');			end		case 'drawmenu'			content = get(handles.drawmenu,'String');			switch lower(content{get(handles.drawmenu,'Value')})				case 'spectrum'					drawSpectra(handles);				case 'values'					drawValues(handles);			end		case {'colormap','inversecolor'}			if isfield(handles, 'imagedata')				figure(handles.imgspectrumexpo_fig);				axes(handles.spectrum);				contents = get(handles.colormap,'String');				cmap = colormap(lower(contents{get(handles.colormap,'Value')}));				if (get(handles.inversecolor,'Value'))					colormap(flipud(cmap));				else					colormap(cmap);				end			end		case 'point'			% Point is moving				%set(handles.figwin,'WindowButtonMotionFcn','imgspectrumexpofn movepoint');			set(handles.figwin,'WindowButtonMotionFcn',{@movePointDraw,handles});            set(handles.figwin,'WindowButtonUpFcn','imgspectrumexpofn release');		%case 'movepoint'		% This recursion was causing problems		%	handles = movepoint(handles);		%	updateSpecPlots(handles);		case 'release'			set(handles.figwin,'WindowButtonMotionFcn','');			set(handles.figwin,'WindowButtonUpFcn','');			handles.hori = get(handles.p,'YData');			handles.vert = get(handles.p,'XData');		case {'imgaliasexpo','imgfilterexpo'}            if isfield(handles,'imagedata')                imagedata = handles.imagedata;                switch action                    case 'imgaliasexpo'                        imgaliasexpogui(imagedata);                    case 'imgfilterexpo'                        imgfilterexpogui(imagedata);                end            end		case 'print'			print_figure(f);		case 'close'			close_figure(f,figname(1:end-4));			if isfield(handles, 'figwin'),				close_figure(handles.figwin);			end            return;	end	set(f,'UserData',handles);%-------------------------------------------------------------function make2DSpecPlot(handles)	figure(handles.imgspectrumexpo_fig);	axes(handles.spectrum);	spectrum = log(abs(fftshift(fft2(handles.imagedata.data))));	% Get rid of inf	points = isinf(spectrum);	spectrum(points) = 0;	imagesc(spectrum);	contents = get(handles.colormap,'String');	cmap = colormap(lower(contents{get(handles.colormap,'Value')}));	if (get(handles.inversecolor,'Value'))		colormap(flipud(cmap));	else		colormap(cmap);	end	axis image;function handles = place_lines(figwin, handles)	figure(figwin);	hold on;	[rows,cols] = size(handles.imagedata.data);	handles.hori = floor(0.1*rows);	handles.vert = floor(0.1*cols);	handles.h = line(get(gca,'Xlim'), [handles.vert handles.vert],...		'Color','r','EraseMode','xor');	handles.v = line([handles.hori handles.hori], get(gca,'YLim'),...		'Color','r','EraseMode','xor');	handles.p = plot(handles.hori, handles.vert,'ro','MarkerSize',10,...		'ButtonDownFcn','imgspectrumexpofn point','EraseMode','xor');

⌨️ 快捷键说明

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