MCPcopy Create free account
hub / github.com/davisking/dlib / make_random_cropping_rect

Function make_random_cropping_rect

examples/dnn_self_supervised_learning_ex.cpp:102–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102rectangle make_random_cropping_rect(
103 const matrix<rgb_pixel>& image,
104 dlib::rand& rnd
105)
106{
107 const auto scale = rnd.get_double_in_range(0.5, 1.0);
108 const auto ratio = exp(rnd.get_double_in_range(log(3.0 / 4.0), log(4.0 / 3.0)));
109 const auto size = scale * min(image.nr(), image.nc());
110 const auto rect = move_rect(set_aspect_ratio(rectangle(size, size), ratio), 0, 0);
111 const point offset(rnd.get_integer(max(0, static_cast<int>(image.nc() - rect.width()))),
112 rnd.get_integer(max(0, static_cast<int>(image.nr() - rect.height()))));
113 return move_rect(rect, offset);
114}
115
116// A helper function to generate different kinds of augmentations.
117matrix<rgb_pixel> augment(

Callers 2

augmentFunction · 0.70
make_crop_planMethod · 0.50

Calls 13

expFunction · 0.85
logFunction · 0.85
move_rectFunction · 0.85
get_double_in_rangeMethod · 0.80
get_integerMethod · 0.80
minFunction · 0.50
set_aspect_ratioFunction · 0.50
rectangleClass · 0.50
maxFunction · 0.50
nrMethod · 0.45
ncMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected