tesseract  4.0.0-1-g2a2b
tesseract::StrideMap Class Reference

#include <stridemap.h>

Classes

class  Index
 

Public Member Functions

 StrideMap ()
 
void SetStride (const std::vector< std::pair< int, int >> &h_w_pairs)
 
void ScaleXY (int x_factor, int y_factor)
 
void ReduceWidthTo1 ()
 
void TransposeXY ()
 
int Size (FlexDimensions dimension) const
 
int Width () const
 

Detailed Description

Definition at line 43 of file stridemap.h.

Constructor & Destructor Documentation

◆ StrideMap()

tesseract::StrideMap::StrideMap ( )
inline

Definition at line 101 of file stridemap.h.

101  {
102  memset(shape_, 0, sizeof(shape_));
103  memset(t_increments_, 0, sizeof(t_increments_));
104  }

Member Function Documentation

◆ ReduceWidthTo1()

void tesseract::StrideMap::ReduceWidthTo1 ( )

Definition at line 154 of file stridemap.cpp.

154  {
155  widths_.assign(widths_.size(), 1);
156  shape_[FD_WIDTH] = 1;
157  ComputeTIncrements();
158 }

◆ ScaleXY()

void tesseract::StrideMap::ScaleXY ( int  x_factor,
int  y_factor 
)

Definition at line 145 of file stridemap.cpp.

145  {
146  for (int& height : heights_) height /= y_factor;
147  for (int& width : widths_) width /= x_factor;
148  shape_[FD_HEIGHT] /= y_factor;
149  shape_[FD_WIDTH] /= x_factor;
150  ComputeTIncrements();
151 }

◆ SetStride()

void tesseract::StrideMap::SetStride ( const std::vector< std::pair< int, int >> &  h_w_pairs)

Definition at line 127 of file stridemap.cpp.

127  {
128  int max_height = 0;
129  int max_width = 0;
130  for (const std::pair<int, int>& hw : h_w_pairs) {
131  int height = hw.first;
132  int width = hw.second;
133  heights_.push_back(height);
134  widths_.push_back(width);
135  if (height > max_height) max_height = height;
136  if (width > max_width) max_width = width;
137  }
138  shape_[FD_BATCH] = heights_.size();
139  shape_[FD_HEIGHT] = max_height;
140  shape_[FD_WIDTH] = max_width;
141  ComputeTIncrements();
142 }

◆ Size()

int tesseract::StrideMap::Size ( FlexDimensions  dimension) const
inline

Definition at line 116 of file stridemap.h.

116 { return shape_[dimension]; }

◆ TransposeXY()

void tesseract::StrideMap::TransposeXY ( )

Definition at line 161 of file stridemap.cpp.

161  {
162  std::swap(shape_[FD_HEIGHT], shape_[FD_WIDTH]);
163  std::swap(heights_, widths_);
164  ComputeTIncrements();
165 }

◆ Width()

int tesseract::StrideMap::Width ( ) const
inline

Definition at line 118 of file stridemap.h.

118 { return t_increments_[FD_BATCH] * shape_[FD_BATCH]; }

The documentation for this class was generated from the following files: