120 using PriorityQueueType =
122 PriorityQueueType priorityQueue;
127 for (
typename ImageType::Iterator it(this->
GetLabelMap()); !it.IsAtEnd(); ++it)
132 labelObject->Optimize();
134 typename LabelObjectType::ConstLineIterator lit(labelObject);
135 while (!lit.IsAtEnd())
142 labelObject->Clear();
148 if (priorityQueue.empty())
154 using LinesType =
typename std::deque<LineOfLabelObject>;
157 lines.push_back(priorityQueue.top());
162 while (!priorityQueue.empty())
168 bool newMainLine =
false;
172 if (idx[i] != prevIdx[i])
178 assert(newMainLine || (idx[0] >= prevIdx[0]));
190 if (prevIdx[0] + prevLength > idx[0])
199 const typename TAttributeAccessor::AttributeValueType prevAttr = accessor(prev.
labelObject);
200 const typename TAttributeAccessor::AttributeValueType attr = accessor(l.
labelObject);
233 if (prevIdx[0] + prevLength > idx[0] + length)
239 newIdx[0] = idx[0] + length;
244 prevLength = idx[0] - prevIdx[0];
247 assert(prevIdx[0] <= idx[0]);
248 lines.back().line.SetLength(idx[0] - prevIdx[0]);
263 if (prevIdx[0] + prevLength >= idx[0] + length)
270 newIdx[0] = prevIdx[0] + prevLength;
274 l.
line.SetIndex(newIdx);
275 l.
line.SetLength(newLength);
278 priorityQueue.push(l);
292 prevIdx = prev.
line.GetIndex();
296 for (
size_t i = 0; i < lines.size(); ++i)
303 typename ImageType::Iterator it(this->
GetLabelMap());
304 while (!it.IsAtEnd())
306 const typename LabelObjectType::LabelType label = it.GetLabel();
309 if (labelObject->Empty())