Created
February 18, 2018 01:02
-
-
Save carsontang/83e1b1a725aeabfe008d19215e7dd462 to your computer and use it in GitHub Desktop.
Describing rcnn_im_crop's mean subtraction from a region
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Crop the region out of the image with the bbox coordinates | |
# bbox = [x1 y1 x2 y2] | |
# size(im) = HEIGHT x WIDTH x NUM_CHANNELS | |
# window = im(y1:y2, x1:x2, all_channels) | |
# For every channel, crop out the height and the width | |
window = im(bbox(2):bbox(4), bbox(1):bbox(3), :); | |
# Warp the region | |
tmp = imresize(window, [crop_height crop_width], ... | |
'bilinear', 'antialiasing', false); | |
# Subtract the portion of the mean that corresponds with the window | |
# See (0) for a walkthrough of the code | |
if ~isempty(image_mean) | |
tmp = tmp - image_mean(pad_h+(1:crop_height), pad_w+(1:crop_width), :); | |
end | |
# (0) | |
1:crop_height % produces a vector of length == crop_height | |
1:crop_width % produces a vector of length == crop_width | |
pad_h + (1:crop_height) | |
% assume pad_h = 10, crop_height = 3 | |
1:crop_height = 1:3 = 1 2 3 | |
pad_h + (1:crop_height) = [10+1 10+2 10+3] = [11 12 13] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment