24 #include <fvutils/base/roi.h> 47 ROI* ROI::roi_full_image = NULL;
54 start.x = start.y = width = height = image_width = image_height = line_step = pixel_step = 0;
67 ROI::ROI(
unsigned int start_x,
unsigned int start_y,
68 unsigned int width,
unsigned int height,
69 unsigned int image_width,
unsigned int image_height)
75 this->height = height;
76 this->image_width = image_width;
77 this->image_height = image_height;
78 line_step = image_width;
87 ROI::ROI(
const ROI &roi)
136 ROI::set_start(
unsigned int x,
unsigned int y)
147 ROI::set_width(
unsigned int width)
157 ROI::get_width()
const 167 ROI::set_height(
unsigned int height)
169 this->height = height;
177 ROI::get_height()
const 188 ROI::set_image_width(
unsigned int image_width)
190 this->image_width = image_width;
199 ROI::get_image_width()
const 210 ROI::set_image_height(
unsigned int image_height)
212 this->image_height = image_height;
221 ROI::get_image_height()
const 233 ROI::set_line_step(
unsigned int step)
244 ROI::get_line_step()
const 256 ROI::set_pixel_step(
unsigned int step)
267 ROI::get_pixel_step()
const 279 ROI::get_hint()
const 290 ROI::set_hint(
unsigned int hint)
302 ROI::contains(
unsigned int x,
unsigned int y)
304 if ( (x >= start.x) &&
305 (x < start.x+width) &&
307 (y < start.y+height) ) {
309 num_hint_points += 1;
323 ROI::intersect(
ROI const &roi)
const 326 if (start.x + width <= roi.
start.
x 328 || start.y + height <= roi.
start.
y 363 ROI::neighbours(
unsigned int x,
unsigned int y,
unsigned int margin)
const 365 return ( (static_cast<int>(x) >= static_cast<int>(start.x) - static_cast<int>(margin)) &&
366 (x <= start.x + width + margin) &&
367 (static_cast<int>(y) >= static_cast<int>(start.y) - static_cast<int>(margin)) &&
368 (y <= start.y + height + margin) );
380 ROI::neighbours(
ROI *roi,
unsigned int margin)
const 383 bool overlapping_x = neighbours(roi->
start.
x, start.y, margin)
384 || neighbours(roi->
start.
x + roi->
width, start.y, margin)
391 || neighbours(start.x, roi->
start.
y, margin)
392 || neighbours(start.x, roi->
start.
y + roi->
height, margin);
394 return overlapping_x && overlapping_y;
403 ROI::extend(
unsigned int x,
unsigned int y)
406 if (x < start.x) { width += start.x - x; start.x = x; }
407 if (y < start.y) { height += start.y - y; start.y = y; }
408 if (x >= start.x + width) { width += (x - (start.x + width) + 1); }
409 if (y >= start.y + height) { height += (y - (start.y + height) + 1); }
411 num_hint_points += 1;
419 ROI::grow(
unsigned int margin)
421 if (start.x < margin) {
427 if (start.y < margin) {
433 if ((start.x + width + margin) > image_width) {
434 width += (image_width - (start.x + width));
439 if ((start.y + height + margin) > image_height) {
440 height += (image_height - (start.y + height));
459 if (roi.
start.
y < start.y) { height += start.y - roi.
start.
y; start.y = roi.
start.
y; }
474 ROI::operator<(
const ROI &roi)
const 485 ROI::operator>(
const ROI &roi)
const 498 ROI::operator==(
const ROI &roi)
const 500 return (start.x == roi.
start.
x) &&
501 (start.y == roi.
start.
y) &&
502 (width == roi.
width) &&
508 (hint == roi.
hint) &&
509 (color == roi.
color) &&
521 ROI::operator!=(
const ROI &roi)
const 532 ROI::operator=(
const ROI &roi)
534 this->start.x = roi.
start.
x;
535 this->start.y = roi.
start.
y;
536 this->width = roi.
width;
537 this->height = roi.
height;
542 this->hint = roi.
hint;
543 this->color = roi.
color;
556 ROI::get_roi_buffer_start(
unsigned char *buffer)
const 558 return (buffer + (start.y * line_step) + (start.x * pixel_step));
580 ROI::get_num_hint_points()
const 582 return num_hint_points;
597 ROI::full_image(
unsigned int width,
unsigned int height)
599 if (roi_full_image == NULL) {
600 roi_full_image =
new ROI();
601 roi_full_image->start.x = 0;
602 roi_full_image->start.y = 0;
603 roi_full_image->pixel_step = 1;
605 roi_full_image->width = width;
606 roi_full_image->height = height;
607 roi_full_image->image_width = roi_full_image->width;
608 roi_full_image->image_height = roi_full_image->height;
609 roi_full_image->line_step = roi_full_image->width;
611 return roi_full_image;
Fawkes library namespace.
fawkes::upoint_t start
ROI start.
unsigned int y
y coordinate
bool neighbours(unsigned int x, unsigned int y, unsigned int margin) const
Check if this ROI neighbours a pixel.
unsigned int x
x coordinate
unsigned int width
ROI width.
unsigned int image_width
width of image that contains this ROI
unsigned int image_height
height of image that contains this ROI
Point with cartesian coordinates as unsigned integers.
unsigned int hint
ROI hint.
unsigned int height
ROI height.
unsigned int line_step
line step
unsigned int num_hint_points
Minimum estimate of points in ROI that are attributed to the ROI hint.
unsigned int pixel_step
pixel step
color_t color
ROI primary color.