Last active
June 16, 2017 01:29
-
-
Save omimo/8be491d762e58c74098f8b4e9a5da664 to your computer and use it in GitHub Desktop.
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
function [ ] = ipimat_to_imgs( filename, out_folder, prefix, w, h, thres ) | |
%IPIMAT_TO_IMGS Summary of this function goes here | |
% Detailed explanation goes here | |
input = load(filename); | |
mkdir(out_folder); | |
for f=1:length(input.DepthFrame) | |
p = pcframe_to_imframe2(input.DepthFrame(f).DepthPoints, w,h, thres); | |
imwrite(p, [out_folder, '/',prefix,'-', num2str(f) ,'.png']); | |
end | |
end | |
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
function [ OUT ] = pcframe_to_imframe( IN , width, height, thres) | |
%PCFRAME_TO_IMFRAME Summary of this function goes here | |
% Detailed explanation goes here | |
num_points = size(IN.x,1); | |
OUT = zeros(width, height, 3); | |
for f=1:num_points | |
x = min(ceil((IN.x(f) + 3 )/6.0 * width), width); | |
y = height - min(ceil((IN.y(f) + 1.5 )/5.0 * height), height); | |
z = min(ceil((IN.z(f) + 3 )/6.0 * 255), 255); | |
if (z > thres) | |
rgb = hsv2rgb(z/255, 1, 1); | |
OUT(max(y,1), max(x,1), 1) = rgb(1,1,1)*4; | |
OUT(max(y,1), max(x,1), 2) = rgb(1,1,2)*4; | |
OUT(max(y,1), max(x,1), 3) = rgb(1,1,3)*4; | |
end | |
end | |
OUT = imgaussfilt(OUT, 0.8); | |
end | |
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
function [ OUT ] = pcframe_to_imframe( IN , width, height, thres) | |
%PCFRAME_TO_IMFRAME Summary of this function goes here | |
% Detailed explanation goes here | |
num_points = size(IN.x,1); | |
OUT = zeros(width, height, 3); | |
% 512x524 | |
for f=1:num_points | |
x = min(ceil((IN.x(f) + 3 )/6.0 * width), width); | |
y = height - min(ceil((IN.y(f) + 3 )/6.0 * height), height); | |
z = min(((IN.z(f) + 3 )/6.0), 3); | |
% z = 1-z; | |
r=0; | |
g=0; | |
b=0; | |
b = min(max(z * 3, 0), 1); | |
g = min(max((z - 1/3) * 3, 0), 1); | |
r = min(max((z - 2/3) * 3, 0), 1); | |
OUT(max(y,1), max(x,1), 1) = r; | |
OUT(max(y,1), max(x,1), 2) = g; | |
OUT(max(y,1), max(x,1), 3) = b; | |
end | |
OUT = OUT(50:end-150, 50:end-50, :); | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment