function im2eps(color), % IM2EPS Image to Encapsulated PostScript % usage: im2eps or im2eps(flag) % % optional flag: % 0: gray scale % 1: gray scale show image figure % 2: colour % 3: colour show image figure (default) % % this function requires the image processing toolbox % % the figure can be put into your \LaTeX file using: % \includegraphics[width=8cm]{xxx.yyy.eps} % using the \usepackage{graphicx} % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software Foundation, % Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA if nargin < 1, flag=0 ; color=3 ; end if ((color==1) | (color==3)), flag=1; else, flag=0 ; end if (color < 2), color=0 ; else, color=1 ; end [fName,pName] = uigetfile(['*.bmp;*.jpg;*.hdf;*.pcx;*.tif;*.xwd;*.png'],'Load Image') ; if (pName == 0), return ; end [Image,Map] = imread([pName,fName]) ; if flag, fHndle = figure ; else, fHndle = figure('visible','off') ; end ImageHndl = image(Image) ; colormap(Map) ; axis image ; set(gca,'visible','off') ; drawnow % allow for shrinking and cropping answer = lower(input('do you want to crop the image? (yes=1/no=0) ')) ; if (answer == 1), Image = imcrop ; ImageHndl = image(Image) ; colormap(Map) ; axis image ; set(gca,'visible','off') ; end answer = lower(input('do you want to resize the image? (yes=1/no=0) ')) ; if (answer == 1), M = input('enter the resize factor, M = ') ; Image = imresize(Image,M) ; ImageHndl = image(Image) ; colormap(Map) ; axis image ; set(gca,'visible','off') ; end idx = find(fName == '.') ; if (color), if (~isempty(idx)), eval(['print -depsc ' fName(1:idx) 'eps']) ; else eval(['print -depsc ' fName 'eps']) ; end else if (~isempty(idx)), eval(['print -deps ' fName(1:idx) 'eps']) ; else eval(['print -deps ' fName 'eps']) ; end end if ~flag, delete(fHndle) ; end