antoverlay2

PURPOSE ^

ANTOVERLAY2 - overlay a figure with image of Antarctica

SYNOPSIS ^

function antoverlay2(fig1,fig2,alpha,colorbartitle,colmap,wrappingnumber);

DESCRIPTION ^

ANTOVERLAY2 - overlay a figure with image of Antarctica

   Overlay figure1 image with Antarctica Power Image, and display on figure 2.
   
   Usage:
      antoverlay2(fig1,fig2,alpha,colorbartitle,colmap,wrappingnumber,outlineflag,colorbarflag)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function antoverlay2(fig1,fig2,alpha,colorbartitle,colmap,wrappingnumber);
0002 %ANTOVERLAY2 - overlay a figure with image of Antarctica
0003 %
0004 %   Overlay figure1 image with Antarctica Power Image, and display on figure 2.
0005 %
0006 %   Usage:
0007 %      antoverlay2(fig1,fig2,alpha,colorbartitle,colmap,wrappingnumber,outlineflag,colorbarflag)
0008 
0009 if ((nargin==0) || (nargin~=6)),
0010     help antoverlay;
0011     return;
0012 end
0013 
0014 %Capture image on figure fig1:
0015 figure(fig1)
0016 
0017 %Capture title
0018 t=get(gca,'Title');
0019 ti=get(t,'String');
0020 
0021 %First remove tick marks
0022 fig1xticks=get(gca,'XTick');
0023 fig1yticks=get(gca,'YTick');
0024 set(gca,'XTick',[]);
0025 set(gca,'YTick',[]);
0026 
0027 %Capture
0028 im=frame2im(getframe);
0029 
0030 %Capture max and min values
0031 maxminvalues=caxis;
0032 c1=maxminvalues(1);
0033 c2=maxminvalues(2);
0034 
0035 %flip image and rescale it.
0036 red=im(:,:,1);
0037 green=im(:,:,2);
0038 blue=im(:,:,3);
0039 im(:,:,1)=flipud(red);
0040 im(:,:,2)=flipud(green);
0041 im(:,:,3)=flipud(blue);
0042 
0043 %Get Size of image
0044 s=size(im);
0045 s1=s(1);
0046 s2=s(2);
0047 
0048 %Get coordinates of image
0049 xbound=xlim;
0050 ybound=ylim;
0051 x0=xbound(1);
0052 x1=xbound(2);
0053 y0=ybound(1);
0054 y1=ybound(2);
0055 
0056 
0057 %Create new image coordinates
0058 x_m=x0:(x1-x0)/(s2-1):x1;
0059 y_m=y0:(y1-y0)/(s1-1):y1;
0060 
0061 %Now that image on figure fig1 is correctly setup, go fetch
0062 %the radar power image.
0063 path_gdal='/home/larour/gdal2/bin/';
0064 %the geotiff image is either 200m or 1km accuracy. We take the 1km accuracy if the domain
0065 %of fig1  is more than 1000 km.
0066 geotiff_name='/proj/tpfimos/larour/Glaciology/Model_Data/Mosaic_Tiff/amm125m_v2_200m.tif';
0067 if (max((x1-x0),(y1-y0))>1000000),
0068     geotiff_name='/proj/tpfimos/larour/Glaciology/Model_Data/Mosaic_Tiff/amm125m_v2_1km.tif';
0069 end
0070 inputname='./temp.tif';
0071 
0072 command=['system(''' path_gdal 'gdal_translate -projwin ' num2str(x0) ' ' num2str(y1) ' ' num2str(x1) ' ' num2str(y0) ' ' geotiff_name ' ' inputname ''');'];
0073 eval(command);
0074 
0075 %Read in temp.tif:
0076 radar=imread('temp.tif','TIFF');
0077 save temp radar
0078 r=size(radar);
0079 r1=r(1);
0080 r2=r(2);
0081 x_r=x0:(x1-x0)/(r2-1):x1;
0082 y_r=y0:(y1-y0)/(r1-1):y1;
0083 
0084 %Display radar image first
0085 figure(fig2)
0086 set(fig2,'Position',[1604 4 1594 1123]);
0087 rim=imagesc(x_r,y_r,flipud(radar));colormap('gray');
0088 save temp x_r y_r
0089 set(gca,'YDir','normal');
0090 
0091 %Display captured image
0092 hold on
0093 iim=image(x_m,y_m,im);
0094 set(gca,'YDir','normal');
0095 
0096 %Set transparency of data image
0097 set(iim,'AlphaData',alpha);
0098 
0099 %Set title identical to the one from fig1
0100 title(ti,'Fontsize',18);
0101 
0102 %x and y axis
0103 xlabel('X (m)','FontSize',18);
0104 ylabel('Y (m)','FontSize',18);
0105 
0106 %Read in outline of antarctica and display.
0107 load /proj/tpfimos/larour/Glaciology/Model_Data/Mosaic_Tiff/antarctica_outline
0108 outline_axes=axes('Position',[.15,.75,.15,.15]); 
0109 imagesc(outlinex,outliney,outline);set(outline_axes,'YDir','normal');
0110 set(outline_axes,'XTick',[]); set(outline_axes,'YTick',[]);
0111 set(outline_axes,'XTickLabel',[]); set(outline_axes,'YTickLabel',[]);
0112 hold on;
0113 %build box inside the continent
0114 for i=1:50,
0115     plot(x0:500:x1,(y0+500*i)*ones(length(x0:500:x1),1),'r');
0116     plot(x0:500:x1,(y1-500*i)*ones(length(x0:500:x1),1),'r');
0117     plot((x0+500*i)*ones(length(y0:500:y1),1),y0:500:y1,'r');
0118     plot((x1-500*i)*ones(length(y0:500:y1),1),y0:500:y1,'r');
0119 end
0120 %make border
0121 for i=1:50,
0122     plot(min(outlinex):500:max(outlinex),(min(outliney)+500*i)*ones(length(min(outlinex):500:max(outlinex)),1),'w');
0123     plot(min(outlinex):500:max(outlinex),(max(outliney)-500*i)*ones(length(min(outlinex):500:max(outlinex)),1),'w');
0124     plot((min(outlinex)+500*i)*ones(length(min(outliney):500:max(outliney)),1),min(outliney):500:max(outliney),'w');
0125     plot((max(outlinex)-500*i)*ones(length(min(outliney):500:max(outliney)),1),min(outliney):500:max(outliney),'w');
0126 end
0127 
0128 %Build colorbar
0129 colim=zeros(1,length(colmap),3);
0130 colim(1,:,1)=colmap(:,1);
0131 colim(1,:,2)=colmap(:,2);
0132 colim(1,:,3)=colmap(:,3);
0133 colaxes=axes('Position',[.7,.05,.1,.02]);
0134 image(colim);
0135 set(colaxes,'XTick',[]);
0136 set(colaxes,'YTick',[]);
0137 %t=text(length(colmap)/2,2,[num2str(c2/wrappingnumber) ' ' colorbartitle]);
0138 t=text(0,0,num2str(c1));
0139 set(t,'FontSize',16);
0140 t=text(length(colmap),0,num2str(c2));
0141 set(t,'FontSize',16);
0142 t=text(length(colmap)/2,2,colorbartitle);
0143 set(t,'HorizontalAlignment','center');
0144 set(t,'FontSize',18);
0145 
0146 
0147 %We are done, reeastablish figure fig1 settings
0148 figure(fig1);
0149 set(gca,'XTick',fig1xticks);
0150 set(gca,'YTick',fig1yticks);
0151

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003