Anda di halaman 1dari 25

Praktikum Grafika (3D) 2

Hero Yudo Martono


2016
Limas.txt (Limas.off)
object3D_color_t limas={ COFF
5, //numOfVertices 560
{{0,100,0, 0.5,0.6,0.7}, 0.0 1.0 0.0 0.5 0.6 0.7 255
//Point3D_color_t
{100,0,0, 0.2,0.4,0.6}, 1.0 0.0 0.0 0.2 0.4 0.6 255
{0,0,100, 0.8,1.0,0.3}, 0.0 0.0 1.0 0.8 1.0 0.3 255
{-100,0,0, 0.6,0.2,0.9}, -1.0 0.0 0.0 0.6 0.2 0.9 255
{0,0,-100, 0.1,1.0,0.7}}, 0.0 0.0 -1.0 0.1 1.0 0.7 255
6, //numberOfFaces 3021
{{3,{0,2,1}}, //face_t
{3,{0,3,2}}, 3032
{3,{0,4,3}}, 3043
{3,{0,1,4}}, 3014
{3,{1,2,4}}, 3124
{3,{3,4,2}}, 3342
}
};
Read txt file
std::ifstream ifs1("C:/Users/heroyudo/Documents/limas.off");
if(!ifs1){
std::cout << "cannot open file_readoff";
exit(1);
}

char str[255];
char *tok;
char delims[]=" ";
while(!ifs1.eof() && (y<2+numVertices+numFaces) ){
ifs1.getline(str,255);
if(y==1){//mendapatkan nilai numVertices dan numFaces
tok=strtok(str,delims);
x=0;
while(tok && x<2){
num[x]=atof(tok);
tok=strtok(NULL, delims);
x++;
}
numVertices=(int) num[0];
numFaces=(int) num[1];
ob.numofVertices=(int) num[0];
ob.numofFaces=(int) num[1];
}
Object .off/5_4.off (apa isi nya) ?
COFF
589 1174 0
0.442359 0.286139 0.616896 132 170 185 255
-0.348265 0.342272 -0.351922 37 59 128 255
-0.501816 0.257142 0.0711048 20 69 135 255
-0.236264 0.318718 -0.288572 121 122 184 255
-0.85305 0.175836 0.123187 120 172 236 255
-0.22916 0.303167 -0.468969 231 224 231 255
0.849705 0.194312 -0.176717 24 72 165 255

3 355 377 391


3 32 225 10
3 477 478 481
3 551 570 575
3 19 209 575
3 392 410 412
3 420 413 400
3 155 231 184
3 158 194 172
3 377 380 391
Object 5.off
COFF
9401 18798 0
-0.512485 0.289568 0.062128 27 59 134 255
0.912892 0.190174 -0.254200 162 196 225 255
0.576421 0.268572 0.294234 108 199 196 255
-0.817752 0.217687 -0.041252 136 182 170 255

std::ifstream ifs1("C:/off14/5.off");
if(!ifs1){
std::cout << "cannot open file_readoff";
exit(1);
}
Deklarasi
int numVertices=5; //nilai sementara typedef struct {
int numFaces=5; //nilai sementara int numofVertices;
Point3D_color_t* pnt;//100
while(!ifs1.eof() && (y<2+numVertices+numFaces) ){
ifs1.getline(str,255); int numofFaces;
if(y==1){ //mendapatkan nilai numVertices dan numFaces face_t* fc;//32,20012
tok=strtok(str,delims); }object3D_color_p;
x=0;
while(tok && x<2){ object3D_color_p mesh_p;
num[x]=atof(tok);
tok=strtok(NULL, delims);
x++;
}
numVertices=(int) num[0]; typedef struct {
numFaces=(int) num[1]; float x,y,z,r,g,b;
}Point3D_color_t;
mesh_p.pnt=new Point3D_color_t[numVertices];
mesh_p.fc=new face_t[numFaces];
mesh_p.numofVertices=numVertices;
mesh_p.numofFaces=numFaces;
}
Proses Memasukkan Obyek 3D
//SET VERTEX VALUE WITH COLOR
mesh_p.pnt[y-2].x=num[0]*scale;
mesh_p.pnt[y-2].y=num[1]*scale;
mesh_p.pnt[y-2].z=num[2]*scale;
mesh_p.pnt[y-2].r=num[3]/256;
mesh_p.pnt[y-2].g=num[4]/256;
mesh_p.pnt[y-2].b=num[5]/256;

//SET VALUE FACES


mesh_p.fc[y-2-numVertices].pnt[0]=num[1];
mesh_p.fc[y-2-numVertices].pnt[1]=num[2];
mesh_p.fc[y-2-numVertices].pnt[2]=num[3];

object3D_color_p prisma;
prisma=mesh_p;
Include opencv
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/opencv_modules.hpp>
#include <opencv2/opencv.hpp>

Membuat file image


cv::Mat image = Mat::zeros(256, 256, CV_8UC3 );
Point area[1][3];
area[0][0]=Point(0,0);
area[0][1]=Point(0,0);
area[0][2]=Point(0,0);
const Point* area_[1]={area[0]};
int num_[]={3};
imwrite("C:test_1.jpg", image );

src = cv::imread( C:test_2.jpg", 1 );


namedWindow( "Image", CV_WINDOW_AUTOSIZE );
imshow( "Image", src );
Vector3D_t normalVector,vecbuff[3];
Point3D_color_t Q[3];

for(int i=0; i<prisma.numofFaces; i++){


for(int j=0; j<3; j++){
int a0=prisma.fc[i].pnt[j];
vecbuff[j]=Point_color2Vector(prisma.pnt[a0]);
}

normalVector=((vecbuff[1])-(vecbuff[0]))^((vecbuff[0])-(vecbuff[2]));
if(normalVector.v[2]>0){
//menggambar invisible
int p0=prisma.fc[i].pnt[0];
int p1=prisma.fc[i].pnt[1]; void createVisible(Point3D_t P[]){
int p2=prisma.fc[i].pnt[2]; glColor3f(1.0, 0.0, 0.0);
glBegin(GL_LINE_LOOP);
Q[0]=prisma.pnt[p0]; for(int i=0; i<3; i++){
Q[1]=prisma.pnt[p1]; P[i].z=0.0;
Q[2]=prisma.pnt[p2]; glVertex3f(P[i].x, P[i].y,P[i].z);
}
area[0][0]=Point(Q[0].x+scale, scale-Q[0].y); glEnd();
area[0][1]=Point(Q[1].x+scale, scale-Q[1].y); }
area[0][2]=Point(Q[2].x+scale, scale-Q[2].y);

int r=(int) (Q[0].r+Q[1].r+Q[2].r)*256/3;


int g=(int) (Q[0].g+Q[1].g+Q[2].g)*256/3;
int b=(int) (Q[0].b+Q[1].b+Q[2].b)*256/3;
fillPoly(image,area_, num_,1,Scalar(b,g,r));
createVisible_color(Q);
}
}

imwrite("C:test_1.jpg", image );
Proyeksi 3D ke Image

3D 2D
Shape Retrieval Contest 2016

1.Retrieval of Human Subjects from Depth Sensor Data


Organizers: Andrea Giachetti (University of Verona)
Web page: http://www.andreagiachetti.it/shrec16/

2.3D Sketch-Based 3D Shape Retrieval


Organizers: Bo Li (University of Central Missouri), Yijuan Lu (Texas State University)
Web page: http://cs.txstate.edu/~yl12/SBR2016/

3.Matching of Deformable Shapes with Topological Noise


Organizers: Zorah Lhner (Technical University Munich), Emanuele Rodol (Technical University Munich),
Michael Bronstein (USI Lugano), Daniel Cremers (Technical University Munich)
Web page: http://vision.in.tum.de/~laehner/shrec2016/

4.Partial Matching of Deformable Shapes


Organizers: Luca Cosmo (Uniiversit Ca Foscari Venezia), Emanuele Rodol (TU Munich), Michael Bronstein
(USI Lugano), Andrea Torsello (Universit Ca Foscari Venezia)
Web page: http://www.dais.unive.it/~shrec2016/
Shape Retrieval Contest 2016

5.Shape Retrieval of Low-Cost RGB-D Captures


Organizers: Pedro Pascoal, Pedro Proena1, Miguel Sales Dias, Alfredo Ferreira ((ISCTE Instituto Universitrio de
Lisboa/ISTAR-IUL, Microsoft Language and Development Center, Lisbon, INESC-ID/ Tcnico Lisboa /Universidade de
Lisboa, Surrey Space Centre, University of Surrey)
Web page: http://dataset.mldc.pt/shrec16.html

6.Partial Shape Queries for 3D Object Retrieval


Organizers: Ioannis Pratikakis, Michalis Savelonas, Fotis Arnaoutoglou (Democritus University of Thrace), Anestis
Koutsoudis (Athena RC), Theoharis Theoharis (NTNU)
Website: http://vc.ee.duth.gr/shrec16/

7.Large-Scale 3D Shape Retrieval from ShapeNet Core55


Organizers: Manolis Savva (Stanford University), Fisher Yu (Princeton University), Hao Su (Stanford University)
Web page: https://shapenet.cs.stanford.edu/shrec16

8.Multiview and Mulitmodal 3D Object Retrieval


Organizers: Yue Gao (Tsinghua University), Anan Liu, Weizhi Nie (Tianjin University), Qionghai Dai (Tsinghua
University)
Web page: http://media.tju.edu.cn/shrec2016
Image Processing
Filter Image

Canny

Sobel

3D 2D
Find Countour
Fourier
Ekstraksi Feature
Local Binary Pattern

1 1 0

1 X 0

0 1 0

1100 0101

0001 0111
Aplikasi Local Binary Pattern

http://what-when-how.com/wp-content/uploads/2012/06/tmpdece304_thumb2.png
Cara Kerja LBP

http://www.rroij.com/articles-images/IJAREEIE-327-e001.gif
http://what-when-how.com/wp-content/uploads/2012/06/tmpdece291_thumb.png
Cara Kerja LBP
Local Ternary Pattern

http://www.hindawi.com/journals/tswj/2014/373254.fig.004.jpg
Aplikasi LTP

http://robinhsieh.com/wp-content/uploads/2013/10/LATP.png