-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API: Introduce a new IImage3dStream interface to also support color-f…
…low data Extend the API to also support display of color-flow data, in addition to tissue. This is intended to be a simple representation that is compatible with the way color-flow data is processed by any vendor. Please note that the color-flow appearance is unlikely to exactly match the appearance on the original system, since the "internal" vendor encoding and algorithms are likely to be more advanced. The goal is therefore to get visual appearance that is fairly close to the original. Integration of this extension will probably require bidirectional code for converting between the "internal" vendor encoding and the Image3dAPI encoding of flow data. Only an API update so far. Actual color-flow support will be added in a later PR.
- Loading branch information
Fredrik Orderud
committed
May 25, 2020
1 parent
d2edd53
commit 00c6d45
Showing
15 changed files
with
337 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,110 @@ | ||
#include "Image3dStream.hpp" | ||
|
||
#include "LinAlg.hpp" | ||
|
||
|
||
static const uint8_t OUTSIDE_VAL = 0; // black outside image volume | ||
static const uint8_t PROBE_PLANE = 127; // gray value for plane closest to probe | ||
|
||
|
||
Image3dStream::Image3dStream() { | ||
} | ||
|
||
void Image3dStream::Initialize (ImageType type, Cart3dGeom img_geom, Cart3dGeom out_geom, unsigned short max_resolution[3]) { | ||
m_type = type; | ||
m_img_geom = img_geom; | ||
m_out_geom = out_geom; | ||
|
||
for (size_t i = 0; i < 3; ++i) | ||
m_max_res[i] = max_resolution[i]; | ||
|
||
// One second loop starting at t = 10 | ||
const size_t numFrames = 25; | ||
const double duration = 1.0; // Seconds | ||
const double startTime = 10.0; | ||
|
||
if (type == IMAGE_TYPE_TISSUE) { | ||
// checker board image data | ||
unsigned short dims[] = { 20, 15, 10 }; // matches length of dir1, dir2 & dir3, so that the image squares become quadratic | ||
std::vector<byte> img_buf(dims[0] * dims[1] * dims[2]); | ||
for (size_t frameNumber = 0; frameNumber < numFrames; ++frameNumber) { | ||
for (unsigned int z = 0; z < dims[2]; ++z) { | ||
for (unsigned int y = 0; y < dims[1]; ++y) { | ||
for (unsigned int x = 0; x < dims[0]; ++x) { | ||
bool even_f = (frameNumber / 2 % 2) == 0; | ||
bool even_x = (x / 2 % 2) == 0; | ||
bool even_y = (y / 2 % 2) == 0; | ||
bool even_z = (z / 2 % 2) == 0; | ||
byte & out_sample = img_buf[x + y*dims[0] + z*dims[0] * dims[1]]; | ||
if (even_f ^ even_x ^ even_y ^ even_z) | ||
out_sample = 255; | ||
else | ||
out_sample = 0; | ||
} | ||
} | ||
} | ||
|
||
// special grayscale value for plane closest to probe | ||
for (unsigned int z = 0; z < dims[2]; ++z) { | ||
for (unsigned int x = 0; x < dims[0]; ++x) { | ||
unsigned int y = 0; | ||
byte & out_sample = img_buf[x + y*dims[0] + z*dims[0] * dims[1]]; | ||
out_sample = PROBE_PLANE; | ||
} | ||
} | ||
|
||
m_frames.push_back(CreateImage3d(frameNumber*(duration/numFrames) + startTime, IMAGE_FORMAT_U8, dims, img_buf)); | ||
} | ||
} else { | ||
abort(); // should never be reached | ||
} | ||
} | ||
|
||
Image3dStream::~Image3dStream() { | ||
} | ||
|
||
|
||
HRESULT Image3dStream::GetFrameCount(/*out*/unsigned int *size) { | ||
if (!size) | ||
return E_INVALIDARG; | ||
|
||
*size = static_cast<unsigned int>(m_frames.size()); | ||
return S_OK; | ||
} | ||
|
||
HRESULT Image3dStream::GetFrameTimes(/*out*/SAFEARRAY * *frame_times) { | ||
if (!frame_times) | ||
return E_INVALIDARG; | ||
|
||
const unsigned int N = static_cast<unsigned int>(m_frames.size()); | ||
CComSafeArray<double> result(N); | ||
if (N > 0) { | ||
double * time_arr = &result.GetAt(0); | ||
for (unsigned int i = 0; i < N; ++i) | ||
time_arr[i] = m_frames[i].time; | ||
} | ||
|
||
*frame_times = result.Detach(); | ||
return S_OK; | ||
} | ||
|
||
|
||
HRESULT Image3dStream::GetFrame(unsigned int index, /*out*/Image3d *data) { | ||
if (!data) | ||
return E_INVALIDARG; | ||
if (index >= m_frames.size()) | ||
return E_BOUNDS; | ||
|
||
ImageFormat format = m_frames[index].format; | ||
if (format == IMAGE_FORMAT_U8) { | ||
Image3d result = SampleFrame<uint8_t>(m_frames[index], m_img_geom, m_out_geom, m_max_res); | ||
*data = std::move(result); | ||
return S_OK; | ||
} else if (format == IMAGE_FORMAT_FREQ8POW8) { | ||
Image3d result = SampleFrame<uint16_t>(m_frames[index], m_img_geom, m_out_geom, m_max_res); | ||
*data = std::move(result); | ||
return S_OK; | ||
} | ||
|
||
return E_NOTIMPL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#define IDS_PROJNAME 100 | ||
|
||
#define IDR_AppID 105 | ||
#define IDR_Image3dSource 106 | ||
#define IDR_Image3dFileLoader 107 | ||
#define IDR_Image3dStream 106 | ||
#define IDR_Image3dSource 107 | ||
#define IDR_Image3dFileLoader 108 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.