| 1125 | } |
| 1126 | |
| 1127 | void mitk::MultiLabelSegmentation::InitializeByLabeledImage(const Image* image) |
| 1128 | { |
| 1129 | if (nullptr == image || image->IsEmpty() || !image->IsInitialized()) |
| 1130 | mitkThrow() << "Invalid labeled image."; |
| 1131 | |
| 1132 | try |
| 1133 | { |
| 1134 | this->Initialize(image, true, true); |
| 1135 | auto groupImage = this->GetGroupImage(0); |
| 1136 | |
| 1137 | if (groupImage->GetDimension() == 3) |
| 1138 | { |
| 1139 | AccessTwoImagesFixedDimensionByItk(groupImage, image, InitializeByLabeledImageProcessing, 3); |
| 1140 | } |
| 1141 | else if (groupImage->GetDimension() == 4) |
| 1142 | { |
| 1143 | AccessTwoImagesFixedDimensionByItk(groupImage, image, InitializeByLabeledImageProcessing, 4); |
| 1144 | } |
| 1145 | else |
| 1146 | { |
| 1147 | mitkThrow() << image->GetDimension() << "-dimensional label set images not yet supported"; |
| 1148 | } |
| 1149 | } |
| 1150 | catch (Exception& e) |
| 1151 | { |
| 1152 | mitkReThrow(e) << "Could not initialize by provided labeled image."; |
| 1153 | } |
| 1154 | catch (...) |
| 1155 | { |
| 1156 | mitkThrow() << "Could not initialize by provided labeled image due to unknown error."; |
| 1157 | } |
| 1158 | |
| 1159 | if (this->GetNumberOfLabels(0) > 0) |
| 1160 | { |
| 1161 | m_ActiveLabelValue = this->GetLabelValuesByGroup(0).front(); |
| 1162 | } |
| 1163 | |
| 1164 | this->Modified(); |
| 1165 | } |
| 1166 | |
| 1167 | namespace |
| 1168 | { |