00001
00008
00009
00010 #include "threshold_algorithm.h"
00011
00012 #include "../../datasets/pixel_dataset.h"
00013 #include "../../datasets/one_byte_image_pixel_dataset.h"
00014 #include "../../datasets/two_byte_image_pixel_dataset.h"
00015 #include "../../datasets/four_byte_image_pixel_dataset.h"
00016 #include "../../datasets/one_byte_volume_pixel_dataset.h"
00017 #include "../../datasets/two_byte_volume_pixel_dataset.h"
00018 #include "../../datasets/four_byte_volume_pixel_dataset.h"
00019
00020 namespace imedgine
00021 {
00022
00023
00024
00025 ThresholdAlgorithm::ThresholdAlgorithm()
00026 {
00027 #ifdef DEBUG
00028 std::cout << "constructing threshold algorithm" << std::endl;
00029 #endif
00030 }
00031
00032
00033
00034 ThresholdAlgorithm::ThresholdAlgorithm(ThresholdAlgorithm const&)
00035 {
00036 }
00037
00038
00039
00040 ThresholdAlgorithm::~ThresholdAlgorithm()
00041 {
00042 std::cout << "destroying threshold algorithm" << std::endl;
00043 }
00044
00045
00046
00047 ThresholdAlgorithm& ThresholdAlgorithm::operator = (ThresholdAlgorithm const&)
00048 {
00049 return(*this);
00050 }
00051
00052
00053
00054 void ThresholdAlgorithm::run()
00055 {
00056 if (configuration_.get() == 0)
00057 {
00058 return;
00059 }
00060
00061 dataset_pointer_type dataset(
00062 configuration_->getDataset("threshold_input"));
00063
00064 if (dataset.get() == 0)
00065 {
00066 return;
00067 }
00068
00069 dataset_key_ = dataset->getDatasetKey();
00070
00071 std::cout << "got " << dataset_key_ << std::endl;
00072
00073 imedgine::pixel_dataset_pointer_type pixel_dataset(
00074 dataset, boost::detail::dynamic_cast_tag());
00075
00076 if (pixel_dataset.get() == 0)
00077 {
00078 return;
00079 }
00080
00081 std::cout << "running ThresholdAlgorithm with " << (unsigned int)pixel_dataset->getNumDimensions() <<
00082 " dimension, " << (unsigned int)pixel_dataset->getNumBytesPerPixel() << " bytes per pixel dataset" << std::endl;
00083
00084 switch (pixel_dataset->getNumDimensions())
00085 {
00086 case 2 :
00087 {
00088 switch (pixel_dataset->getNumBytesPerPixel())
00089 {
00090 case 1 :
00091 {
00092 one_byte_image_pixel_dataset_pointer_type image_dataset(
00093 pixel_dataset, boost::detail::dynamic_cast_tag());
00094 if (image_dataset.get() == 0)
00095 {
00096 return;
00097 }
00098 this->applyAlgorithm<one_byte_image_pointer_type>(image_dataset->getDataset());
00099 break;
00100 }
00101 case 2 :
00102 {
00103 two_byte_image_pixel_dataset_pointer_type image_dataset(
00104 pixel_dataset, boost::detail::dynamic_cast_tag());
00105 if (image_dataset.get() == 0)
00106 {
00107 return;
00108 }
00109 this->applyAlgorithm<two_byte_image_pointer_type>(image_dataset->getDataset());
00110 break;
00111 }
00112 case 4 :
00113 {
00114 four_byte_image_pixel_dataset_pointer_type image_dataset(
00115 pixel_dataset, boost::detail::dynamic_cast_tag());
00116 if (image_dataset.get() == 0)
00117 {
00118
00119 return;
00120 }
00121
00122 this->applyAlgorithm<four_byte_image_pointer_type>(image_dataset->getDataset());
00123 break;
00124 }
00125 default :
00126 {}
00127 }
00128 break;
00129 }
00130 case 3 :
00131 {
00132 switch (pixel_dataset->getNumBytesPerPixel())
00133 {
00134 case 1 :
00135 {
00136 one_byte_volume_pixel_dataset_pointer_type volume_dataset(
00137 pixel_dataset, boost::detail::dynamic_cast_tag());
00138 if (volume_dataset.get() == 0)
00139 {
00140 std::cout << "...............CAST!!!.............." << std::endl;
00141 return;
00142 }
00143 std::cout << "...............alright.............." << std::endl;
00144 this->applyAlgorithm<one_byte_volume_pointer_type>(volume_dataset->getDataset());
00145 break;
00146 }
00147 case 2 :
00148 {
00149 two_byte_volume_pixel_dataset_pointer_type volume_dataset(
00150 pixel_dataset, boost::detail::dynamic_cast_tag());
00151 if (volume_dataset.get() == 0)
00152 {
00153 return;
00154 }
00155 this->applyAlgorithm<two_byte_volume_pointer_type>(volume_dataset->getDataset());
00156 break;
00157 }
00158 case 4 :
00159 {
00160 four_byte_volume_pixel_dataset_pointer_type volume_dataset(
00161 pixel_dataset, boost::detail::dynamic_cast_tag());
00162 if (volume_dataset.get() == 0)
00163 {
00164 return;
00165 }
00166 this->applyAlgorithm<four_byte_volume_pointer_type>(volume_dataset->getDataset());
00167 break;
00168 }
00169 default :
00170 {}
00171 }
00172 break;
00173 }
00174 }
00175 }
00176
00177 }