tesseract  4.00.00dev
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 153 of file stridemap.cpp.

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

◆ ScaleXY()

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

Definition at line 144 of file stridemap.cpp.

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

◆ SetStride()

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

Definition at line 126 of file stridemap.cpp.

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

◆ 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 160 of file stridemap.cpp.

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

◆ 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: