Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

RectObjectArea.hpp

00001 #ifndef __RectObjectArea__
00002 #define __RectObjectArea__
00003 
00004 
00023 #include <stdio.h>
00024 
00025 #include "RectObjectArea.hpp"
00026 
00027 
00028 class RectObjectArea
00029 {
00030 private:
00031 
00032 int                             label;
00033 
00034 int                             x0, y0;
00035 int                             x1, y1;
00036 
00037 public:
00038         
00039 RectObjectArea(int id, int xa, int ya, int xb, int yb)
00040         { 
00041         label=id; 
00042 
00043         if( xa < xb )
00044                 {
00045                 x0= xa;
00046                 x1= xb;
00047                 }
00048         else
00049                 {
00050                 x0= xb;
00051                 x1= xa;
00052                 }
00053 
00054         if( ya < yb )
00055                 {
00056                 y0= ya;
00057                 y1= yb;
00058                 }
00059         else
00060                 {
00061                 y0= yb;
00062                 y1= ya;
00063                 }
00064         }
00065 
00066 RectObjectArea(FILE* file)                      // reading from file stream
00067 {
00068 char    line[128];
00069  
00070 fgets(line, 128, file);
00071 sscanf(line,"%d %d %d %d %d", &label, &x0, &y0, &x1, &y1);
00072 }
00073 
00074 ~RectObjectArea(){}
00075 
00076 
00077 int getLabel(){ return label; }
00078 void setLabel(int l){ label = l; }
00079 
00080 int getX0(){ return x0; }
00081 int getY0(){ return y0; }
00082 int set0(int x, int y){ x0= x; y0= y; }
00083 
00084 int getX1(){ return x1; }
00085 int getY1(){ return y1; }
00086 int set1(int x, int y){ x1= x; y1= y; }
00087 
00088 int numberOfPixels(){ return (x1-x0+1)*(y1-y0+1); }
00089 
00090 // I/O operations
00091 void write(FILE* file)
00092 { 
00093 fprintf(file, "%d %d %d %d %d \t: %s\n", 
00094                                 label, x0, y0, x1, y1,
00095                                 (label == 0 ? "background" : "object") ); 
00096 }
00097 
00098 void output(){ printf("label=%d, (%d,%d)-(%d,%d)\n", label, x0, y0, x1, y1); }
00099 };
00100 
00101 
00102 #endif
SourceForge.net Logo
Restoreinpaint sourceforge project `C++/Java Image Processing, Restoration, Inpainting Project'.

Bernard De Cuyper: Open Project Leader: Concept, design and development.
Bernard De Cuyper & Eddy Fraiha 2002, 2003. Bernard De Cuyper 2004. Open and free, for friendly usage only.
Modifications on Belgium ground of this piece of artistic work, by governement institutions or companies, must be notified to Bernard De Cuyper.
bern_bdc@hotmail.com