You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB
Matlab

function [Iall,classList,objLocation,objRegion]=expand_affine_image_set(offset,i,Iall,classList,objLocation,objRegion,I,groundtruth,class)
scales=1; %[0.9:0.1:1.1];
angles=[-8:8:8];
translateX=0; %[-1:1];
translateY=0; %[-1:1];
shearH=[-0.3:0.3:0.3];
shearV=shearH; %[-0.2:0.2:0.2];
numManipulations=length(scales)*length(angles)*length(translateX)*length(translateY)*length(shearH)*length(shearV);
i=numManipulations*(offset+(i-1));
for scale=scales
for angle=angles
for tX=translateX
for tY=translateY
for sH=shearH
for sV=shearV
i=i+1;
Iall{i}=manipulate_image(I,scale,angle,tX,tY,sH,sV);
classList(i)=class;
if ~isempty(groundtruth),
GT=manipulate_image(groundtruth,scale,angle,tX,tY,sH,sV);
objLocation(i,1:2)=fliplr(centroid(GT));
region=single(imdilate(groundtruth,strel('disk',4)));
else
objLocation(i,:)=[NaN;NaN];
region=ones(size(I),'single');
end
objRegion{i}=single(manipulate_image(region,scale,angle,tX,tY,sH,sV));
end
end
end
end
end
end
function I=manipulate_image(I,scale,angle,tX,tY,sH,sV)
I=imwarp(imrotate(imresize(I,'scale',scale),angle,'bilinear','crop'),affine2d([1 sV 0; sH 1 0; 0 0 1]));