JeungEunLee

data augmentated and size/rotate experiment : because output looks folded

{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"from glob import glob\n",
"import os \n",
"\n",
"motionpatch_location = './motionpatch/*.png'\n",
"output_location = './smallone/'\n",
"count = 0\n",
"for f in glob(motionpatch_location):\n",
" count += 1\n",
" image = cv2.imread(f)\n",
" small = cv2.resize(image,dsize=(25,25))\n",
" dst = os.path.join(output_location +str(count)+\".png\")\n",
" cv2.imwrite(dst,small)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
This diff is collapsed. Click to expand it.
This file is too large to display.
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
......@@ -20,6 +20,49 @@
" dst = os.path.join(output_location +str(count)+\".png\")\n",
" cv2.imwrite(dst,small)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
" def __init__(self, data_files):\n",
" IMAGE_WIDTH = 25\n",
" IMAGE_HEIGHT = 25\n",
" self.image_mode = 'RGB'\n",
" image_channels = 3\n",
" self.data_files = data_files\n",
" self.shape = len(data_files), IMAGE_WIDTH, IMAGE_HEIGHT, image_channels\n",
" \n",
" def get_image(iself,image_path, width, height, mode):\n",
" image = Image.open(image_path)\n",
" image = Image.im2double(image)\n",
" return np.array(image)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"from PIL import Image\n",
"import numpy as np\n",
"from matplotlib import pyplot\n",
"\n",
"imgloc = './smallone/5004.png'\n",
"image = Image.open(imgloc)\n",
"dst = os.path.join(\"./samples/5004.png\")\n",
"pyplot.imsave(dst,image)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......
S001C002P005R002A008
S001C002P006R001A008
S001C003P002R001A055
S001C003P002R002A012
S001C003P005R002A004
S001C003P005R002A005
S001C003P005R002A006
S001C003P006R002A008
S002C002P011R002A030
S002C003P008R001A020
S002C003P010R002A010
S002C003P011R002A007
S002C003P011R002A011
S002C003P014R002A007
S003C001P019R001A055
S003C002P002R002A055
S003C002P018R002A055
S003C003P002R001A055
S003C003P016R001A055
S003C003P018R002A024
S004C002P003R001A013
S004C002P008R001A009
S004C002P020R001A003
S004C002P020R001A004
S004C002P020R001A012
S004C002P020R001A020
S004C002P020R001A021
S004C002P020R001A036
S005C002P004R001A001
S005C002P004R001A003
S005C002P010R001A016
S005C002P010R001A017
S005C002P010R001A048
S005C002P010R001A049
S005C002P016R001A009
S005C002P016R001A010
S005C002P018R001A003
S005C002P018R001A028
S005C002P018R001A029
S005C003P016R002A009
S005C003P018R002A013
S005C003P021R002A057
S006C001P001R002A055
S006C002P007R001A005
S006C002P007R001A006
S006C002P016R001A043
S006C002P016R001A051
S006C002P016R001A052
S006C002P022R001A012
S006C002P023R001A020
S006C002P023R001A021
S006C002P023R001A022
S006C002P023R001A023
S006C002P024R001A018
S006C002P024R001A019
S006C003P001R002A013
S006C003P007R002A009
S006C003P007R002A010
S006C003P007R002A025
S006C003P016R001A060
S006C003P017R001A055
S006C003P017R002A013
S006C003P017R002A014
S006C003P017R002A015
S006C003P022R002A013
S007C001P018R002A050
S007C001P025R002A051
S007C001P028R001A050
S007C001P028R001A051
S007C001P028R001A052
S007C002P008R002A008
S007C002P015R002A055
S007C002P026R001A008
S007C002P026R001A009
S007C002P026R001A010
S007C002P026R001A011
S007C002P026R001A012
S007C002P026R001A050
S007C002P027R001A011
S007C002P027R001A013
S007C002P028R002A055
S007C003P007R001A002
S007C003P007R001A004
S007C003P019R001A060
S007C003P027R002A001
S007C003P027R002A002
S007C003P027R002A003
S007C003P027R002A004
S007C003P027R002A005
S007C003P027R002A006
S007C003P027R002A007
S007C003P027R002A008
S007C003P027R002A009
S007C003P027R002A010
S007C003P027R002A011
S007C003P027R002A012
S007C003P027R002A013
S008C002P001R001A009
S008C002P001R001A010
S008C002P001R001A014
S008C002P001R001A015
S008C002P001R001A016
S008C002P001R001A018
S008C002P001R001A019
S008C002P008R002A059
S008C002P025R001A060
S008C002P029R001A004
S008C002P031R001A005
S008C002P031R001A006
S008C002P032R001A018
S008C002P034R001A018
S008C002P034R001A019
S008C002P035R001A059
S008C002P035R002A002
S008C002P035R002A005
S008C003P007R001A009
S008C003P007R001A016
S008C003P007R001A017
S008C003P007R001A018
S008C003P007R001A019
S008C003P007R001A020
S008C003P007R001A021
S008C003P007R001A022
S008C003P007R001A023
S008C003P007R001A025
S008C003P007R001A026
S008C003P007R001A028
S008C003P007R001A029
S008C003P007R002A003
S008C003P008R002A050
S008C003P025R002A002
S008C003P025R002A011
S008C003P025R002A012
S008C003P025R002A016
S008C003P025R002A020
S008C003P025R002A022
S008C003P025R002A023
S008C003P025R002A030
S008C003P025R002A031
S008C003P025R002A032
S008C003P025R002A033
S008C003P025R002A049
S008C003P025R002A060
S008C003P031R001A001
S008C003P031R002A004
S008C003P031R002A014
S008C003P031R002A015
S008C003P031R002A016
S008C003P031R002A017
S008C003P032R002A013
S008C003P033R002A001
S008C003P033R002A011
S008C003P033R002A012
S008C003P034R002A001
S008C003P034R002A012
S008C003P034R002A022
S008C003P034R002A023
S008C003P034R002A024
S008C003P034R002A044
S008C003P034R002A045
S008C003P035R002A016
S008C003P035R002A017
S008C003P035R002A018
S008C003P035R002A019
S008C003P035R002A020
S008C003P035R002A021
S009C002P007R001A001
S009C002P007R001A003
S009C002P007R001A014
S009C002P008R001A014
S009C002P015R002A050
S009C002P016R001A002
S009C002P017R001A028
S009C002P017R001A029
S009C003P017R002A030
S009C003P025R002A054
S010C001P007R002A020
S010C002P016R002A055
S010C002P017R001A005
S010C002P017R001A018
S010C002P017R001A019
S010C002P019R001A001
S010C002P025R001A012
S010C003P007R002A043
S010C003P008R002A003
S010C003P016R001A055
S010C003P017R002A055
S011C001P002R001A008
S011C001P018R002A050
S011C002P008R002A059
S011C002P016R002A055
S011C002P017R001A020
S011C002P017R001A021
S011C002P018R002A055
S011C002P027R001A009
S011C002P027R001A010
S011C002P027R001A037
S011C003P001R001A055
S011C003P002R001A055
S011C003P008R002A012
S011C003P015R001A055
S011C003P016R001A055
S011C003P019R001A055
S011C003P025R001A055
S011C003P028R002A055
S012C001P019R001A060
S012C001P019R002A060
S012C002P015R001A055
S012C002P017R002A012
S012C002P025R001A060
S012C003P008R001A057
S012C003P015R001A055
S012C003P015R002A055
S012C003P016R001A055
S012C003P017R002A055
S012C003P018R001A055
S012C003P018R001A057
S012C003P019R002A011
S012C003P019R002A012
S012C003P025R001A055
S012C003P027R001A055
S012C003P027R002A009
S012C003P028R001A035
S012C003P028R002A055
S013C001P015R001A054
S013C001P017R002A054
S013C001P018R001A016
S013C001P028R001A040
S013C002P015R001A054
S013C002P017R002A054
S013C002P028R001A040
S013C003P008R002A059
S013C003P015R001A054
S013C003P017R002A054
S013C003P025R002A022
S013C003P027R001A055
S013C003P028R001A040
S014C001P027R002A040
S014C002P015R001A003
S014C002P019R001A029
S014C002P025R002A059
S014C002P027R002A040
S014C002P039R001A050
S014C003P007R002A059
S014C003P015R002A055
S014C003P019R002A055
S014C003P025R001A048
S014C003P027R002A040
S015C001P008R002A040
S015C001P016R001A055
S015C001P017R001A055
S015C001P017R002A055
S015C002P007R001A059
S015C002P008R001A003
S015C002P008R001A004
S015C002P008R002A040
S015C002P015R001A002
S015C002P016R001A001
S015C002P016R002A055
S015C003P008R002A007
S015C003P008R002A011
S015C003P008R002A012
S015C003P008R002A028
S015C003P008R002A040
S015C003P025R002A012
S015C003P025R002A017
S015C003P025R002A020
S015C003P025R002A021
S015C003P025R002A030
S015C003P025R002A033
S015C003P025R002A034
S015C003P025R002A036
S015C003P025R002A037
S015C003P025R002A044
S016C001P019R002A040
S016C001P025R001A011
S016C001P025R001A012
S016C001P025R001A060
S016C001P040R001A055
S016C001P040R002A055
S016C002P008R001A011
S016C002P019R002A040
S016C002P025R002A012
S016C003P008R001A011
S016C003P008R002A002
S016C003P008R002A003
S016C003P008R002A004
S016C003P008R002A006
S016C003P008R002A009
S016C003P019R002A040
S016C003P039R002A016
S017C001P016R002A031
S017C002P007R001A013
S017C002P008R001A009
S017C002P015R001A042
S017C002P016R002A031
S017C002P016R002A055
S017C003P007R002A013
S017C003P008R001A059
S017C003P016R002A031
S017C003P017R001A055
S017C003P020R001A059
\ No newline at end of file
%your motion_patch location
ori = imread('/home/rfj/바탕화면/actionGAN/motion_patch/S001C001P001R001A020.png');
ori = imread('/home/rfj/바탕화면/actionGAN/DCGAN/new_motionpatch/sample_111.png');
ori = im2double(ori);
ori = ori(:,:,:);
......
This diff is collapsed. Click to expand it.
clear;
path_name = '/media/rfj/EEA4441FA443E923/nturgb_skeletones/';
fileID = fopen('/home/rfj/바탕화면/actionGAN/skeletone_INDEX/good_stand_2.txt','r');
formatSpec = '%s';
sizeA = [20 Inf];
perfect_list = fscanf(fileID,formatSpec,sizeA);
perfect_list = perfect_list.';
fclose(fileID);
L = length(perfect_list);
for K = 1:L
file_name = char(perfect_list(K,:));
name = strcat(path_name,file_name(1:20),'.skeleton');
[token,remainder] = strtok(file_name,'A');
class = str2num(remainder(2:4));
bodyinfo = read_skeleton_file(name);
frame_num = size(bodyinfo,2);
try
%initialize
cur_subject_x = zeros(frame_num, 25);
cur_subject_y = zeros(frame_num, 25);
cur_subject_z = zeros(frame_num, 25);
tot_x = zeros(frame_num,25);
tot_y = zeros(frame_num,25);
tot_z = zeros(frame_num,25);
joint_5 = zeros(1,3);
joint_9 = zeros(1,3);
joint_1 = zeros(1,3);
joint_3 = zeros(1,3);
%get total joints information
for FN = 1:frame_num
cur_body = bodyinfo(FN).bodies(1);
joints = cur_body.joints;
for JN = 1:25
tot_x(FN,JN) = joints(JN).x;
tot_y(FN,JN) = joints(JN).y;
tot_z(FN,JN) = joints(JN).z;
end
end
%Orientation normalization 1 : in space
%get median values
M_x = median(tot_x);
M_y = median(tot_y);
M_z = median(tot_z);
%set 3 points for make plane
joint_5 = [M_x(5) M_y(5) M_z(5)];
joint_9 = [M_x(9) M_y(9) M_z(9)];
joint_1 = [M_x(1) M_y(1) M_z(1)];
joint_3 = [M_x(3) M_y(3) M_z(3)];
%find RIGID TRNASFORMATION matrix
d1 = joint_1 - joint_5;
d2 = joint_1 - joint_9;
n1 = cross(d1,d2); % because we will parallel transform, don't need to find belly
u1 = n1/norm(n1);
u2 = [0 0 1];
cs1 = dot(u1,u2)/norm(u1)*norm(u2);
ss1 = sqrt(1-cs1.^2);
v1 = cross(u1,u2)/norm(cross(u1,u2));
R1 = [v1(1)*v1(1)*(1-cs1)+cs1 v1(1)*v1(2)*(1-cs1)-v1(3)*ss1 v1(1)*v1(3)*(1-cs1)+v1(2)*ss1];
R1(2,:) = [v1(1)*v1(2)*(1-cs1)+v1(3)*ss1 v1(2)*v1(2)*(1-cs1)+cs1 v1(2)*v1(3)*(1-cs1)-v1(1)*ss1];
R1(3,:) = [v1(1)*v1(3)*(1-cs1)-v1(2)*ss1 v1(2)*v1(3)*(1-cs1)+v1(1)*ss1 v1(3)*v1(3)*(1-cs1)+cs1];
%1-3 number tolls to parallel x axis. Rigid transformation on plane surface
%Z axis coords oyler angle transform
t = joint_3 - joint_1;
d3 = R1(1,:) * t.';
d3(1,2) = R1(2,:) * t.';
d3(1,3) = R1(3,:) * t.';
u3 = d3(1:2)/norm(d3(1:2));
v3 = [u3(1) -u3(2)];
v3(2,:) = [u3(2) u3(1)];
u4 = [1 0].';
csss = v3\u4;
cs2 = csss(1);
ss2 = csss(2);
R2 = [cs2 -ss2 0];
R2(2,:) = [ss2 cs2 0];
R2(3,:) = [0 0 1];
%apply rigid transformation
for FN = 1:frame_num
cur_body = bodyinfo(FN).bodies(1);
joints = cur_body.joints;
for JN = 1:25
a = R1(1,:) * [joints(JN).x joints(JN).y joints(JN).z].';
b = R1(2,:) * [joints(JN).x joints(JN).y joints(JN).z].';
c = R1(3,:) * [joints(JN).x joints(JN).y joints(JN).z].';
cur_subject_x(FN,JN) = R2(1,:) * [a b c].';
cur_subject_y(FN,JN) = R2(2,:) * [a b c].';
cur_subject_z(FN,JN) = R2(3,:) * [a b c].';
end
end
%orientation normalize 2 in plane surface
if cur_subject_x(1,4) < cur_subject_x(1,1)
cur_subject_x = 0 - cur_subject_x;
end
if cur_subject_y(1,9) > cur_subject_y(1,5)
cur_subject_y = 0 - cur_subject_y;
end
% for save origin subjects before data augment
clear_subject_x = cur_subject_x;
clear_subject_y = cur_subject_y;
clear_subject_z = cur_subject_z;
% Left <-> Right Change : 2option
for LR = 1:2
if LR == 1
augment_y = clear_subject_y;
else
augment_y = 0 - clear_subject_y;
end
%Height change : 3option
for HE = 1:3
if HE == 1
augment_x = clear_subject_x.* 1.2;
elseif HE==2
augment_x = clear_subject_x.* 1.0;
else
augment_x = clear_subject_x.* 0.8;
end
%Give Gaussian Random Variable : 0.01 - 6times
for RV = 1:6
%3. Gaussian Random filter 0.1
cur_subject_x = augment_x + 0.01.*randn(frame_num,25);
cur_subject_y = augment_y + 0.01.*randn(frame_num,25);
cur_subject_z = clear_subject_z + 0.01.*randn(frame_num,25);
% NORMALIZATION
cur_subject_x = cur_subject_x - min(cur_subject_x(:));
max_tall = max(cur_subject_x(:)) .*2;
cur_subject_x = cur_subject_x ./ max_tall;
cur_subject_y = cur_subject_y - min(cur_subject_y(:));
cur_subject_y = cur_subject_y ./ max_tall;
cur_subject_z = cur_subject_z - min(cur_subject_z(:));
cur_subject_z = cur_subject_z ./ max_tall;
%Write image
motionpatch = cur_subject_x;
motionpatch(:,:,2) = cur_subject_y;
motionpatch(:,:,3) = cur_subject_z;
new_file_name = strcat('/home/rfj/바탕화면/actionGAN/DCGAN/new_motionpatch_halfsize/',file_name(1:20),'_',num2str(LR),num2str(HE),num2str(RV),'.png');
imwrite(motionpatch,new_file_name);
end
end
end
catch
name
end
end
clear;
path_name = '/media/rfj/EEA4441FA443E923/nturgb_skeletones/';
fileID = fopen('/home/rfj/바탕화면/actionGAN/skeletone_INDEX/good_stand_2.txt','r');
formatSpec = '%s';
sizeA = [20 Inf];
perfect_list = fscanf(fileID,formatSpec,sizeA);
perfect_list = perfect_list.';
fclose(fileID);
L = length(perfect_list);
for K = 1:L
file_name = char(perfect_list(K,:));
name = strcat(path_name,file_name(1:20),'.skeleton');
[token,remainder] = strtok(file_name,'A');
class = str2num(remainder(2:4));
bodyinfo = read_skeleton_file(name);
frame_num = size(bodyinfo,2);
try
%initialize
cur_subject_x = zeros(frame_num, 25);
cur_subject_y = zeros(frame_num, 25);
cur_subject_z = zeros(frame_num, 25);
tot_x = zeros(frame_num,25);
tot_y = zeros(frame_num,25);
tot_z = zeros(frame_num,25);
joint_5 = zeros(1,3);
joint_9 = zeros(1,3);
joint_1 = zeros(1,3);
joint_3 = zeros(1,3);
%get total joints information
for FN = 1:frame_num
cur_body = bodyinfo(FN).bodies(1);
joints = cur_body.joints;
for JN = 1:25
tot_x(FN,JN) = joints(JN).x;
tot_y(FN,JN) = joints(JN).y;
tot_z(FN,JN) = joints(JN).z;
end
end
%Orientation normalization 1 : in space
%get median values
M_x = median(tot_x);
M_y = median(tot_y);
M_z = median(tot_z);
%set 3 points for make plane
joint_5 = [M_x(5) M_y(5) M_z(5)];
joint_9 = [M_x(9) M_y(9) M_z(9)];
joint_1 = [M_x(1) M_y(1) M_z(1)];
joint_3 = [M_x(3) M_y(3) M_z(3)];
%find RIGID TRNASFORMATION matrix
d1 = joint_1 - joint_5;
d2 = joint_1 - joint_9;
n1 = cross(d1,d2); % because we will parallel transform, don't need to find belly
u1 = n1/norm(n1);
u2 = [0 0 1];
cs1 = dot(u1,u2)/norm(u1)*norm(u2);
ss1 = sqrt(1-cs1.^2);
v1 = cross(u1,u2)/norm(cross(u1,u2));
R1 = [v1(1)*v1(1)*(1-cs1)+cs1 v1(1)*v1(2)*(1-cs1)-v1(3)*ss1 v1(1)*v1(3)*(1-cs1)+v1(2)*ss1];
R1(2,:) = [v1(1)*v1(2)*(1-cs1)+v1(3)*ss1 v1(2)*v1(2)*(1-cs1)+cs1 v1(2)*v1(3)*(1-cs1)-v1(1)*ss1];
R1(3,:) = [v1(1)*v1(3)*(1-cs1)-v1(2)*ss1 v1(2)*v1(3)*(1-cs1)+v1(1)*ss1 v1(3)*v1(3)*(1-cs1)+cs1];
%1-3 number tolls to parallel x axis. Rigid transformation on plane surface
%Z axis coords oyler angle transform
t = joint_3 - joint_1;
d3 = R1(1,:) * t.';
d3(1,2) = R1(2,:) * t.';
d3(1,3) = R1(3,:) * t.';
u3 = d3(1:2)/norm(d3(1:2));
v3 = [u3(1) -u3(2)];
v3(2,:) = [u3(2) u3(1)];
u4 = [0 1].'; % decide orientation in plane
csss = v3\u4;
cs2 = csss(1);
ss2 = csss(2);
R2 = [cs2 -ss2 0];
R2(2,:) = [ss2 cs2 0];
R2(3,:) = [0 0 1];
%apply rigid transformation
for FN = 1:frame_num
cur_body = bodyinfo(FN).bodies(1);
joints = cur_body.joints;
for JN = 1:25
a = R1(1,:) * [joints(JN).x joints(JN).y joints(JN).z].';
b = R1(2,:) * [joints(JN).x joints(JN).y joints(JN).z].';
c = R1(3,:) * [joints(JN).x joints(JN).y joints(JN).z].';
cur_subject_x(FN,JN) = R2(1,:) * [a b c].';
cur_subject_y(FN,JN) = R2(2,:) * [a b c].';
cur_subject_z(FN,JN) = R2(3,:) * [a b c].';
end
end
%orientation normalize 2 (with plane surface)
if cur_subject_y(1,4) < cur_subject_y(1,1)
cur_subject_y = 0 - cur_subject_y;
end
if cur_subject_x(1,9) > cur_subject_x(1,5)
cur_subject_x = 0 - cur_subject_x;
end
% for save origin subjects before data augment
clear_subject_x = cur_subject_x;
clear_subject_y = cur_subject_y;
clear_subject_z = cur_subject_z;
% Left <-> Right Change : 2option
for LR = 1:2
if LR == 1
augment_x = clear_subject_x;
else
augment_x = 0 - clear_subject_x;
end
%Height change : 3option
for HE = 1:3
if HE == 1
augment_y = clear_subject_y.* 1.2;
elseif HE==2
augment_y = clear_subject_y.* 1.0;
else
augment_y = clear_subject_y.* 0.8;
end
%Give Gaussian Random Variable : 0.01 - 6times
for RV = 1:6
%3. Gaussian Random filter 0.1
cur_subject_x = augment_x + 0.01.*randn(frame_num,25);
cur_subject_y = augment_y + 0.01.*randn(frame_num,25);
cur_subject_z = clear_subject_z + 0.01.*randn(frame_num,25);
% NORMALIZATION
cur_subject_y = cur_subject_y - min(cur_subject_y(:));
max_tall = max(cur_subject_y(:));
cur_subject_y = cur_subject_y ./ max_tall;
cur_subject_x = cur_subject_x - min(cur_subject_x(:));
cur_subject_x = cur_subject_x ./ max_tall;
cur_subject_z = cur_subject_z - min(cur_subject_z(:));
cur_subject_z = cur_subject_z ./ max_tall;
%Write image
motionpatch = cur_subject_x;
motionpatch(:,:,2) = cur_subject_y;
motionpatch(:,:,3) = cur_subject_z;
new_file_name = strcat('/home/rfj/바탕화면/actionGAN/DCGAN/new_motionpatch_rotate90/',file_name(1:20),'_',num2str(LR),num2str(HE),num2str(RV),'.png');
imwrite(motionpatch,new_file_name);
end
end
end
catch
name
end
end
......@@ -7,7 +7,7 @@
clear;
name = '/home/rfj/바탕화면/skeletones/S001C001P002R002A020.skeleton'
name = '/home/rfj/바탕화면/actionGAN/sample_skeletones/S001C001P001R002A020.skeleton'
bodyinfo = read_skeleton_file(name);
frame_num = size(bodyinfo,2);
......@@ -37,6 +37,7 @@ for FN = 1:frame_num
end
end
%Orientation normalization 1 : in space
%get median values
M_x = median(tot_x);
M_y = median(tot_y);
......@@ -109,89 +110,59 @@ end
if cur_subject_y(1,9) > cur_subject_y(1,5)
cur_subject_y = 0 - cur_subject_y;
end
%get current median
CM_x=median(cur_subject_x);
CM_y=median(cur_subject_y);
CM_z=median(cur_subject_z);
%for transform bellybutton to 0.5,0.5 (Except X) but it doesn't work
belly_button = 0.5 - CM_y(2);
belly_button(2) = 0.5 - CM_z(2);
% normalize with x... <- HERE! WANT TO PARALLEL TRANSFORM
... but if I plus belly_button for x and y axis , it dosn't work
cur_subject_x = cur_subject_x - min(cur_subject_x(:));
max_tall = max(cur_subject_x(:));
cur_subject_x = cur_subject_x ./ max_tall;
cur_subject_y = cur_subject_y - min(cur_subject_y(:));
cur_subject_y = cur_subject_y ./ max_tall;
cur_subject_z = cur_subject_z - min(cur_subject_z(:));
cur_subject_z = cur_subject_z ./ max_tall;
% 이미지 저장
motionpatch = cur_subject_x;
motionpatch(:,:,2) = cur_subject_y;
motionpatch(:,:,3) = cur_subject_z;
new_file_name = strcat('/home/rfj/바탕화면/sample.png');
imwrite(motionpatch,new_file_name);
% read image after write
ori = imread('/home/rfj/바탕화면/sample.png');
ori = im2double(ori);
ori = ori(:,:,:);
dx = [];
dy = [];
dz = [];
for f = 1:numel(ori(:,1,1))
for j = 1:25
dx = [dx;ori(f,j,1)];
dy = [dy;ori(f,j,2)];
dz = [dz;ori(f,j,3)];
% for save origin subjects before data augment
clear_subject_x = cur_subject_x;
clear_subject_y = cur_subject_y;
clear_subject_z = cur_subject_z;
% Left <-> Right Change : 2option
for LR = 1:2
if LR == 1
augment_y = clear_subject_y;
else
augment_y = 0 - clear_subject_y;
end
end
a = [1 0 0]; % Red 척추 1,2,3,4,20
b = [0 0 1]; % Blue 오른팔 8,9,10,11,23,24
c = [0 1 0]; % Green왼팔 5,6,7,21,22 (여기서 5번이 빠짐. 넣고싶으면 나중에 24 joint가 아니라 25 joint로 추가)
d = [1 1 0]; % Yellow 오른다리 16,17,18,19
e = [0 1 1]; % Skyblue 왼다리 12,13,14,15
colors = [a;a;a;a;c;c;c;c;b;b;b;b;e;e;e;e;d;d;d;d;a;c;c;b;b];
scatter3(dx,dy,dz,100,'filled');
connecting_joints= ...
[2 1 21 3 21 5 6 7 21 9 10 11 1 13 14 15 1 17 18 19 2 8 8 12 12];
for jj=1:25:numel(dx)% 1부터 8개씩 numel = 열갯수..?
current = [];
current(:,1) = dy(jj:jj+24) ;
current(:,2) = dz(jj:jj+24) ;
current(:,3) = dx(jj:jj+24) ;
scatter3(current(:,1),current(:,2),current(:,3),100,colors(:,:),'filled');
for j =1:25
k=connecting_joints(j);
line([current(j,1) current(k,1)], [current(j,2) current(k,2)] , [current(j,3) current(k,3)])
%Height change : 3option
for HE = 1:3
if HE == 1
augment_x = clear_subject_x.* 1.2;
elseif HE==2
augment_x = clear_subject_x.* 1.0;
else
augment_x = clear_subject_x.* 0.8;
end
%Give Gaussian Random Variable : 0.01 - 6times
for RV = 1:6
%3. Gaussian Random filter 0.1
cur_subject_x = augment_x + 0.01.*randn(frame_num,25);
cur_subject_y = augment_y + 0.01.*randn(frame_num,25);
cur_subject_z = clear_subject_z + 0.01.*randn(frame_num,25);
% NORMALIZATION
cur_subject_x = cur_subject_x - min(cur_subject_x(:));
max_tall = max(cur_subject_x(:));
cur_subject_x = cur_subject_x ./ max_tall;
cur_subject_y = cur_subject_y - min(cur_subject_y(:));
cur_subject_y = cur_subject_y ./ max_tall;
cur_subject_z = cur_subject_z - min(cur_subject_z(:));
cur_subject_z = cur_subject_z ./ max_tall;
%Write image
motionpatch = cur_subject_x;
motionpatch(:,:,2) = cur_subject_y;
motionpatch(:,:,3) = cur_subject_z;
new_file_name = strcat('/home/rfj/바탕화면/actionGAN/DCGAN/new_motionpatch/sample_',num2str(LR),num2str(HE),num2str(RV),'.png');
imwrite(motionpatch,new_file_name);
end
end
set(gca,'Xdir','reverse','Ydir','reverse')
xlim([0 1]);
xlabel('x')
ylim([0 1]);
ylabel('y')
zlim([0 1]);
zlabel('z')
drawnow
pause(0.01)
end
\ No newline at end of file
end
......
This file is too large to display.
This file is too large to display.
This file is too large to display.
This file is too large to display.
......@@ -4,7 +4,6 @@ S001C001P005R002A020
S001C001P007R001A020
S001C001P008R002A020
S001C002P002R002A020
S001C001P001R001A020
S001C002P003R002A020
S001C002P005R001A020
S001C002P005R002A020
......