Changes between Version 3 and Version 4 of VisitMatlab


Ignore:
Timestamp:
01/18/18 17:41:14 (7 years ago)
Author:
Jonathan
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • VisitMatlab

    v3 v4  
    55* FaceVertexCData - Fx1 scalar field defined on the faces
    66
     7== Example ==
     8
     9The following matlab script will prompt for a file, import the data, and plot the surface in matlab using the default colormap
     10{{{
     11[filename,pathname]=uigetfile('*.vtk','Please select a file','*.vtk')
     12data=read2DScalarVTK([pathname,filename])
     13patch(data,'LineStyle','None','FaceColor','flat')
     14}}}
     15
     16== Line integral convolution ==
     17You can also use velocity data to do line integral convolution
     18
     19
     20{{{
     21% Fix these to point to the LIC toolbox and update the pathname to your rho.vtk, vx.vtk, and vz.vtk files
     22addpath('T:\Documents and Settings\jcarroll\My Documents\MATLAB\LIC\toolbox_image\')
     23addpath('T:\Documents and Settings\jcarroll\My Documents\MATLAB\LIC\toolbox_image\toolbox\')
     24pathname='Y:\visualizations\iigu\2\data\';
     25
     26%% Read in rho.vtk, vx.vtk, and vz.vtk (since my slice was in the y direction)
     27N=512; %resolution of lic image
     28
     29filename='rho.vtk';
     30data=read2DScalarVTK([pathname,filename])
     31[xx,yy]=generatemesh(data,N); %We are going to use the same mesh for all regridding all of the data
     32rho=regridmesh(data,xx,yy);
     33
     34filename='vx.vtk';
     35data=read2DScalarVTK([pathname,filename]);
     36vx=regridmesh(data,xx,yy);
     37
     38filename='vz.vtk';
     39data=read2DScalarVTK([pathname,filename]);
     40vz=regridmesh(data,xx,yy);
     41
     42%% Normalize velocities since this is expected by LIC routine
     43maxnorm=sqrt(max(max(vx.^2+vz.^2)));
     44vx=vx/maxnorm;
     45vz=vz/maxnorm;
     46
     47%% Set the options and perform the line integral convolution
     48options.histogram = 'linear';
     49options.verb = 0;
     50options.dt = .5; % time stepping for LIC
     51options.flow_correction = 1;
     52options.niter_lic = 10; % several iterations gives better results
     53options.M0=randn(N); %mask for noise
     54z=zeros(N,N,2);
     55z(:,:,1)=vz;
     56z(:,:,2)=vx;
     57result=perform_lic(z,10,options);
     58imageplot(result)
     59
     60%% Now we can use the noise mask generated from LIC on the velocity data, to adjust the brightness of a false color image of the density
     61f=.8; %Brightening factor - so that you can still see color through black/white noise
     62rho_min=min(min(rho)) %get lower bound
     63rho_max=max(max(rho)) %get upper bound
     64cmap=colormap('hsv');
     65cmap=cmap(1:200,:); %restrict colormap to first 200 entries instead of 256 to avoid circling back around to red
     66cdata=interp1(linspace(log(rho_min),log(rho_max),size(cmap,1)), double(cmap), log(rho(:))); %get cdata from scalar field using log scaling
     67cdata=reshape(cdata,[N,N,3]).*repmat((1-f)+f*result,[1,1,3]); %multiply by mask
     68image(cdata) %draw image
     69}}}