Img2dul
image (image with Ulong pixels). It implies that all image member functions are applicable to a region map.
The class Reg2d.
Reg1d:
region map in 1D;Reg2d:
region map in 2D;Reg3d:
region map in 3D.Long Width()
: returns the number of columns;Long Height()
: returns the number of rows;Long Depth()
: returns the number of planes;Dimension2d Size()
: returns the size as dimension;int VectorSize()
: returns the size of the data vector;Long Labels()
: returns the higher label value;Long Labels(Long labelmax)
: sets the higher label value;PobjectProps Props()
: returns a structure with the region attribute values.Reg2d rgs1(256,512); // Data: 256 rows, 512 columns Reg2d rgs2(rgs1.Size()); // Data: same size than rgs1 Reg2d rgs3; // No data Reg2d *rgs4=new Reg2d; // No data
The creation of a region map from the properties of an other Pandore object can be done by using:
Reg2d rgs1(ims2.Props()); // same size than ims1
New()
creates the data array -if data already exist they are first deleted. For example: Reg2d rgs3; rgs3.New(256,512); Reg2d *rgs4; rgs4->New(256,512);
Reg2d rgs(256,256); rgs = 0; // This also sets Labels(0). rgs = 127; // This also sets Labels(127).
Ulong *d = (Ulong*)malloc(128*256*sizeof(Ulong)); Reg2d rgs1(256,128,d); Reg2 *rgs2 = new Reg2(256,128,d); rgs1.delete(); delete rgs2; free(d);
Reg3d *rgs= new Reg3d(12,200,256); for(d=0;d<rgs->Depth();d++) { Reg2d *regii=new Reg2d(rgs->Height(),rgs->Width(),&(*rgs)(d,0,0)); Reg2d *regio = new Reg2d(regii->Props()); gauss:Gauss(*regii,*regio,2.0F); *regii=*regio; delete regii; delete regio; }
Delete()
. For example: Reg2d rgs1(120,245);
rgs1.Delete();
Reg2d rgs4 = new Reg2d(120,245);
rgs4->Delete();
rgs4->New(400,200);
rgs1(i,j)=15; (*rgs4)(i,j)=15; Point2d pt(10,20); rgs1[pt]=15;
Vector()
Reg2d rgs(256,512);
for (Ulong *p=rgs.Vector(); *p< rgs.Vector()+rgs.VectorSize();)
*p++ = 15;
X()
Reg2d reg1(10,20); Reg3d reg2(123,124,120); ULong **d=reg1.X(); Ulong ***d1=reg2.X();
Reg2d reg;
reg.SaveFile("foobar.pan");
To load an region map from a file, just use:
Reg2d reg;
reg.LoadFile("foobar.pan");
Hold()
tests whether a point is in or out of the region map boundary. For example: Reg2d rgs(100,200); Point2d p(-1,-1); rgs.Hold(p); // returns false; rgs.Hold(5,10); // returns true; rgs.Hold(10,199); // returns true; rgs.Hold(10,200); // returns false;
The member function Frame()
sets the border of the region with a given value or with the pixel of a given region. For example:
rgs2.Frame(127,5); // set the border (5x5) with the value 127. rgs2.Frame(rgs1,5,6); // set the border (5x6) with the pixel of the region rgs1.