k-Wave Toolbox |
![]() ![]() |
On this page… |
---|
This example demonstrates how to use an external image as the initial pressure distribution in the simulation and detection of photoacoustic waves within a two-dimensional homogeneous propagation medium. It builds on the Homogeneous Propagation Medium Example.
The initial pressure distribution source.p0
used by kspaceFirstOrder2D
is simply a two-dimensional matrix filled with arbitrary numeric values. Consequently, any data may be used to define this distribution. Here an external image map is loaded using loadImage
. This function converts an external image into a matrix, sums the colour channels (for colour images), and scales the pixel values from 0 to 1.
% load the initial pressure distribution from an image p0_magnitude = 5; p0 = p0_magnitude*loadImage('EXAMPLE_source.bmp');
The medium discretisation is again performed by calling makeGrid
with the required grid dimensions, after which resize
is used to scale the loaded image map to the required dimensions.
% create the computational grid Nx = 128; % number of pixels in the x (column) direction Nz = 128; % number of pixels in the z (row) direction dx = 0.1e-3; % pixel width [m] dz = 0.1e-3; % pixel height [m] kgrid = makeGrid(Nx, dx, Nz, dz); % resize the image to the desired number of pixels and assign to the % source input structure source.p0 = resize(p0, Nx, Nz);
The simulation is invoked in the same way as in the previous examples. A plot of the initial pressure distribution and utilised Cartesian sensor mask (using nearest neighbour interpolation) and a visualisation of the recorded pressure field are shown below.
![]() |
Using A Binary Sensor Mask Example | Heterogeneous Propagation Medium | ![]() |
© 2009, 2010 Bradley Treeby and Ben Cox.