-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgetBatch_test.m
24 lines (22 loc) · 982 Bytes
/
getBatch_test.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function fn = getBatch_test(opts)
% -------------------------------------------------------------------------
fn = @(x,y) getSimpleNNBatch(x,y,opts.patchSize) ;
% -------------------------------------------------------------------------
function [images, labels, lowRes] = getSimpleNNBatch(imdb, batch, patchSize)
% -------------------------------------------------------------------------
Ny = size(imdb.images.noisy,1);
Nx = size(imdb.images.noisy,2);
pos_x = round(rand(1)*(Nx-patchSize));
pos_y = round(rand(1)*(Ny-patchSize));
images = single(imdb.images.noisy(pos_y+(1:patchSize),pos_x+(1:patchSize),:,batch)) ;
labels = single(imdb.images.orig(pos_y+(1:patchSize),pos_x+(1:patchSize),:,batch)) ;
if rand > 0.5
labels=fliplr(labels); % left right rotate
images=fliplr(images);
end
if rand > 0.5
labels=flipud(labels); % up down rotate
images=flipud(images);
end
lowRes = images(:,:,1,:);
labels(:,:,1,:) = labels(:,:,1,:) - lowRes;