Skip to content

Commit

Permalink
rgb2lab
Browse files Browse the repository at this point in the history
  • Loading branch information
Fungungun committed Feb 14, 2017
1 parent e5e3abc commit 4ff9627
Show file tree
Hide file tree
Showing 41 changed files with 453 additions and 1,735 deletions.
16 changes: 14 additions & 2 deletions Test6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ Chenghuan Liu , Du Huynh, Jan 2017.
#include "Cparticle.h"
#include "SParater.h"

#define ERROR_OUT__ std::cerr<<"[ERROR][File:"<<__FILE__<<"][Line:"<<__LINE__<<"]"

#ifndef _DEBUG
#define TB__(A) int64 A; A = cv::getTickCount()
#define TE__(A) std::cout << #A << " : " << 1.E3 * double(cv::getTickCount() - A)/double(cv::getTickFrequency()) << "ms" << std::endl
#else
#define TB__(A)
#define TE__(A)
#endif



using namespace std;
using namespace cv;
Expand Down Expand Up @@ -62,8 +73,9 @@ int main( int argc, char** argv )
//tracking start
for(int i = para.startFrame; i < para.endFrame ; i++){
//load new frame
covimg.im = imread(filename[i],-1);
covimg.process();
Mat im_rgb = imread(filename[i],-1);
cvtColor(im_rgb,covimg.im,CV_BGR2Lab);
covimg.process();
cout<<filename[i]<<endl;

//search
Expand Down
133 changes: 19 additions & 114 deletions config.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[video_test] ;
file = david3
file = ball
fext = .jpg

[video_route]
Expand Down Expand Up @@ -52,103 +52,6 @@ std_gain_h = 0.1
gt_sep = 2
diffratio = 0.03

[Spiderman]
x1 = 527
y1 = 86
x2 = 663
y2 = 471
startframe = 1
endframe = 351
nParticles = 50
nModes = 9
dataset = 0
std_x = 3
std_y = 3
std_gain_w = 0.01
std_gain_h = 0.01
gt_sep = 1

[basketball]
x1 = 198
y1 = 214
x2 = 232
y2 = 295
startframe = 1
endframe = 725
nParticles = 100
nModes = 9
dataset = 0
std_x = 3
std_y = 3
std_gain_w = 0.003
std_gain_h = 0.003
gt_sep = 1
diffratio = 0.5

[Girl]
x1 = 57
y1 = 21
x2 = 88
y2 = 66
startframe = 1
endframe = 500
nParticles = 200
nModes = 9
dataset = 0
std_x = 2
std_y = 2
std_gain_w = 0.005
std_gain_h = 0.005
gt_sep = 2
diffratio = 0.2

[Tiger1]
x1 = 232
y1 = 88
x2 = 308
y2 = 172
startframe = 1
endframe = 354
nParticles = 200
nModes = 9
dataset = 0
std_x = 10
std_y = 10
std_gain_w = 0.1
std_gain_h = 0.1
gt_sep = 1

[Woman]
x1 = 213
y1 = 121
x2 = 234
y2 = 216
startframe = 1
endframe = 597
nParticles = 200
nModes = 9
dataset = 0
std_x = 2
std_y = 2
std_gain_w = 0.005
std_gain_h = 0.005
gt_sep = 1

[Skating]
x1 = 592
y1 = 133
x2 = 675
y2 = 340
startframe = 1
endframe = 497
nParticles = 100
nModes = 9
dataset = 0
std_x = 5
std_y = 5
std_gain_w = 0.005
std_gain_h = 0.005
gt_sep = 1

[FaceOcc1]
x1 = 118
Expand All @@ -168,22 +71,6 @@ gt_sep = 1
diffratio = 0.15


[FaceOcc2]
x1 = 118
y1 = 57
x2 = 200
y2 = 155
startframe = 1
endframe = 812
nParticles = 300
nModes = 9
dataset = 0
std_x = 1
std_y = 1
std_gain_w = 0.001
std_gain_h = 0.001
gt_sep = 1

[David3]
x1 = 83
y1 = 200
Expand All @@ -199,4 +86,22 @@ std_y = 3
std_gain_w = 0.005
std_gain_h = 0.005
gt_sep = 1
diffratio = 0.5


[ball]
x1 = 200.35
y1 = 113.74
x2 = 245.48
y2 = 159.32
startframe = 1
endframe = 602
nParticles = 100
nModes = 9
dataset = 1
std_x = 5
std_y = 5
std_gain_w = 0.01
std_gain_h = 0.01
gt_sep = 1
diffratio = 0.5
114 changes: 58 additions & 56 deletions covImage.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Chenghuan Liu, Du Huynh, Jan 2017.
*/
* Chenghuan Liu, Du Huynh, Jan 2017.
*/

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -57,10 +57,12 @@ void CovImage::coordinateY()

void CovImage::intensity(int channel)
{
uchar *inptr;
// uchar *inptr;
double *inptr;
double *outptr;
for (int r=0; r < nRows; r++) {
inptr = (uchar *)im.ptr<uchar>(r) + channel;
for(int r=0; r < nRows; r++){
// inptr = (uchar *)im.ptr<uchar>(r) + channel;
inptr = (double *)im.ptr<double>(r) + channel;
outptr = (double *)featimage.ptr<double>(r) + channel + 2;
for (int c=0; c < nCols; c++, inptr += nChannels, outptr += dim){
*outptr = (double)(*inptr);
Expand All @@ -84,7 +86,7 @@ void CovImage::gradientX(int channel)
inptr += dim; outptr += dim;
for (int c=1; c < nCols-1; c++, inptr += dim, outptr += dim){
*outptr = (*(inptr+dim) - *(inptr-dim)) / 2.0;
}
}
// the Ix value at the last column is the same as the previous column
*outptr = *(outptr-dim);
}
Expand All @@ -105,76 +107,76 @@ void CovImage::gradientY(int channel)
outptr = (double *)featimage.ptr<double>(r) + offset + nChannels*2;
for (int c=0; c < nCols; c++, inptr1 += dim, inptr2 += dim, outptr += dim){
*outptr = *inptr2 - *inptr1;
}
}
}
// set row 0 the same as row 1
outptr = (double *)featimage.ptr<double>(1) + offset + nChannels*2;
double *outptr2 = (double *)featimage.ptr<double>(0) + offset + nChannels*2;
for (int c=0; c < nCols; c++, outptr += dim, outptr2 += dim){
*outptr2 = *outptr;
}
}

