Introduction
The core module contains all ultrasound tool kit data structures such as 2D or 3D images, for RF, pre-scan or post-scan modalities, and conversion algorithms between those different image types. The io module code contains a set of read/write methods to save and load ultrasound images.
The following turials are good examples to :
- Load and convert a 2D RF image in a pre-scan image.
- Load and convert a 2D pre-scan image and convert it to a post-scan image.
Note that the source code used in this tutorial can be downloaded using the following command :
2D Rf Conversion
The following code shows how to read a rf frame, include it in a volume, and finally convert the volume to pre-scan iamge. To read a RF frame, you can use the usImageIo::read() method. Then, to convert it, the usRFToPreScan2DConverter does the job. Note that using rf files, you have to manually set the transducer settings of the probe used (those informations aren't present in rf format from ultrasonix).
#include <visp3/ustk_core/usConfig.h>
#ifdef USTK_HAVE_FFTW
#include <visp3/core/vpTime.h>
#include <visp3/ustk_core/usImageIo.h>
#include <visp3/ustk_core/usImageRF3D.h>
#include <visp3/ustk_core/usRFToPreScan3DConverter.h>
int main()
{
std::string filename;
if (!env_ipath.empty())
filename = env_ipath + "/rf/signal.rf";
else {
std::cout << "You should set USTK_DATASET_PATH environment var to access to ustk dataset" << std::endl;
return 0;
}
std::cout << filename << std::endl;
std::cout << "end reading" << std::endl;
double startTime = vpTime::measureTimeMs();
std::cout << "converting..." << std::endl;
converter.
convert(rfImage, prescanImage);
std::cout << prescanImage;
double endConvertTime = vpTime::measureTimeMs();
std::cout << "convert time (sec) = " << (endConvertTime - startTime) / 1000.0 << std::endl;
std::cout << "writing pre-scan..." << std::endl;
std::string outFileName = "preScan.png";
return 0;
}
#else
#include <iostream>
int main()
{
std::cout << "You should install FFTW library to run this tutorial" << std::endl;
return 0;
}
#endif
static void read(usImageRF2D< short int > &imageRf2D, const std::string &headerFileName)
static void write(const usImageRF2D< short > &rfImage, const std::string &headerFileName, const std::string &imageExtension2D)
2D conversion from RF signal to pre-scan image
void convert(const usImageRF2D< short int > &rfImage, usImagePreScan2D< unsigned char > &preScanImage)
void setDepth(double depth)
void setScanLinePitch(const double scanLinePitch)
void setTransducerRadius(const double transducerRadius)
VISP_EXPORT std::string getDataSetPath()
Scan conversion of a pre-scan ultrasound frame
The following code shows how to read a pre-scan frame, and convert it to a post-scan iamge. To read a pre-scan frame, you can use the usImageIo::read() method. Then to convert it, use usPreScanToPostScan2DConverter class.
#include <visp3/core/vpTime.h>
#include <visp3/ustk_core/usImageIo.h>
#include <visp3/ustk_core/usPreScanToPostScan2DConverter.h>
#include <visp3/ustk_core/usSequenceReader.h>
int main(int argc, char **argv)
{
std::string filename;
for (int i = 0; i < argc; i++) {
if (std::string(argv[i]) == "--input")
filename = std::string(argv[i + 1]);
else if (std::string(argv[i]) == "--help") {
std::cout << "\nUsage: " << argv[0] << " [--input <preScan3D.xml>] [--help]\n" << std::endl;
return 0;
}
}
if (filename.empty()) {
if (!env_ipath.empty())
filename = env_ipath + "/pre-scan/2D_xml/prescan2d.xml";
else {
std::cout << "You should set USTK_DATASET_PATH environment var to access to ustk dataset" << std::endl;
return 0;
}
}
prescanImage.
resize(128, 480, 16);
converter.
convert(prescanImage, postscanImage);
std::cout << "converted image : " << std::endl;
std::cout << postscanImage;
std::cout << "writing post-scan..." << std::endl;
std::string outFileName = "postscan.xml";
return 0;
}
void resize(const unsigned int h, const unsigned int w)
void convert(const usImagePreScan2D< unsigned char > &preScanImage, usImagePostScan2D< unsigned char > &postScanImage, double xResolution=0., double yResolution=0.)