-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed MSLD_pyramid to PMSLD. Added PSMSLD
- Loading branch information
Big Smile
committed
Jan 17, 2014
1 parent
b041221
commit 2c2db09
Showing
53 changed files
with
7,997 additions
and
11 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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
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
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 not shown.
Binary file not shown.
Binary file not shown.
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
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; | ||
} |
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
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.
Oops, something went wrong.