// set the last row the same as the second last row
outptr = (double *)featimage.ptr<double>(nRows-2) + offset + nChannels*2;
outptr2 = (double *)featimage.ptr<double>(nRows-1) + offset + nChannels*2;
for (int c=0; c < nCols; c++, outptr += dim, outptr2 += dim){
*outptr2 = *outptr;
}
}
}

/* ------------------------------------------------------------ */

void CovImage::gradient2X(int channel)
{
double *inptr; // pointing to intensity of the channel
double *outptr; // pointing to gradient-x of the channel
int offset = channel + 2;
for(int r=0; r < nRows; r++) {
inptr = (double *)featimage.ptr<double>(r) + offset;
outptr = (double *)featimage.ptr<double>(r) + nChannels*3 + offset;
// set the Ix value at column 0 the same as column 1
*outptr = (*(inptr+2*dim) - 2*(*(inptr+dim)) + *inptr) / 1.0;
inptr += dim; outptr += dim;
for (int c=1; c < nCols-1; c++, inptr += dim, outptr += dim){
*outptr = (*(inptr+dim) - 2 * (*inptr) + *(inptr-dim)) / 1.0;
}
// the Ix value at the last column is the same as the previous column
*outptr = *(outptr-dim);
}
double *outptr; // pointing to gradient-x of the channel
int offset = channel + 2;
for(int r=0; r < nRows; r++) {
inptr = (double *)featimage.ptr<double>(r) + offset;
outptr = (double *)featimage.ptr<double>(r) + nChannels*3 + offset;
// set the Ix value at column 0 the same as column 1
*outptr = (*(inptr+2*dim) - 2*(*(inptr+dim)) + *inptr) / 1.0;
inptr += dim; outptr += dim;
for (int c=1; c < nCols-1; c++, inptr += dim, outptr += dim){
*outptr = (*(inptr+dim) - 2 * (*inptr) + *(inptr-dim)) / 1.0;
}
// the Ix value at the last column is the same as the previous column
*outptr = *(outptr-dim);
}
}

/* ------------------------------------------------------------ */

