Version 4 (modified by 7 years ago) ( diff ) | ,
---|
If you have a surface in Visit (ie an isosurface, or a slice), you can save the window as a vtk file. And then use the attached read2DScalarVTK.m matlab function to import the vtk file as a struct in matlab. The struct returns contains
- Faces - Fx3 array of integers containing the point numbers that make up each face
- Vertices - Vx3 array of floats containing the xyz coordinates of each vertex
- FaceVertexCData - Fx1 scalar field defined on the faces
Example
The following matlab script will prompt for a file, import the data, and plot the surface in matlab using the default colormap
[filename,pathname]=uigetfile('*.vtk','Please select a file','*.vtk') data=read2DScalarVTK([pathname,filename]) patch(data,'LineStyle','None','FaceColor','flat')
Line integral convolution
You can also use velocity data to do line integral convolution
% Fix these to point to the LIC toolbox and update the pathname to your rho.vtk, vx.vtk, and vz.vtk files addpath('T:\Documents and Settings\jcarroll\My Documents\MATLAB\LIC\toolbox_image\') addpath('T:\Documents and Settings\jcarroll\My Documents\MATLAB\LIC\toolbox_image\toolbox\') pathname='Y:\visualizations\iigu\2\data\'; %% Read in rho.vtk, vx.vtk, and vz.vtk (since my slice was in the y direction) N=512; %resolution of lic image filename='rho.vtk'; data=read2DScalarVTK([pathname,filename]) [xx,yy]=generatemesh(data,N); %We are going to use the same mesh for all regridding all of the data rho=regridmesh(data,xx,yy); filename='vx.vtk'; data=read2DScalarVTK([pathname,filename]); vx=regridmesh(data,xx,yy); filename='vz.vtk'; data=read2DScalarVTK([pathname,filename]); vz=regridmesh(data,xx,yy); %% Normalize velocities since this is expected by LIC routine maxnorm=sqrt(max(max(vx.^2+vz.^2))); vx=vx/maxnorm; vz=vz/maxnorm; %% Set the options and perform the line integral convolution options.histogram = 'linear'; options.verb = 0; options.dt = .5; % time stepping for LIC options.flow_correction = 1; options.niter_lic = 10; % several iterations gives better results options.M0=randn(N); %mask for noise z=zeros(N,N,2); z(:,:,1)=vz; z(:,:,2)=vx; result=perform_lic(z,10,options); imageplot(result) %% 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 f=.8; %Brightening factor - so that you can still see color through black/white noise rho_min=min(min(rho)) %get lower bound rho_max=max(max(rho)) %get upper bound cmap=colormap('hsv'); cmap=cmap(1:200,:); %restrict colormap to first 200 entries instead of 256 to avoid circling back around to red cdata=interp1(linspace(log(rho_min),log(rho_max),size(cmap,1)), double(cmap), log(rho(:))); %get cdata from scalar field using log scaling cdata=reshape(cdata,[N,N,3]).*repmat((1-f)+f*result,[1,1,3]); %multiply by mask image(cdata) %draw image
Attachments (4)
- read2DScalarVTK.m (1.3 KB ) - added by 7 years ago.
- generatemesh.m (217 bytes ) - added by 7 years ago.
- regridmesh.m (225 bytes ) - added by 7 years ago.
- toolbox_image.zip (2.7 MB ) - added by 7 years ago.
Note:
See TracWiki
for help on using the wiki.