24 return m_regionHandle;
29 return &m_regionHandle;
35 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Create(&m_regionHandle);
41 std::vector<peak_common_point> cPoints(points.size());
42 std::transform(points.begin(), points.end(), cPoints.begin(), [](
const auto& cppPoint) -> peak_common_point {
43 return { cppPoint.GetX(), cppPoint.GetY() };
46 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_CreateFromPoints(&m_regionHandle, cPoints.data(), cPoints.size());
53 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_CreateFromRectangle(
54 &m_regionHandle, peak::common::detail::BackendAccessor<peak::common::Rectangle>::CreateCType(rect));
58inline Region::Region(peak_icv_region_handle regionHandle) noexcept
59 : m_regionHandle{ regionHandle }
62inline Region::Region(
const Region& other)
64 if (m_regionHandle != other.m_regionHandle)
67 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_IncreaseUseCount(other.m_regionHandle);
69 m_regionHandle = other.m_regionHandle;
73inline Region::Region(
Region&& other)
noexcept
75 if (m_regionHandle != other.m_regionHandle)
77 m_regionHandle = other.m_regionHandle;
78 other.m_regionHandle =
nullptr;
82inline Region::~Region()
86 PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Destroy(m_regionHandle);
92 if (m_regionHandle != other.m_regionHandle)
97 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Destroy(m_regionHandle);
102 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_IncreaseUseCount(other.m_regionHandle);
104 m_regionHandle = other.m_regionHandle;
112 if (m_regionHandle != other.m_regionHandle)
117 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Destroy(m_regionHandle);
121 m_regionHandle = other.m_regionHandle;
122 other.m_regionHandle =
nullptr;
128inline std::vector<peak::common::Point> Region::GetPoints()
const
130 size_t numPoints = 0;
132 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_GetPoints_GetCount(m_regionHandle, &numPoints);
140 std::vector<peak_common_point> points(numPoints);
141 std::vector<peak::common::Point> cppPoints{};
142 cppPoints.reserve(numPoints);
145 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_GetPoints(m_regionHandle, points.data(), numPoints);
148 std::transform(points.begin(), points.end(), std::back_inserter(cppPoints), [](
const auto& cPoint) {
149 return peak::common::detail::BackendAccessor<peak::common::Point>::CreateInstance(cPoint);
155inline std::vector<Region> Region::GetConnectedComponents()
const
157 size_t numConnectedComponents = 0;
160 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_GetConnectedComponents_GetCount(m_regionHandle, &numConnectedComponents);
163 if (numConnectedComponents == 0)
168 std::vector<peak_icv_region_handle> regionHandles(numConnectedComponents);
171 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Array_Create(regionHandles.data(), numConnectedComponents);
175 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_GetConnectedComponents(m_regionHandle, regionHandles.data(), numConnectedComponents);
178 return peak::common::detail::BackendAccessor<Region>::CreateInstances(regionHandles);
181inline size_t Region::GetArea()
const
186 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_GetArea(m_regionHandle, &area);
194 peak_common_point_f centerOfGravity{};
197 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_GetCenterOfGravity(m_regionHandle, ¢erOfGravity);
200 return peak::common::detail::BackendAccessor<peak::common::PointF>::CreateInstance(centerOfGravity);
203inline bool Region::operator==(
const Region& rhs)
const
205 if (m_regionHandle == rhs.m_regionHandle)
210 bool is_equal =
false;
212 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Compare(m_regionHandle, rhs.m_regionHandle, &is_equal);
218inline bool Region::operator!=(
const Region& rhs)
const
220 return !(*
this == rhs);
225 const auto imageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(image);
226 const auto optionsC = peak::common::detail::BackendAccessor<detail::DrawingOptions>::CreateCType(options);
228 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Draw(imageHandle, m_regionHandle, optionsC);
236 const auto otherHandle = peak::common::detail::BackendAccessor<Region>::BackendHandle(other);
237 const auto outputRegionHandleAddress = peak::common::detail::BackendAccessor<Region>::BackendHandleAddress(outputRegion);
238 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Intersection(m_regionHandle, otherHandle, outputRegionHandleAddress);
247 const auto otherHandle = peak::common::detail::BackendAccessor<Region>::BackendHandle(other);
248 const auto outputRegionHandleAddress = peak::common::detail::BackendAccessor<Region>::BackendHandleAddress(outputRegion);
249 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Difference(m_regionHandle, otherHandle, outputRegionHandleAddress);
258 const auto otherHandle = peak::common::detail::BackendAccessor<Region>::BackendHandle(other);
259 const auto outputRegionHandleAddress = peak::common::detail::BackendAccessor<Region>::BackendHandleAddress(outputRegion);
260 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Union(m_regionHandle, otherHandle, outputRegionHandleAddress);
269 const auto seHandle = peak::common::detail::BackendAccessor<Region>::BackendHandle(structuringElement);
270 const auto outputRegionHandleAddress = peak::common::detail::BackendAccessor<Region>::BackendHandleAddress(outputRegion);
271 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Dilation(m_regionHandle, seHandle, outputRegionHandleAddress);
280 const auto seHandle = peak::common::detail::BackendAccessor<Region>::BackendHandle(structuringElement);
281 const auto outputRegionHandleAddress = peak::common::detail::BackendAccessor<Region>::BackendHandleAddress(outputRegion);
282 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Erosion(m_regionHandle, seHandle, outputRegionHandleAddress);
292 const auto outputRegionHandleAddress = peak::common::detail::BackendAccessor<Region>::BackendHandleAddress(outputRegion);
293 return PEAK_ICV_C_ABI_PREFIX peak_icv_Region_Scale(m_regionHandle, { inputSize.
GetWidth(), inputSize.
GetHeight() },
294 { outputSize.
GetWidth(), outputSize.
GetHeight() },
static_cast<peak_icv_interpolation
>(interpolation),
295 outputRegionHandleAddress);
A generic rectangle defined by a point and a size.
Represents a two-dimensional size with non-negative width and height.
constexpr T GetWidth() const
Returns the width.
constexpr T GetHeight() const
Returns the height.
For detailed information about the use of ids_peak_icv Image refer to the Image Guide.
A region consists of a set of points in the image plane.
Region()
Creates an empty Region.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
peak::common::detail::c_type_of_t< Type > * handle_of_t