void CovImage::gradient2Y(int channel)
{
double *inptr1; // pointing to intensity of the channel
double *inptr2;
double *inptr3;
double *outptr; // pointing to gradient-y of the channel

int offset = channel + 2;
for (int r = 1; r < nRows-1; r++) {
inptr1 = (double *)featimage.ptr<double>(r-1) + offset;
inptr2 = (double *)featimage.ptr<double>(r+1) + offset;
inptr3 = (double *)featimage.ptr<double>(r) + offset;
outptr = (double *)featimage.ptr<double>(r) + offset + nChannels*4;
for (int c=0; c < nCols; c++, inptr1 += dim, inptr2 += dim, outptr += dim){
*outptr = *inptr2 + *inptr1 - 2*(*inptr3);
}
}
// set row 0 the same as row 1
outptr = (double *)featimage.ptr<double>(1) + offset + nChannels*4;
double *outptr2 = (double *)featimage.ptr<double>(0) + offset + nChannels*4;
for (int c=0; c < nCols; c++, outptr += dim, outptr2 += dim){
*outptr2 = *outptr;
}

// set the last row the same as the second last row
outptr = (double *)featimage.ptr<double>(nRows-2) + offset + nChannels*4;
outptr2 = (double *)featimage.ptr<double>(nRows-1) + offset + nChannels*4;
for (int c=0; c < nCols; c++, outptr += dim, outptr2 += dim){
*outptr2 = *outptr;
}
double *inptr1; // pointing to intensity of the channel
double *inptr2;
double *inptr3;
double *outptr; // pointing to gradient-y of the channel

int offset = channel + 2;
for (int r = 1; r < nRows-1; r++) {
inptr1 = (double *)featimage.ptr<double>(r-1) + offset;
inptr2 = (double *)featimage.ptr<double>(r+1) + offset;
inptr3 = (double *)featimage.ptr<double>(r) + offset;
outptr = (double *)featimage.ptr<double>(r) + offset + nChannels*4;
for (int c=0; c < nCols; c++, inptr1 += dim, inptr2 += dim, outptr += dim){
*outptr = *inptr2 + *inptr1 - 2*(*inptr3);
}
}
// set row 0 the same as row 1
outptr = (double *)featimage.ptr<double>(1) + offset + nChannels*4;
double *outptr2 = (double *)featimage.ptr<double>(0) + offset + nChannels*4;
for (int c=0; c < nCols; c++, outptr += dim, outptr2 += dim){
*outptr2 = *outptr;
}

// set the last row the same as the second last row
outptr = (double *)featimage.ptr<double>(nRows-2) + offset + nChannels*4;
outptr2 = (double *)featimage.ptr<double>(nRows-1) + offset + nChannels*4;
for (int c=0; c < nCols; c++, outptr += dim, outptr2 += dim){
*outptr2 = *outptr;
}
}

/* ------------------------------------------------------------ */
Expand Down Expand Up @@ -215,8 +217,8 @@ void CovImage::computeIntegralImage()
}

/* IIsum is a copy of featimage with an extra row of 0 at the top and extra
* columns of 0 at the left. The #extra columns = dim
*/
* columns of 0 at the left. The #extra columns = dim
*/
IIsum.row(0).setTo(0.0);
IIsum.col(0).setTo(0.0);
for (int r=1; r < nRows+1; r++) {
Expand All @@ -226,7 +228,7 @@ void CovImage::computeIntegralImage()
}

/* now compute the cumulative sum along the rows then along the columns
*/
*/
for (int r=1; r < nRows+1; r++) {
IIprod.row(r) += IIprod.row(r-1);
IIsum.row(r) += IIsum.row(r-1);
Expand All @@ -235,7 +237,7 @@ void CovImage::computeIntegralImage()
IIprod.col(c) += IIprod.col(c-1);
IIsum.col(c) += IIsum.col(c-1);
}

}
/* ------------------------------------------------------------ */

Expand Down
4 changes: 3 additions & 1 deletion covImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class CovImage {
*/
CovImage(string filename) {
// cerr << "constructor 1\n";
im = imread(filename, -1);
Mat im_rgb = imread(filename, -1);
cvtColor(im_rgb,im,CV_BGR2Lab);
process();
}

Expand Down Expand Up @@ -194,6 +195,7 @@ class CovImage {

void computeIntegralImage();


public:
/* return the total from 1 to S inclusive */
inline int total(int S) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 4ff9627

Please sign in to comment.