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 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.
% assign the grid size and create the computational grid Nx = 256; % number of pixels in the x (column) direction Nz = 256; % number of pixels in the z (row) direction x = 10e-3; % grid size [m] z = 10e-3; % grid size [m] dx = x/Nx; % pixel width [m] dz = z/Nz; % pixel height [m] kgrid = makeGrid(Nx, dx, Nz, dz); % resize the input image to the desired number of pixels 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 Bradley Treeby and Ben Cox.