void Blob::ComputeLabels(IImage& Source, ImageBuffer& Labels, int ConnectType) { if (ConnectType != 4 && ConnectType != 8) throw cl::Error(CL_INVALID_VALUE, "Wrong connect type in Blob::ComputeLabels"); if (Labels.Depth() != 32 || Labels.IsFloat()) throw cl::Error(CL_INVALID_VALUE, "Wrong Labels image type in Blob::ComputeLabels - Labels must be 32 bit integer"); if (m_TempBuffer == nullptr) PrepareFor(Source); CheckSameSize(Source, Labels); CheckCompatibility(Labels, *m_TempBuffer); m_BlobInfo.Init(ConnectType); m_InfoBuffer.Send(); // Initialize the label image Kernel(init_label, Source, Out(Labels, *m_TempBuffer), Labels.Step(), m_TempBuffer->Step(), m_InfoBuffer); // These two labeling steps need to be executed at least twice each int i = 0; while (i <= m_BlobInfo.LastUsefulIteration) { i++; Kernel(label_step1, Labels, *m_TempBuffer, Labels.Step(), m_TempBuffer->Step(), m_InfoBuffer, i); Kernel(label_step2, Labels, *m_TempBuffer, Labels.Step(), m_TempBuffer->Step(), m_InfoBuffer, i); if (i >= 2) m_InfoBuffer.Read(true); } }
void Blob::RenameLabels(ImageBuffer& Labels) { if (Labels.Depth() != 32 || Labels.IsFloat()) throw cl::Error(CL_INVALID_VALUE, "Wrong Labels image type in Blob::RenameLabels - Labels must be 32 bit integer"); if (m_TempBuffer == nullptr) throw cl::Error(CL_INVALID_MEM_OBJECT, "Wrong Labels image type in Blob::RenameLabels - Labels must be 32 bit integer"); CheckCompatibility(Labels, *m_TempBuffer); // Rename the labels Kernel(reorder_labels1, Labels, *m_TempBuffer, Labels.Step(), m_TempBuffer->Step(), m_InfoBuffer); Kernel(reorder_labels2, Labels, *m_TempBuffer, Labels.Step(), m_TempBuffer->Step(), m_InfoBuffer); m_InfoBuffer.Read(true); }