ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Isolines< T > Class Template Reference

#include <ecvIsolines.h>

Public Member Functions

 Isolines (int w, int h)
 Default constructor. More...
 
void setThreshold (T t)
 Sets isoline value to trace. More...
 
int find (const T *in)
 Find isolines. More...
 
int getNumContours () const
 Returns the number of found contours. More...
 
int getContourLength (int contour) const
 Returns the length of a given contour. More...
 
bool isContourClosed (int contour) const
 Returns whether a given contour is closed or not. More...
 
void getContourPoint (int contour, size_t index, double &x, double &y) const
 Returns the given point (x,y) of a given contour. More...
 
double measureArea (int contour) const
 Measures the area delineated by a given contour. More...
 
double measurePerimeter (int contour) const
 Measures the perimeter of a given contour. More...
 
void createOnePixelBorder (T *in, T borderval) const
 Creates a single pixel, 0-valued border around the grid. More...
 
double getContourX (int contour, int v) const
 
double getContourY (int contour, int v) const
 
double measureCurvature (int contour, int i) const
 
void findAreas (int window, std::vector< double > &tips)
 
void findRoundedCorners (int window, std::vector< double > &tips)
 
int getMaxContour () const
 
bool computeBoundingBoxes ()
 
double getBBMinX (int contour) const
 
double getBBMaxX (int contour) const
 
double getBBMinY (int contour) const
 
double getBBMaxY (int contour) const
 
bool contains (int k, double x, double y) const
 
bool containsContour (int k1, int k2)
 
bool containsBoundingBox (int k, double minx, double miny, double maxx, double maxy) const
 
bool contains (const std::vector< double > &polyx, const std::vector< double > &polyy, double x, double y) const
 
bool bbIntersect (int k1, int k2) const
 
bool bbContainsBB (int k1, int k2) const
 
double bbArea (int k) const
 
double getBBCenterX (int k) const
 
double getBBCenterY (int k) const
 

Protected Types

enum  ConfigurationCodes {
  CASE0 = 0 , CASE1 = 1 , CASE2 = 2 , CASE3 = 3 ,
  CASE4 = 4 , CASE5 = 5 , CASE6 = 6 , CASE7 = 7 ,
  CASE8 = 8 , CASE9 = 9 , CASE10 = 10 , CASE11 = 11 ,
  CASE12 = 12 , CASE13 = 13 , CASE14 = 14 , CASE15 = 15 ,
  VISITED = 16
}
 2x2 cell configuration codes More...
 
enum  Edges {
  NONE = -1 , TOP = 0 , RIGHT = 1 , BOTTOM = 2 ,
  LEFT = 3
}
 Entry/exit edges. More...
 

Protected Member Functions

void preCodeImage (const T *in)
 Computes a code for each group of 4x4 cells. More...
 
void endContour (bool closed, bool alternatePath)
 
int findIsolines (const T *in)
 Searches image for contours from topleft to bottomright corners. More...
 
double LERP (T A, T B) const
 LERP between two values. More...
 
int getLastIndex () const
 
void setContourX (int contour, int v, double x)
 
void setContourY (int contour, int v, double y)
 
int getValidIndex (int contour, int v) const
 
double measureArea (int contour, int first, int last) const
 
double measureMeanX (int contour) const
 
double measureMeanY (int contour) const
 
double measurePerimeter (int contour, int first, int last) const
 
double measureNormalX (int contour, int i) const
 
double measureNormalY (int contour, int i) const
 
double measureNormalY (int contour, int first, int last) const
 
double measureNormalX (int contour, int first, int last) const
 
double measureAngleChange (int contour, int first, int last) const
 
int ixy (int x, int y) const
 
double measureDistance (int contour, int first, int second) const
 
double measureLength (int contour, int i) const
 
double measureAngle (int contour, int i) const
 

Static Protected Member Functions

static int wrap (int i, int lo, int hi)
 

Protected Attributes

std::vector< double > m_minx
 
std::vector< double > m_miny
 
std::vector< double > m_maxx
 
std::vector< double > m_maxy
 
std::vector< int > m_cd
 
std::vector< double > m_contourX
 
std::vector< double > m_contourY
 
std::vector< int > m_contourLength
 
std::vector< int > m_contourOrigin
 
std::vector< int > m_contourIndexes
 
std::vector< bool > m_contourClosed
 
int m_w
 
int m_h
 
int m_numContours
 
m_threshold
 

Detailed Description

template<typename T>
class Isolines< T >

