33 #include "Core/include/DCommon.h"
34 #include "Core/include/DBaseObject.h"
35 #include "Base/include/DImageDraw.h"
63 SE_Rhombicuboctahedron
76 :
BaseObject(
"StrElt"), odd(false), seT(SE_Generic), size(s)
94 StrElt(
bool oddSE, UINT nbrPts, ...)
95 :
BaseObject(
"StrElt"), odd(oddSE), seT(SE_Generic), size(1)
101 for (UINT i = 0; i < nbrPts; i++) {
102 index = va_arg(vl, UINT);
131 StrElt(
bool oddSE, vector<UINT> indexList)
132 :
BaseObject(
"StrElt"), odd(oddSE), seT(SE_Generic), size(1)
134 vector<UINT>::iterator it;
135 for (it = indexList.begin(); it != indexList.end(); it++)
240 void addPoint(
int x,
int y,
int z = 0);
312 std::map<seType, string> seNames = {
313 {SE_Generic,
"GenericSE"},
318 {SE_Cross,
"CrossSE"},
319 {SE_Horiz,
"HorizSE"},
322 {SE_Cross3D,
"Cross3DSE"},
323 {SE_Rhombicuboctahedron,
"RhombicuboctahedronSE"},
325 {SE_Line3D,
"Line3DSE"},
326 {SE_CenteredLine,
"CenteredLineSE"},
327 {SE_CenteredLine3D,
"CenteredLine3DSE"}
330 std::map<seType, string>::iterator it;
331 it = seNames.find(seT);
332 if (it != seNames.end())
333 this->name = seNames[seT];
335 this->name =
"Unknown";
354 virtual void printSelf(ostream &os = std::cout,
string indent =
"")
const;
372 inline void operator<<(ostream &os, StrElt &se)
388 SquSE(UINT s = 1) :
StrElt(
false, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8)
390 className =
"SquSE : StrElt";
408 typedef StrElt parentClass;
409 SquSE0(UINT s = 1) :
StrElt(
false, 8, 1, 2, 3, 4, 5, 6, 7, 8)
411 className =
"SquSE0";
430 HexSE(UINT s = 1) :
StrElt(
true, 7, 0, 1, 2, 3, 4, 5, 6)
432 className =
"HexSE : StrElt";
452 className =
"HexSE0";
473 className =
"CrossSE : StrElt";
494 className =
"HorizSE : StrElt";
515 className =
"VertSE : StrElt";
535 className =
"CubeSE : StrElt";
540 int zList[] = {0, -1, 1};
541 for (
int i = 0; i < 3; i++) {
569 className =
"Cross3DSE : StrElt";
596 className =
"RhombicuboctahedronSE : StrElt";
597 seT = SE_Rhombicuboctahedron;
604 for (x = -2; x <= 2; x++)
605 for (y = -1; y <= 1; y++)
606 for (z = -1; z <= 1; z++)
608 for (x = -1; x <= 1; x++)
609 for (y = -2; y <= 2; y++)
610 for (z = -1; z <= 1; z++)
612 for (x = -1; x <= 1; x++)
613 for (y = -1; y <= 1; y++)
614 for (z = -2; z <= 2; z++)
656 className =
"LineSE : StrElt";
661 int xf = round(length * cos(-theta * PI / 180.));
662 int yf = round(length * sin(-theta * PI / 180.));
665 vector<Point<int>> v;
668 for (
size_t i = 0; i < v.size(); i++)
713 className =
"Line3DSE : StrElt";
718 double lenXY = abs(length * cos(zeta * PI / 180.));
720 int zf = round(length * sin(zeta * PI / 180.));
721 int xf = round(lenXY * cos(-theta * PI / 180.));
722 int yf = round(lenXY * sin(-theta * PI / 180.));
726 for (
size_t i = 0; i < v.size(); i++)
757 className =
"CenteredLineSE : StrElt";
758 seT = SE_CenteredLine;
762 int xf = round(length * cos(-theta * PI / 180.) / 2);
763 int yf = round(length * sin(-theta * PI / 180.) / 2);
767 vector<Point<int>> v;
770 for (
size_t i = 0; i < v.size(); i++) {
772 if (v[i].x == 0 && v[i].y == 0 && v[i].z == 0)
774 addPoint(-v[i].x, -v[i].y, -v[i].z);
779 inline StrElt CenteredLineSE(
int length,
double theta = 0)
781 StrElt se = LineSE(length / 2 + 1, theta);
782 return se.merge(se.transpose());
817 className =
"CenteredLine3DSE : StrElt";
818 seT = SE_CenteredLine3D;
823 double lenXY = abs(length * cos(zeta * PI / 180.));
825 int zf = round(length * sin(zeta * PI / 180.));
826 int xf = round(lenXY * cos(-theta * PI / 180.));
827 int yf = round(lenXY * sin(-theta * PI / 180.));
832 for (
size_t i = 0; i < v.size(); i++) {
834 if (v[i].x == 0 && v[i].y == 0 && v[i].z == 0)
836 addPoint(-v[i].x, -v[i].y, -v[i].z);
841 inline StrElt CenteredLine3DSE(
int length,
double theta = 0,
double zeta = 0)
843 StrElt se = Line3DSE(length / 2 + 1, theta, zeta);
844 return se.merge(se.transpose());
850 inline HexSE hSE(UINT s = 1)
854 inline HexSE0 hSE0(UINT s = 1)
858 inline SquSE sSE(UINT s = 1)
862 inline SquSE0 sSE0(UINT s = 1)
866 inline CrossSE cSE(UINT s = 1)
870 inline CubeSE cbSE(UINT s = 1)
874 inline RhombicuboctahedronSE rcoSE(UINT s = 1)
876 return RhombicuboctahedronSE(s);
894 int xf = round(length * cos(theta * PI / 180.));
895 int yf = round(length * sin(theta * PI / 180.));
897 vector<Point<int>> v;
900 for (
size_t i = 0; i < v.size(); i++)
901 se.addPoint(v[i].x, v[i].y, v[i].z);
917 typename vector<IntPoint>::iterator it;
918 for (it = se1.
points.begin(); it != se1.
points.end(); it++) {
922 for (it = se2.
points.begin(); it != se2.
points.end(); it++) {
929 #define DEFAULT_SE Morpho::getDefaultSE()
Base Smil Object.
Definition: DBaseObject.h:52
Bresenham Class.
Definition: DImageDraw.h:225
vector< IntPoint > getPoints() const
getPoints() - access a vector with the points of the line
Definition: DImageDraw.h:296
CenteredLine3DSE() - constructor.
Definition: DStructuringElement.h:801
CenteredLine3DSE(int length, double theta=0, double zeta=0)
CenteredLine3DSE() -.
Definition: DStructuringElement.h:815
CenteredLineSE()
Definition: DStructuringElement.h:743
CenteredLineSE(int length, double theta=0)
CenteredLineSE() -.
Definition: DStructuringElement.h:755
3D Cross structuring element (6 neighbors).
Definition: DStructuringElement.h:565
Cross structuring element.
Definition: DStructuringElement.h:469
3D Cubic structuring element (26 neighbors).
Definition: DStructuringElement.h:531
virtual void printSelf(ostream &os=std::cout, string s="") const
printSelf() -
Definition: DGraph.hpp:578
Hexagonal structuring element without center point.
Definition: DStructuringElement.h:448
Hexagonal structuring element.
Definition: DStructuringElement.h:428
Horizontal segment structuring element.
Definition: DStructuringElement.h:490
Line3DSE - 3D structuring element of arbitrary length and direction starting at the origin.
Definition: DStructuringElement.h:696
Line3DSE(int length, double theta, double zeta)
Line3DSE() - constructor.
Definition: DStructuringElement.h:711
LineSE - a line structuring element with arbitrary length and angle.
Definition: DStructuringElement.h:641
LineSE(int length, double theta)
LineSE() - flat structuring element of arbitrary length and direction starting at the origin.
Definition: DStructuringElement.h:654
Rhombicuboctahedron struturing element (80 neighbors).
Definition: DStructuringElement.h:592
Square structuring element without center point.
Definition: DStructuringElement.h:406
Square structuring element.
Definition: DStructuringElement.h:386
Base structuring element.
Definition: DStructuringElement.h:70
string getName()
getName() - Get the name of the structuring element
Definition: DStructuringElement.h:343
StrElt(UINT s=1)
Class constructor - generic structurant element.
Definition: DStructuringElement.h:75
virtual void printSelf(string indent) const
printSelf() - Print the contents of the structuring element
Definition: DStructuringElement.h:362
StrElt(bool oddSE, vector< UINT > indexList)
Class constructor.
Definition: DStructuringElement.h:131
StrElt transpose() const
transpose() - Return the opposite SE (symmetry with respect to 0)
Definition: DStructuringElement.cpp:121
void addPoint(const UINT index)
addPoint() - Add a point to the structurant element based on an index on a grid.
Definition: DStructuringElement.cpp:69
void setName(string name)
setName() - Set the name of the structuring element
Definition: DStructuringElement.h:301
vector< IntPoint > points
List of neighbor points.
Definition: DStructuringElement.h:203
void setName()
setName() - Set the name of the structuring element
Definition: DStructuringElement.h:310
const StrElt operator()(int s=1) const
operator() -
Definition: DStructuringElement.cpp:113
void clone(const StrElt &rhs)
clone() - Clone a structuring element
Definition: DStructuringElement.cpp:61
StrElt noCenter() const
Return the SE with no center.
Definition: DStructuringElement.cpp:160
virtual void printSelf(ostream &os=std::cout, string indent="") const
printSelf() - Print the contents of the structuring element
Definition: DStructuringElement.cpp:179
UINT getSize() const
getSize() - Get the size of the Structuring Element
Definition: DStructuringElement.h:163
StrElt & operator=(const StrElt &rhs)
Clone a structuring element.
Definition: DStructuringElement.cpp:55
StrElt merge(const StrElt &rhs)
merge() - Merge a structuring element
Definition: DStructuringElement.cpp:138
IntPoint getPoint(const UINT i)
getPoint() - Get the coordinates (as a point) of the pixel of order i in the structuring element
Definition: DStructuringElement.h:153
StrElt(const StrElt &rhs)
Class constructor - clone another structuring element.
Definition: DStructuringElement.h:85
StrElt homothety(const UINT s) const
homothety() - Build and return an homothetic SE with size s
Definition: DStructuringElement.cpp:90
virtual seType getType() const
getType() - Get the type of the structuring element
Definition: DStructuringElement.h:292
Vertical segment structuring element.
Definition: DStructuringElement.h:511
vector< IntPoint > bresenhamPoints(int p1x, int p1y, int p2x, int p2y, int xMax=0, int yMax=0)
Find intermediate points forming a line between two end points, using the Bresenham Line Draw Algorit...
Definition: DImageDraw.h:62
StrElt merge(StrElt se1, StrElt se2)
merge() - merge two Structuring Elements
Definition: DStructuringElement.h:913
StrElt buildLineSE(int length, int theta)
buildLineSE() - build a line structuring element with arbitrary length and angle.
Definition: DStructuringElement.h:890