image thumbnail

makestereofig_v2

by

 

Converts .fig files containing Cartesian xyz plots to stereo in 3 formats

makestereofig_v2.m
% makestereofig_v2.m
% Dec 23, 2011
% v2 allows choice of straight pair, cross pair, or anaglyphic
% converts MATLAB plot (.FIG) of z as func of x,y into an anaglyphic
%  stereo JPG image

mydir = uigetdir('','Select work folder');
cd (mydir);

while 1
    
      clear Lview Rview Sview
    
      [filename,pathname]=uigetfile('*.fig','Input name of 3D fig file to be converted');
      if filename == 0
          return
      end
      disp([filename ' has been loaded.']); 
      open(filename);
      input('Adjust figure location on display, then hit return');
      set(gcf,'units','normal');
      figpos = get(gcf,'position');
      rotate3d on
      input('Adjust azimuth & elevation to desired point of view, then hit return');
      [az,el] = view;
      view(az - 2.5, el);
      saveas(gcf,'Lview.jpg');
      view(az + 2.5, el);
      saveas(gcf,'Rview.jpg');
      Lview = imread('Lview.jpg');
      Rview = imread('Rview.jpg');

      while 1
          choice = menu('Choose option','Anaglyphic stereo','Straight pair', ...
                        'Crossed pair','New Image','Quit');
          if choice == 5
              return
          elseif choice == 4
              break
          elseif choice == 3
              clear crossview
              crossview = cat(2,Rview,Lview);
              plotdisplay2(crossview,[0.15313 0.05 0.70859 0.45]);
              set(gcf,'paperpositionmode','auto','paperorientation','landscape');
              savename = [filename '_crosspair.jpg'];
              imwrite(crossview, savename, 'jpg');
              disp([savename ' has been saved.']);
          elseif choice == 2
              clear straightview
              straightview = cat(2,Lview,Rview);
              plotdisplay2(straightview,[0.15313 0.05 0.70859 0.45]);
              set(gcf,'paperpositionmode','auto','paperorientation','landscape');
          else
              clear anaglyphview
              anaglyphview(:,:,1) = Lview(:,:,1);
              anaglyphview(:,:,2:3) = Rview(:,:,2:3);              
              plotdisplay2(anaglyphview, figpos);
              savename = [filename '_anaglyph.jpg'];
              imwrite(anaglyphview, savename, 'jpg');
              disp([savename ' has been saved.']);
          end
          input('Hit enter to continue');
      end
end
      
      
      

Contact us