X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2FContour%2FContourExtractData.cxx;h=4e32b1e7990c9b767e5038a829c55c2148441699;hb=6e940f8b87d85a90438f01d56c3c6c92da2bc14a;hp=e64fa03a444370e831d5e8e3162e631fd35192d8;hpb=8e7ab74a199d1f05b01dccfb75da7f2c4754ddc5;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx index e64fa03..4e32b1e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx @@ -69,6 +69,10 @@ void ContourExtractData::GetMinMaxPoint(int *minPoint, if (x>maxPoint[0]){ maxPoint[0]=(int)x; } if (y>maxPoint[1]){ maxPoint[1]=(int)y; } } + minPoint[0]--; + minPoint[1]--; + maxPoint[0]++; + maxPoint[1]++; //------------------------------------------------------------------------------------------------------ } @@ -91,6 +95,7 @@ int ContourExtractData::AnalisisContourInside(int x, manualContourModel *manualcontourmodel ) { + bool inBorder=false; int result = 0; int i; //int np = manualcontourmodel->GetSizeLstPoints( ); // number of control points // JPRx @@ -98,8 +103,8 @@ int ContourExtractData::AnalisisContourInside(int x, // JSTG 26-02-08 --------------------------------------------------------------------------------------- //int nps = manualviewbaseecontour->GetNumberOfPointsSpline(); // number of points in the spline int nps = manualcontourmodel->GetNumberOfPointsSpline(); // number of points in the spline - //double x1,y1,z1,x2,y2,z2,t; double x1,y1,z1,x2,y2,z2; + double borderX, borderY; double xx1, yy1,xx2, yy2; //double delta=( double ) ( np ) / ( double ) ( nps ); manualcontourmodel->UpdateSpline(); @@ -109,26 +114,55 @@ int ContourExtractData::AnalisisContourInside(int x, // if (np>=2) // { // JSTG 26-02-08 --------------------------------------------------------------------------------------- - nps--; +// nps--; //manualcontourmodel->GetSplinePoint(0,x1,y1,z1); manualcontourmodel->GetSpline_i_Point(0,&x1,&y1,&z1); + x1=x1+0.5; y1=y1+0.5; for (i=1; i<=nps; i++) { + borderX=x1; + borderY=y1; + ok=false; //t= delta * (double)(i%nps); //manualcontourmodel->GetSplinePoint(t,x2,y2,z2); manualcontourmodel->GetSpline_i_Point(i,&x2,&y2,&z2); + x2=x2+0.5; y2=y2+0.5; //------------------------------------------------------------------------------------------------------ + //by triangle similarity if ( ((y1=y1)&&(yy2)&&(y<=y1)&&(y>y2)) ) { if (y1xx2)&&(x<(xx1-d))) ) { result++; } - } // if + if ( (xx1xx2)&&(x<(xx1-d)) ) { + result++; + borderX=xx1-d; + borderY=y; + } + } // if point inside contour + + + //Border verication + if ( (x==(int)borderX) && (y==(int)borderY) ) + { + inBorder=true; + i=nps; + }// if point in border + x1=x2; y1=y2; z1=z2; + } // for i // } //if + + if (inBorder==true) { result=1; } + return result; } @@ -197,22 +231,62 @@ double ContourExtractData::GetDataValue(int x, int y, int z) void *p; p = imagedata->GetScalarPointer(x,y,z); - if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR) - { unsigned char *pp = (unsigned char*)p; + if (imagedata->GetScalarType()==VTK_CHAR) + { + char *pp = (char*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_SIGNED_CHAR) + { + signed char *pp = (signed char*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR) + { + unsigned char *pp = (unsigned char*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_SHORT) + { + short *pp = (short*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT) + { + unsigned short *pp = (unsigned short*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_INT) + { + int *pp = (int*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_UNSIGNED_INT) + { + unsigned int *pp = (unsigned int*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_LONG) + { + long *pp = (long*)p; result = (double)(*pp); } - if (imagedata->GetScalarType()==VTK_FLOAT) - { float *pp = (float*)p; + else if (imagedata->GetScalarType()==VTK_UNSIGNED_LONG) + { + unsigned long *pp = (unsigned long*)p; result = (double)(*pp); } - if (imagedata->GetScalarType()==VTK_SHORT) - { short *pp = (short*)p; + else if (imagedata->GetScalarType()==VTK_FLOAT) + { + float *pp = (float*)p; result = (double)(*pp); } - if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT) - { unsigned short *pp = (unsigned short*)p; + else if (imagedata->GetScalarType()==VTK_DOUBLE) + { + double *pp = (double*)p; result = (double)(*pp); } + return result; } @@ -241,7 +315,11 @@ void ContourExtractData::ResetImageResult(int z) int ext[6]; imagedataValueResult->GetExtent(ext); - int i,size = (ext[1]-ext[0]+1) * (ext[3]-ext[2]+1); + int size = (ext[1]-ext[0]+1) * (ext[3]-ext[2]+1); + memset(pValue,0,size*2); + memset(pMask,0,size*2); + /* + int i; for(i=0; iModified(); imagedataMaskResult->Modified(); - } + imagedataValueResult->Update(); + imagedataMaskResult->Update(); + } // if } @@ -320,9 +402,9 @@ void ContourExtractData::GetValuesInsideCrown(std::vector *pLstValue, GetMinMaxPoint_Of_LstManConMod(minPoint,maxPoint); - for (j=minPoint[1]; jSetSpacing(spc); imagedataMaskResult->SetDimensions( newDim ); imagedataMaskResult->AllocateScalars(); + printf("EED ContourExtractData::InitVtkImagesResult %p %p\n", imagedataValueResult, imagedataMaskResult); } +//------------------------------------------------------------------------ +void ContourExtractData::InitVolumeStatistics() +{ + vol_rCountRange = 0; + vol_rsize = 0; + vol_minValue = 9999999; + vol_maxValue =-9999999; + vol_acum_average = 0; + vol_acum_standardeviation = 0; +} + +//------------------------------------------------------------------------ +void ContourExtractData::SetVolumeStatistics(int rCountRange, + int rsize, + double minValue, + double maxValue, + double acum_average, + double acum_standardeviation) +{ + vol_rCountRange = vol_rCountRange + rCountRange; + vol_rsize = vol_rsize + rsize; + + if (minValuevol_maxValue){ vol_maxValue = maxValue; } + + vol_acum_average = vol_acum_average + acum_average; + vol_acum_standardeviation = vol_acum_standardeviation + acum_standardeviation; +} + +//------------------------------------------------------------------------ +void ContourExtractData::GetVolumeStatistics(int *vol_rCountRange, + int *vol_rsize, + double *vol_minValue, + double *vol_maxValue, + double *vol_average, + double *vol_standardeviation) +{ + *vol_rCountRange = this->vol_rCountRange; + *vol_rsize = this->vol_rsize; + *vol_minValue = this->vol_minValue; + *vol_maxValue = this->vol_maxValue; + *vol_average = this->vol_acum_average / this->vol_rsize; + *vol_standardeviation = sqrt(this->vol_acum_standardeviation / this->vol_rsize); +} + //------------------------------------------------------------------------ void ContourExtractData::Statistics( std::vector *inputLstValue, @@ -411,15 +540,17 @@ void ContourExtractData::Statistics( std::vector *inputLstValue, double *rmin, double *rmax, double *raverage, - double *rstandardeviation) + double *rstandardeviation + ) { - double min = 0; - double max = 0; - double average = 0; - double standardeviation = 0; - double acum = 0; - int size = 0; - int countRange = 0; + double min = 0; + double max = 0; + double average = 0; + double standardeviation = 0; + double acum_average = 0; + double acum_standardeviation = 0; + int size = 0; + int countRange = 0; double ng; if (inputLstValue!=NULL) @@ -433,25 +564,27 @@ void ContourExtractData::Statistics( std::vector *inputLstValue, for ( i=0; ing) min=ng; // Min if ((ng>=grayRangeMin) && (ng<=grayRangeMax)) countRange++; // countRange - } - average = acum / size; + } // for average + average = acum_average / size; // Standar Deviation - acum=0; + acum_standardeviation=0; double tmp; for ( i=0; i