[Insight-users] Question about upper bound in itk::Histogram class

Raghavendra Chandrashekara rc3 at doc . ic . ac . uk
Tue, 13 May 2003 12:25:33 +0100


This is a multi-part message in MIME format.
--------------040804050208030309030006
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi Folks,

Is it possible for the itk::Histogram class to hold a sample value which 
is equal to the upper bound value? I've written a simple test program 
which creates a 2D histogram and tries to increase the frequency of a 
sample value at the lower and upper bounds. The lower bound sample value 
frequency is increased by 1, but the upper bound is not. Please can you 
tell me if this is a bug or this is the expected behaviour.

Thanks,

Raghavendra

--------------040804050208030309030006
Content-Type: text/plain;
 name="Histogram.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="Histogram.cpp"

#include "itkHistogram.h"

int main()
{
  typedef itk::Statistics::Histogram<double, 2> HistogramType;

  // Initialize histogram.
  HistogramType::Pointer pHistogram = HistogramType::New();
  HistogramType::MeasurementVectorType lowerBound;
  HistogramType::MeasurementVectorType upperBound;
  HistogramType::SizeType size;
  size.Fill(1024);
  lowerBound.Fill(0);
  upperBound.Fill(255);
  pHistogram->Initialize(size, lowerBound, upperBound);

  // Add samples.
  HistogramType::MeasurementVectorType vec;
  vec[0] = 0;
  vec[1] = 0;
  pHistogram->IncreaseFrequency(vec, 1);
  vec[0] = 255;
  vec[1] = 255;
  pHistogram->IncreaseFrequency(vec, 1);

  HistogramType::Iterator it = pHistogram->Begin();
  HistogramType::Iterator end = pHistogram->End();
  while (it != end) {
    if (it.GetFrequency() > 0) {
      std::cout << "Measurement = " << it.GetMeasurementVector()
		<< "Frequency = " << it.GetFrequency() << std::endl;
    }
    ++it;
  }

  return 0;
}

--------------040804050208030309030006
Content-Type: text/plain;
 name="CMakeLists.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="CMakeLists.txt"

PROJECT(Histogram)

INCLUDE(${CMAKE_ROOT}/Modules/FindITK.cmake)

IF (ITK_USE_FILE)
  INCLUDE(${ITK_USE_FILE})
ENDIF (ITK_USE_FILE)

INCLUDE_DIRECTORIES(${VIPITK_SOURCE_DIR}/Code)
LINK_DIRECTORIES(${VIPITK_BINARY_DIR}/Code)
LINK_LIBRARIES(${ITK_LIBRARIES})

ADD_EXECUTABLE(Histogram Histogram.cpp)
--------------040804050208030309030006--