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

Function make_random_cropping_rect

examples/dnn_semantic_segmentation_train_ex.cpp:44–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42// ----------------------------------------------------------------------------------------
43
44rectangle make_random_cropping_rect(
45 const matrix<rgb_pixel>& img,
46 dlib::rand& rnd
47)
48{
49 // figure out what rectangle we want to crop from the image
50 double mins = 0.466666666, maxs = 0.875;
51 auto scale = mins + rnd.get_random_double()*(maxs-mins);
52 auto size = scale*std::min(img.nr(), img.nc());
53 rectangle rect(size, size);
54 // randomly shift the box around
55 point offset(rnd.get_random_32bit_number()%(img.nc()-rect.width()),
56 rnd.get_random_32bit_number()%(img.nr()-rect.height()));
57 return move_rect(rect, offset);
58}
59
60// ----------------------------------------------------------------------------------------
61

Callers 1

randomly_crop_imageFunction · 0.70

Calls 8

move_rectFunction · 0.85
get_random_doubleMethod · 0.80
minFunction · 0.50
nrMethod · 0.45
ncMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected