Scope
ScopeOverlayResonanceSW.cpp
1 #include "stdafx.h"
2 #include "ScopeOverlayResonanceSW.h"
3 #include "ScopeImage.h"
4 #include "ScopeMultiImageResonanceSW.h"
5 #include "helpers.h"
6 #include "pixel.h"
7 #include "lut.h"
8 
9 namespace scope {
10 
11 ScopeOverlayResonanceSW::ScopeOverlayResonanceSW(const uint32_t& _lines, const uint32_t& _linewidth)
12  : ScopeOverlay(_lines, _linewidth) {
13 }
14 
15 void ScopeOverlayResonanceSW::Create(ScopeMultiImageResonanceSWCPtr const _multi, const std::vector<ColorProps>& _color_props) {
16  std::lock_guard<std::mutex> lock(mutex);
17  assert( (_color_props.size() == _multi->Channels()) && (lines==_multi->Lines()) && (linewidth==_multi->Linewidth()) );
18 
19  std::fill(std::begin(overlay), std::end(overlay), BGRA8BLACK); // Clear the overlay
20 
21  for ( size_t ch = 0 ; ch < _multi->Channels() ; ch++ ) {
22  ScopeImageU16CPtr chimage = _multi->GetChannel(ch);
23  if ( _color_props.at(ch).Color() != None ) { // save some time...
24  ColorEnum col = _color_props.at(ch).Color();
25  uint16_t ll = _color_props.at(ch).LowerLimit();
26  uint16_t ul = _color_props.at(ch).UpperLimit();
27 
28  ScopeImageConstAccessU16 imagedata(*chimage);
29  auto it = imagedata.GetConstData()->begin();
30 
31  // if in resonance scanner mode, only the forward lines are shown on the screen
32 
33  // I do not see that the reason for the l+=2 is here, RKr 7/1/15
34  for ( uint32_t l = 0; l < lines; l+= 2 ) {
35  it = imagedata.GetConstData()->begin() + l*linewidth;
36  std::transform(std::begin(overlay)+l*linewidth, std::begin(overlay)+(l+1)*linewidth, it, std::begin(overlay)+l*linewidth, [&](BGRA8Pixel& pix, const uint16_t& gray) {
37  return pix + U16ToBGRA8Histo(gray, col, ll, ul);
38  } );
39  it = imagedata.GetConstData()->begin() + l*linewidth;
40  std::transform(std::begin(overlay)+(l+1)*linewidth, std::begin(overlay)+(l+2)*linewidth, it, std::begin(overlay)+(l+1)*linewidth, [&](BGRA8Pixel& pix, const uint16_t& gray) {
41  return pix + U16ToBGRA8Histo(gray, col, ll, ul);
42  } );
43  }
44  }
45  }
46 }
47 
48 }
49 
50 
ScopeOverlayResonanceSW(const uint32_t &_lines=0, const uint32_t &_linewidth=0)
overlay will be initialized with 0s
Encapsulated a 4-byte pixel in BGRA format for use with Direct2D.
Definition: pixel.h:38
#define BGRA8BLACK
An opaque black.
Definition: lut.h:108
std::vector< BGRA8Pixel > overlay
vector with pixeldata
Definition: ScopeOverlay.h:27
uint32_t lines
number of lines, y resolution
Definition: ScopeOverlay.h:21
Overlay of several gray-scale/uint16_t channels into one BGRA8 image.
Definition: ScopeOverlay.h:17
uint32_t linewidth
width of a line, x resolution
Definition: ScopeOverlay.h:24
The BGRA8Pixel struct and various related helpers for color conversions.
This is the include file for standard system include files, or project specific include files that ar...
virtual void Create(ScopeMultiImageResonanceSWCPtr const _multi, const std::vector< ColorProps > &_color_props)
Creates an overlay from a multi image with the specified color properties per channel.
const std::vector< T > * GetConstData() const
Definition: ScopeImage.h:247
following http://www.mochima.com/articles/LUT/lut_h.html
Various helper functions and classes for Scope.
std::mutex mutex
mutex for protection
Definition: ScopeOverlay.h:30
Gives RAII safe const access (read-only) to the pixeldata of a ScopeImage.
Definition: ScopeImage.h:14