Skip to content

Commit

Permalink
Renamed MSLD_pyramid to PMSLD. Added PSMSLD
Browse files Browse the repository at this point in the history
  • Loading branch information
Big Smile committed Jan 17, 2014
1 parent b041221 commit 2c2db09
Show file tree
Hide file tree
Showing 53 changed files with 7,997 additions and 11 deletions.
Binary file modified MSLD/MSLD/MSLD_descriptor/TianMatch.sdf
Binary file not shown.
Binary file modified MSLD/MSLD/MSLD_descriptor/TianMatch.v11.suo
Binary file not shown.
7 changes: 6 additions & 1 deletion MSLD/MSLD/MSLD_descriptor/wzhlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,12 @@ bool SaveDescriptor(float * pDes, int nLineCount, byte * pByValidFlag, int * szC
for(int i = 0; i < nLineCount; i++) {
for(int k = 0; k < nMaxRegionNum*8; k++)
{
fprintf(fp1,"%f ", pDes[i*nDesDim+k]);
if(pDes[i*nDesDim+k] > 0) {
fprintf(fp1,"%f ", pDes[i*nDesDim+k]);
} else {
// Means it has overflown and is most likely not a valid line
fprintf(fp1,"%f ", -1.0f);
}
}
fprintf(fp1,"\n");
}
Expand Down
21 changes: 21 additions & 0 deletions SMSLD/SMSLD/SMSLD_descriptor/810A~1/9E57~1.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//������С���˼�������
initM(MATCOM_VERSION);
Mm mMatrix = zeros(nCount,3);
for(int g1 = 0; g1 < nCount; g1++)
{
mMatrix.r(g1+1,1) = pLinePts[2*g1];
mMatrix.r(g1+1,2) = pLinePts[2*g1+1];
mMatrix.r(g1+1,3) = 1;
}

//����ֵ�ֽ��þ�ȷλ��
Mm u,s,v;
i_o_t i_o = {0,0};
svd(mMatrix,i_o,u,s,v);

//���㷽��
double a = v.r(1,3);
double b = v.r(2,3);

//�˳�
exitM();
Binary file added SMSLD/SMSLD/SMSLD_descriptor/810A~1/ago4500.dll
Binary file not shown.
Binary file added SMSLD/SMSLD/SMSLD_descriptor/810A~1/v4500v.dll
Binary file not shown.
Binary file added SMSLD/SMSLD/SMSLD_descriptor/810A~1/v4500v.lib
Binary file not shown.
280 changes: 280 additions & 0 deletions SMSLD/SMSLD/SMSLD_descriptor/Image.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
// Image.cpp -- Defination of the class Image.

#pragma once

#include "stdafx.h"
#include "Image.h"

Image::Image(void)
{
m_pixels = NULL;
}

Image::Image(int xDim, int yDim)
{
this->Allocate(xDim, yDim);
}

Image::Image(const Image &other)
{
this->Allocate(other.m_xDim, other.m_yDim);

for (int y=0; y<m_yDim; y++)
{
for (int x=0; x<m_xDim; x++)
{
m_pixels[y][x] = other.m_pixels[y][x];
}
}
}

Image::~Image(void)
{
this->DeAllocate();
}

Image & Image::operator =(const Image &other)
{
if (this == &other)
{
return *this;
}

this->ReAllocate(other.m_xDim, other.m_yDim);

for (int y=0; y<m_yDim; y++)
{
for (int x=0; x<m_xDim; x++)
{
m_pixels[y][x] = other.m_pixels[y][x];
}
}

return *this;
}

void Image::ReAllocate(int xDim, int yDim)
{
this->DeAllocate();
this->Allocate(xDim, yDim);
}

void Image::Allocate(int xDim, int yDim)
{
assert((xDim > 0) && (yDim > 0));

m_xDim = xDim;
m_yDim = yDim;

m_pixels = new double *[m_yDim];
if (m_pixels == NULL)
{
FatalError("Image -- Allocating memory fails!");
}
for (int y=0; y<m_yDim; y++)
{
m_pixels[y] = new double[m_xDim];
if (m_pixels[y] == NULL)
{
FatalError("Image -- Allocating memory fails!");
}
}
}

void Image::DeAllocate(void)
{
if (m_pixels != NULL)
{
for (int y=0; y<m_yDim; y++)
{
delete [] m_pixels[y];
}
delete []m_pixels;
}
}

/********************************************************************
So we can just use image(x, y) to indicate the pixel value
at position (x, y).
********************************************************************/
double & Image::operator ()(int x, int y)
{
assert((x >= 0) && (x < m_xDim) && (y >= 0) && (y < m_yDim));

return m_pixels[y][x];
}

int Image::GetXDim(void) const
{
return m_xDim;
}

int Image::GetYDim(void) const
{
return m_yDim;
}

/********************************************************************
Find the minimum to maximum range, then stretch and limit those
to exactly 0.0 to 1.0.
If both the minimum and maximum values are equal, no normalization
takes place.
********************************************************************/
void Image::Normalize(void)
{
double min = 1.0;
double max = 0.0;

for (int y=0; y<m_yDim; ++y)
{
for (int x=0; x<m_xDim; ++x)
{
if (min > m_pixels[y][x])
{
min = m_pixels[y][x];
}

if (max < m_pixels[y][x])
{
max = m_pixels[y][x];
}
}
}

if (min == max)
{
return;
}

double diff = max - min;

for (int y=0; y<m_yDim; ++y)
{
for (int x=0 ; x<m_xDim; ++x)
{
m_pixels[y][x] = (m_pixels[y][x] - min) / diff;
}
}
}

/********************************************************************
Downscale the image from size (x, y) to (x / 2, y / 2),
sampling pixels by a factor of 2.
********************************************************************/
Image Image::HalfScale(void)
{
if ((m_xDim / 2 == 0) || (m_yDim / 2 == 0))
{
//return *this;
FatalError("Too small image size, cannot half.");
}

Image res(m_xDim / 2, m_yDim / 2);

for (int y=0; y<res.m_yDim; y++)
{
for (int x=0; x<res.m_xDim; x++)
{
res.m_pixels[y][x] = this->m_pixels[2 * y][2 * x];
}
}

return res;
}

/********************************************************************
Double the image from size (x, y) to (x * 2 - 1, y * 2 - 1),
using linear interpolation.
********************************************************************/
Image Image::DoubleScale(void)
{
if ((m_xDim <= 1) || (m_yDim <= 1))
{
//return *this;
FatalError("Too small image size for doubling.");
}

Image res(m_xDim * 2 - 1, m_yDim * 2 - 1);

for (int y=0; y<(m_yDim-1); y++)
{
for (int x=0; x<(m_xDim-1); x++)
{
res(x * 2, y * 2) = this->m_pixels[y][x];
res(x * 2 + 1, y * 2) = 0.5 *
(this->m_pixels[y][x] + this->m_pixels[y][x + 1]);
res(x * 2, y * 2 + 1) = 0.5 *
(this->m_pixels[y][x] + this->m_pixels[y + 1][x]);
res(x * 2 + 1, y * 2 + 1) = 0.25 *
(this->m_pixels[y][x] + this->m_pixels[y + 1][x + 1] +
this->m_pixels[y][x + 1] + this->m_pixels[y + 1][x]);
}
}

for (int y=0; y<(m_yDim-1); y++)
{
res(m_xDim * 2 - 2, y * 2) = this->m_pixels[y][m_xDim - 1];
res(m_xDim * 2 - 2, y * 2 + 1) = 0.5 *
(this->m_pixels[y][m_xDim - 1] +
this->m_pixels[y + 1][m_xDim - 1]);
}

for (int x=0; x<(m_xDim-1); x++)
{
res(x * 2, m_yDim * 2 - 2) = this->m_pixels[m_yDim - 1][x];
res(x * 2 + 1, m_yDim * 2 - 2) = 0.5 *
(this->m_pixels[m_yDim - 1][x] +
this->m_pixels[m_yDim - 1][x + 1]);
}

res(m_xDim * 2 - 2, m_yDim * 2 - 2) =
this->m_pixels[m_yDim - 1][m_xDim - 1];

return res;
}

/*
Image operator -(Image &img1, Image &img2)
{
if ((img1.m_xDim != img2.m_xDim) || (img1.m_yDim != img2.m_yDim))
{
cerr << "Images have different sizes, can not subtract.\n";
exit(1);
}
Image res(img1.m_xDim, img1.m_yDim);
for (int y=0; y<img1.m_yDim; y++)
{
for (int x=0; x<img1.m_xDim; x++)
{
res(x, y) = img1(x, y) - img2(x, y);
}
}
return res;
}
*/

Image operator -(Image &img1, Image &img2)
{
int dimX = img1.GetXDim();
int dimY = img1.GetYDim();

if ((dimX != img2.GetXDim()) || (dimY != img2.GetYDim()))
{
FatalError("Images have different sizes, can not subtract.");
}

Image res(dimX, dimY);

for (int y=0; y<dimY; y++)
{
for (int x=0; x<dimX; x++)
{
res(x, y) = img1(x, y) - img2(x, y);
}
}

return res;
}
49 changes: 49 additions & 0 deletions SMSLD/SMSLD/SMSLD_descriptor/Image.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Image.h -- Declaration of the class Image.


#ifndef IMAGE_H
#define IMAGE_H

/*
#include <cstdlib>
#include <iostream>
#include <cassert>
using namespace std;
*/
#include "SiftUtil.h"


class Image
{
public:
Image(void);
Image(int xDim, int yDim);
Image(const Image &other);
~Image(void);
Image & operator =(const Image &other);

void ReAllocate(int xDim, int yDim);
void Allocate(int xDim, int yDim);
void DeAllocate(void);

double & operator ()(int x, int y);
int GetXDim(void) const;
int GetYDim(void) const;

void Normalize(void);
Image HalfScale(void);
Image DoubleScale(void);
//friend Image operator -(Image &img1, Image &img2);

private:
int m_xDim; // width of the image.
int m_yDim; // height of the image.
double **m_pixels; // pixel values of the image.
};


Image operator -(Image &img1, Image &img2);


#endif
Empty file.
Loading

0 comments on commit 2c2db09

Please sign in to comment.