X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FpPlotter%2FpHistogram.cxx;h=c14e9511348f57ac1bf39256258777ebdfbaf2d9;hb=dea0efc567d8332b2e7eb936e3ba4ac1c11b2542;hp=19a2af26fdd5a52a5382221e5367b1cebb286b3e;hpb=cc00f80af2e160ce2af3ddd2903c4a41c023cc94;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx index 19a2af2..c14e951 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx @@ -1,3 +1,28 @@ +/*# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sant�) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ */ + //---------------------------------------------------------------------------- // Class definition include @@ -6,10 +31,11 @@ #include "pHistogram.h" //#include "vtkJPEGReader.h" #include "vtkImageData.h" -#include "vtkImageCast.h" -//----------------- -// C++ -//----------------- +#include "vtkImageCast.h" +#include "vtkComputeHistogram2DOutliers.h" +#include "vtkTable.h" + + #include #include #include @@ -36,42 +62,34 @@ //---------------------------------------------------------------------------- pHistogram::pHistogram(std::string filePath) { - path=filePath; - points= vtkImageData::New(); - size=100; - sizeImage=0; + path = filePath; + points = vtkImageData::New(); + size = 100; + sizeImage = 0; buildHistogram(); } pHistogram::pHistogram(vtkImageData* imageData) { - points= vtkImageData::New(); - size=100; - sizeImage=0; - //cast - /* - vtkImageCast* cast= vtkImageCast::New(); - cast->SetInput(imageData); - cast->SetOutputScalarTypeToInt(); - cast->Update(); - */ - //build the histogram + points = vtkImageData::New(); + size = 100; + sizeImage = 0; buildHistogram(imageData); } +//---------------------------------------------------------------------------- pHistogram::~pHistogram() { if(points!=NULL)points->Delete(); } -//---------------------------------------------------------------------------- -// Methods -//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- void pHistogram::setImagePath(std::string filePath) { path=filePath; } +//---------------------------------------------------------------------------- void pHistogram::buildHistogram() { /* @@ -95,7 +113,6 @@ void pHistogram::buildHistogram() imageData->GetScalarRange(range); initializePoints(size); setPoints(imageData); - } /* @@ -117,7 +134,8 @@ void pHistogram::initializePoints(int xDimension) { //setting image data of the points points->SetDimensions(xDimension,1,1); - points->SetScalarTypeToUnsignedShort(); +//EED points->SetScalarTypeToUnsignedShort(); + points->SetScalarTypeToDouble(); points->AllocateScalars(); points->Update(); } @@ -127,28 +145,47 @@ void pHistogram::initializePoints(int xDimension) */ void pHistogram::setPoints(vtkImageData* imageData) { + +printf("EED pHistogram::setPoints Trinng new histogram ..\n"); +/* +printf("EED pHistogram::setPoints Test: vtkPComputeHistogram2DOutliers\n"); +vtkComputeHistogram2DOutliers *vtkhist = vtkComputeHistogram2DOutliers::New(); +vtkhist->SetPreferredNumberOfOutliers(10); +vtkhist->SetInput(imageData); +vtkTable *resulttable = vtkhist->GetOutputTable(); + +printf("EED pHistogram::setPoints rows:%d\n", (int)(resulttable->GetNumberOfRows()) ); +printf("EED pHistogram::setPoints colums:%d\n", (int)(resulttable->GetNumberOfColumns()) ); +*/ + /* Pointers */ - unsigned short* dataImagePointer=NULL; - unsigned short* dataHistogramPointer=NULL; - dataImagePointer=(unsigned short*)imageData->GetScalarPointer(0,0,0); - dataHistogramPointer=(unsigned short*)points->GetScalarPointer(0,0,0); + char* dataImagePointerC = (char*)imageData->GetScalarPointer(0,0,0); + unsigned char* dataImagePointerUC = (unsigned char*)imageData->GetScalarPointer(0,0,0); + short* dataImagePointerS = (short*)imageData->GetScalarPointer(0,0,0); + unsigned short* dataImagePointerUS = (unsigned short*)imageData->GetScalarPointer(0,0,0); + float* dataImagePointerF = (float*)imageData->GetScalarPointer(0,0,0); + double* dataImagePointerD = (double*)imageData->GetScalarPointer(0,0,0); + double* dataHistogramPointer = (double*)points->GetScalarPointer(0,0,0); /* Range of greys */ double range[2]; if(imageData==NULL) - range[1]=1; - else + { + range[1] = 1; + } else { imageData->GetScalarRange(range); + } // imageData + /* Setting the minimun and maximum levels of grey */ - maxLevelOfGrey=(int)range[1]; - minLevelOfGrey=(int)range[0]; + maxLevelOfGrey = range[1]; + minLevelOfGrey = range[0]; //std::cout<<"maxLevelOfGrey "<GetExtent(ext); int sx,sy,sz; - sx=ext[1]+1; - sy=ext[3]+1; - sz=ext[5]+1; + sx = ext[1]-ext[0]+1; + sy = ext[3]-ext[2]+1; + sz = ext[5]-ext[4]+1; sizeImage=sx*sy*sz; @@ -171,35 +208,75 @@ void pHistogram::setPoints(vtkImageData* imageData) dataHistogramPointer[i]=0; } - /* - Constructing the Histogram - */ - //int k=size/(maxLevelOfGrey-minLevelOfGrey); - int j=0; - for(i=0;iGetScalarType()==VTK_CHAR) { - /* - hashing the histogram - */ - //double p=((float)*dataImagePointer-minLevelOfGrey); - //j=p*k; - - j=getIndex(*dataImagePointer); - //std::cout<GetScalarType()==VTK_UNSIGNED_CHAR) { - k=dataHistogramPointer[i]; - } - */ + for(i=0;iGetScalarType()==VTK_SHORT) + { + for(i=0;iGetScalarType()==VTK_UNSIGNED_SHORT) + { + for(i=0;iGetScalarType()==VTK_FLOAT) + { + for(i=0;iGetScalarType()==VTK_DOUBLE) + { + for(i=0;iGetScalarPointer(0,0,0); - + double* dataHistogramPointer = dataHistogramPointer=(double*)points->GetScalarPointer(0,0,0); return dataHistogramPointer[gValue]; }