buildoverlay

PURPOSE ^

BUILDOVERLAY - creates an RGB image of a field

SYNOPSIS ^

function [image_rgb varargout]=buildoverlay(md,field,transparency,highres,smoothing,windowsize,border);

DESCRIPTION ^

BUILDOVERLAY - creates an RGB image of a field

   This routine is used by plotmodel to superimpose a radar
   image and a field of the model

   Usage:
      image_rgb=buildoverlay(md,field,transparency,highres,smoothing,windowsize);

   Example:
      image_rgb=buildoverlay(md,md.vel,0.5,1,1,10^3);

   See also: RADARPOWER, PLOTMODEL, BUILDOVERLAYCOLORBAR

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [image_rgb varargout]=buildoverlay(md,field,transparency,highres,smoothing,windowsize,border);
0002 %BUILDOVERLAY - creates an RGB image of a field
0003 %
0004 %   This routine is used by plotmodel to superimpose a radar
0005 %   image and a field of the model
0006 %
0007 %   Usage:
0008 %      image_rgb=buildoverlay(md,field,transparency,highres,smoothing,windowsize);
0009 %
0010 %   Example:
0011 %      image_rgb=buildoverlay(md,md.vel,0.5,1,1,10^3);
0012 %
0013 %   See also: RADARPOWER, PLOTMODEL, BUILDOVERLAYCOLORBAR
0014 
0015 %2d plots only
0016 if ~strcmpi(md.type,'2d'),
0017     error('plot_overlay error message: only 2d plots allowed');
0018 end
0019 
0020 %Ok, first we need to recover the radar map.
0021 md=radarpower(md,highres);
0022 
0023 if isfield(struct(md),field)
0024     data=eval(['md.' field ';']);
0025 else
0026     data=field;
0027 end
0028 
0029 %load x,y, etc ... to speed up plot
0030 x=md.x;
0031 y=md.y;
0032 z=md.z;
0033 elements=md.elements;
0034 
0035 if md.numberofgrids==size(elements,1),
0036     error('buildoverlay error message: the number of elements is the same as the number of grids! cannot plot anything with model/plot, use matlab/plot instead')
0037 end
0038 
0039 if smoothing,
0040     data=averaging(md,data,1);
0041 end
0042 
0043 %use mesh2grid solution to get an gridded data to display using imagesc
0044 md.dummy=data;
0045 md.mesh2grid_parameters={'dummy'};
0046 if length(data)==length(elements),
0047     md.mesh2grid_interpolation={'element'};
0048 elseif length(data)==md.numberofgrids,
0049     md.mesh2grid_interpolation={'node'};
0050 else 
0051     error('plot_overlay error message: data should be numberofgrids of numberofelements long');
0052 end
0053 md.mesh2grid_filter={'average'};
0054 md.mesh2grid_cornereast=min(md.x);
0055 md.mesh2grid_cornernorth=max(md.y);
0056 md.mesh2grid_ncolumns=length(md.sarxm);
0057 md.mesh2grid_xposting=(max(md.x)-min(md.x))/md.mesh2grid_ncolumns;
0058 md.mesh2grid_nlines=length(md.sarym);
0059 md.mesh2grid_yposting=(max(md.y)-min(md.y))/md.mesh2grid_nlines;
0060 md.mesh2grid_windowsize=windowsize;
0061 
0062 md.cluster='none';
0063 md=solve(md,'mesh2grid','cielo');
0064 
0065 %Ok, we have two images, double format:
0066 radar=md.sarpwr;
0067 results=md.mesh2grid_results{1};
0068 
0069 %nullify NaN in results
0070 results(find(isnan(results)))=0;
0071 
0072 %Build hsv color image from radar and results
0073 %intensity
0074 v=radar/max(max(radar));
0075 
0076 %hue
0077 %cut results under 1.5, and log
0078 results(find(results<1.5))=1.5;
0079 h=bytscl(log(results))/(255+1); %1 offset on colormap
0080 
0081 %saturation
0082 s=(0.5+results/125)/transparency;s(find(s>1))=1;s(find(s<0))=0;
0083 s(find(results==1.5))=0;
0084 
0085 %Include border
0086 v((1:border),:)=0;  v((end-border+1:end),:)=0; v(:,1:border)=0;v(:,(end-border+1:end))=0;
0087 
0088 %Transform hsv to rgb
0089 image_hsv=zeros(size(results,1),size(results,2),3);
0090 image_hsv(:,:,1)=h;
0091 image_hsv(:,:,2)=s;
0092 image_hsv(:,:,3)=v;
0093 image_rgb=hsv2rgb(image_hsv);
0094 
0095 if nargout==3,
0096     varargout{1}=md.sarxm;
0097     varargout{2}=md.sarym;
0098 end

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