Transcription of FindIsolines.java for C++

Fast implementation of marching squares

AUTHOR: Murphy Stein, Greg Borenstein New York University CREATED: Jan-Sept 2012 MODIFIED: Dec 2014 (DGM)

LICENSE: BSD

Copyright (c) 2012 New York University. All rights reserved.

Redistribution and use in source and binary forms are permitted provided that the above copyright notice and this paragraph are duplicated in all such forms and that any documentation, advertising materials, and other materials related to such distribution and use acknowledge that the software was developed by New York Univserity. The name of the University may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED `‘AS IS’' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. This is a fast implementation of the marching squares algorithm for finding isolines (lines of equal color) in an image.

Definition at line 55 of file ecvIsolines.h.

Member Enumeration Documentation

◆ ConfigurationCodes

template<typename T >
enum Isolines::ConfigurationCodes
protected

2x2 cell configuration codes

Enumerator
CASE0 
CASE1 
CASE2 
CASE3 
CASE4 
CASE5 
CASE6 
CASE7 
CASE8 
CASE9 
CASE10 
CASE11 
CASE12 
CASE13 
CASE14 
CASE15 
VISITED 

Definition at line 177 of file ecvIsolines.h.

◆ Edges

template<typename T >
enum Isolines::Edges
protected

Entry/exit edges.

Enumerator
NONE 
TOP 
RIGHT 
BOTTOM 
LEFT 

Definition at line 198 of file ecvIsolines.h.

Constructor & Destructor Documentation

◆ Isolines()

template<typename T >
Isolines< T >::Isolines ( int  w,
int  h 
)
inline

Default constructor.

Definition at line 78 of file ecvIsolines.h.

References Isolines< T >::m_cd.

Member Function Documentation

◆ bbArea()

template<typename T >
double Isolines< T >::bbArea ( int  k) const
inline

◆ bbContainsBB()

template<typename T >
bool Isolines< T >::bbContainsBB ( int  k1,
int  k2 
) const
inline

◆ bbIntersect()

template<typename T >
bool Isolines< T >::bbIntersect ( int  k1,
int  k2 
) const
inline

◆ computeBoundingBoxes()

◆ contains() [1/2]

template<typename T >
bool Isolines< T >::contains ( const std::vector< double > &  polyx,
const std::vector< double > &  polyy,
double  x,
double  y 
) const
inline

Definition at line 936 of file ecvIsolines.h.

◆ contains() [2/2]

template<typename T >
bool Isolines< T >::contains ( int  k,
double  x,
double  y 
) const
inline

◆ containsBoundingBox()

template<typename T >
bool Isolines< T >::containsBoundingBox ( int  k,
double  minx,
double  miny,
double  maxx,
double  maxy 
) const
inline

Definition at line 930 of file ecvIsolines.h.

References Isolines< T >::contains().

◆ containsContour()

template<typename T >
bool Isolines< T >::containsContour ( int  k1,
int  k2 
)
inline

◆ createOnePixelBorder()

template<typename T >
void Isolines< T >::createOnePixelBorder ( T *  in,
borderval 
) const
inline

Creates a single pixel, 0-valued border around the grid.

Definition at line 135 of file ecvIsolines.h.

Referenced by ccRasterizeTool::generateContours().

◆ endContour()

template<typename T >
void Isolines< T >::endContour ( bool  closed,
bool  alternatePath 
)
inlineprotected

◆ find()

template<typename T >
int Isolines< T >::find ( const T *  in)
inline

Find isolines.

Definition at line 94 of file ecvIsolines.h.

Referenced by ccRasterizeTool::generateContours().

◆ findAreas()

template<typename T >
void Isolines< T >::findAreas ( int  window,
std::vector< double > &  tips 
)
inline

◆ findIsolines()

template<typename T >
int Isolines< T >::findIsolines ( const T *  in)
inlineprotected

Searches image for contours from topleft to bottomright corners.

Definition at line 270 of file ecvIsolines.h.

◆ findRoundedCorners()

template<typename T >
void Isolines< T >::findRoundedCorners ( int  window,
std::vector< double > &  tips 
)
inline

◆ getBBCenterX()

template<typename T >
double Isolines< T >::getBBCenterX ( int  k) const
inline

Definition at line 998 of file ecvIsolines.h.

References Isolines< T >::getBBMaxX(), and Isolines< T >::getBBMinX().

◆ getBBCenterY()

template<typename T >
double Isolines< T >::getBBCenterY ( int  k) const
inline

Definition at line 1001 of file ecvIsolines.h.

References Isolines< T >::getBBMaxY(), and Isolines< T >::getBBMinY().

◆ getBBMaxX()

template<typename T >
double Isolines< T >::getBBMaxX ( int  contour) const
inline

◆ getBBMaxY()

template<typename T >
double Isolines< T >::getBBMaxY ( int  contour) const
inline

◆ getBBMinX()

template<typename T >
double Isolines< T >::getBBMinX ( int  contour) const
inline

◆ getBBMinY()

template<typename T >
double Isolines< T >::getBBMinY ( int  contour) const
inline

◆ getContourLength()

◆ getContourPoint()

template<typename T >
void Isolines< T >::getContourPoint ( int  contour,
size_t  index,
double &  x,
double &  y 
) const
inline

Returns the given point (x,y) of a given contour.

Definition at line 115 of file ecvIsolines.h.

References Isolines< T >::getContourLength(), Isolines< T >::getContourX(), and Isolines< T >::getContourY().

◆ getContourX()

◆ getContourY()

◆ getLastIndex()

template<typename T >
int Isolines< T >::getLastIndex ( ) const
inlineprotected

◆ getMaxContour()

template<typename T >
int Isolines< T >::getMaxContour ( ) const
inline

◆ getNumContours()

template<typename T >
int Isolines< T >::getNumContours ( ) const
inline

Returns the number of found contours.

Definition at line 102 of file ecvIsolines.h.

References Isolines< T >::m_numContours.

Referenced by Isolines< T >::computeBoundingBoxes(), and Isolines< T >::getLastIndex().

◆ getValidIndex()

template<typename T >
int Isolines< T >::getValidIndex ( int  contour,
int  v 
) const
inlineprotected

◆ isContourClosed()

template<typename T >
bool Isolines< T >::isContourClosed ( int  contour) const
inline

Returns whether a given contour is closed or not.

Definition at line 110 of file ecvIsolines.h.

References Isolines< T >::m_contourClosed.

Referenced by ccRasterizeTool::generateContours().

◆ ixy()

template<typename T >
int Isolines< T >::ixy ( int  x,
int  y 
) const
inlineprotected

Definition at line 744 of file ecvIsolines.h.

References Isolines< T >::m_w.

◆ LERP()

template<typename T >
double Isolines< T >::LERP ( A,
B 
) const
inlineprotected

LERP between two values.

Definition at line 624 of file ecvIsolines.h.

References Isolines< T >::m_threshold.

◆ measureAngle()

template<typename T >
double Isolines< T >::measureAngle ( int  contour,
int  i 
) const
inlineprotected

◆ measureAngleChange()

template<typename T >
double Isolines< T >::measureAngleChange ( int  contour,
int  first,
int  last 
) const
inlineprotected

Definition at line 716 of file ecvIsolines.h.

◆ measureArea() [1/2]

template<typename T >
double Isolines< T >::measureArea ( int  contour) const
inline

Measures the area delineated by a given contour.

Definition at line 125 of file ecvIsolines.h.

References Isolines< T >::getContourLength().

Referenced by Isolines< T >::findAreas(), and Isolines< T >::findRoundedCorners().

◆ measureArea() [2/2]

template<typename T >
double Isolines< T >::measureArea ( int  contour,
int  first,
int  last 
) const
inlineprotected

◆ measureCurvature()

template<typename T >
double Isolines< T >::measureCurvature ( int  contour,
int  i 
) const
inline

Definition at line 806 of file ecvIsolines.h.

References Isolines< T >::measureAngle(), and Isolines< T >::measureLength().

◆ measureDistance()

template<typename T >
double Isolines< T >::measureDistance ( int  contour,
int  first,
int  second 
) const
inlineprotected

◆ measureLength()

◆ measureMeanX()

template<typename T >
double Isolines< T >::measureMeanX ( int  contour) const
inlineprotected

◆ measureMeanY()

template<typename T >
double Isolines< T >::measureMeanY ( int  contour) const
inlineprotected

◆ measureNormalX() [1/2]

template<typename T >
double Isolines< T >::measureNormalX ( int  contour,
int  first,
int  last 
) const
inlineprotected

Definition at line 710 of file ecvIsolines.h.

References Isolines< T >::measureNormalX().

◆ measureNormalX() [2/2]

template<typename T >
double Isolines< T >::measureNormalX ( int  contour,
int  i 
) const
inlineprotected

◆ measureNormalY() [1/2]

template<typename T >
double Isolines< T >::measureNormalY ( int  contour,
int  first,
int  last 
) const
inlineprotected

Definition at line 704 of file ecvIsolines.h.

References Isolines< T >::measureNormalY().

◆ measureNormalY() [2/2]

template<typename T >
double Isolines< T >::measureNormalY ( int  contour,
int  i 
) const
inlineprotected

◆ measurePerimeter() [1/2]

template<typename T >
double Isolines< T >::measurePerimeter ( int  contour) const
inline

Measures the perimeter of a given contour.

Definition at line 130 of file ecvIsolines.h.

References Isolines< T >::getContourLength().

Referenced by Isolines< T >::findRoundedCorners().

◆ measurePerimeter() [2/2]

template<typename T >
double Isolines< T >::measurePerimeter ( int  contour,
int  first,
int  last 
) const
inlineprotected

◆ preCodeImage()

template<typename T >
void Isolines< T >::preCodeImage ( const T *  in)
inlineprotected

Computes a code for each group of 4x4 cells.

The code depends only on whether each of four corners is above or below threshold.

Definition at line 156 of file ecvIsolines.h.

◆ setContourX()

template<typename T >
void Isolines< T >::setContourX ( int  contour,
int  v,
double  x 
)
inlineprotected

◆ setContourY()

template<typename T >
void Isolines< T >::setContourY ( int  contour,
int  v,
double  y 
)
inlineprotected

◆ setThreshold()

template<typename T >
void Isolines< T >::setThreshold ( t)
inline

Sets isoline value to trace.

Definition at line 91 of file ecvIsolines.h.

References Isolines< T >::m_threshold.

Referenced by ccRasterizeTool::generateContours().

◆ wrap()

template<typename T >
static int Isolines< T >::wrap ( int  i,
int  lo,
int  hi 
)
inlinestaticprotected

Member Data Documentation

◆ m_cd

template<typename T >
std::vector<int> Isolines< T >::m_cd
protected

Definition at line 62 of file ecvIsolines.h.

Referenced by Isolines< T >::Isolines().

◆ m_contourClosed

template<typename T >
std::vector<bool> Isolines< T >::m_contourClosed
protected

Definition at line 68 of file ecvIsolines.h.

Referenced by Isolines< T >::endContour(), and Isolines< T >::isContourClosed().

◆ m_contourIndexes

template<typename T >
std::vector<int> Isolines< T >::m_contourIndexes
protected

Definition at line 67 of file ecvIsolines.h.

Referenced by Isolines< T >::endContour().

◆ m_contourLength

◆ m_contourOrigin

◆ m_contourX

template<typename T >
std::vector<double> Isolines< T >::m_contourX
protected

◆ m_contourY

template<typename T >
std::vector<double> Isolines< T >::m_contourY
protected

◆ m_h

template<typename T >
int Isolines< T >::m_h
protected

Definition at line 71 of file ecvIsolines.h.

Referenced by Isolines< T >::findAreas(), and Isolines< T >::findRoundedCorners().

◆ m_maxx

template<typename T >
std::vector<double> Isolines< T >::m_maxx
protected

Definition at line 59 of file ecvIsolines.h.

Referenced by Isolines< T >::computeBoundingBoxes(), and Isolines< T >::getBBMaxX().

◆ m_maxy

template<typename T >
std::vector<double> Isolines< T >::m_maxy
protected

Definition at line 60 of file ecvIsolines.h.

Referenced by Isolines< T >::computeBoundingBoxes(), and Isolines< T >::getBBMaxY().

◆ m_minx

template<typename T >
std::vector<double> Isolines< T >::m_minx
protected

Definition at line 57 of file ecvIsolines.h.

Referenced by Isolines< T >::computeBoundingBoxes(), and Isolines< T >::getBBMinX().

◆ m_miny

template<typename T >
std::vector<double> Isolines< T >::m_miny
protected

Definition at line 58 of file ecvIsolines.h.

Referenced by Isolines< T >::computeBoundingBoxes(), and Isolines< T >::getBBMinY().

◆ m_numContours

template<typename T >
int Isolines< T >::m_numContours
protected

◆ m_threshold

template<typename T >
T Isolines< T >::m_threshold
protected

Definition at line 74 of file ecvIsolines.h.

Referenced by Isolines< T >::LERP(), and Isolines< T >::setThreshold().

◆ m_w

template<typename T >
int Isolines< T >::m_w
protected

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