This post is a basic exercise of geometry and image processing.

Ultrasound images are generated based on the probe data of beamwaves reflecting objects in a cone area. Suppose each ultrasound image is consisted with waves in different radial directions, and each ultrasound wave records points in the range of , then the raw data can be saved as a array. To generate an ultrasound image with cone angle, we can assume that the radius of the inner circle of the cone area is mm, while the outer radius is mm. The following figure depicts the parameters of the ultrasound image.

Ultrasound Cone Depiction

To draw the ultrasound image, first we need to decide the background image size. The height of the image is determined by . And the width of the image is mm. If the angle of the cone is , then the image width should also be mm.

With the background image, we need to paint the raw probe points into the image. Based on the probe data( points) and physical metrics, we can calculate the the number of pixels needed for the background image height and width:

       ,

       .

And the pixels mapped to the cone’s inner circle radius and outer circle radius are:

       ,

       .

As shown in the above image, we can set the origin to the middle of the image top. Given the -th probe data from the -th wave, suppose the cone area is painted from left to right, its coordinates can be calculated based on the cone’s radius pixels and , angle , and number of points per cone border:

       ,

       .

Where

       ,

is the angle of the pixel to the -axis, and (from left to right), .

The point angle is calculated by dividing cone angle into copies. For the left half of the cone area, is an obtuse angle, hence the above formula still work.

In the real ultrasound image, the origin is set to the upper-left corner. We can shift the origin from the upper middle to left by adding to each probe data. To make the cone are in the center of the image, we can move each probe data up for pixels in the image. Therefore the actual coordinates are:

       ,

       .

Following is a short ultrasound video clip generated with the above tranformation method. And here is the python implementation.

Ultasound Video GIF