Add imageExtrapolation.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#include "imageExtrapolation.h"
|
||||
#include "Function1D.h"
|
||||
#include "Function2D.h"
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
using namespace Recon;
|
||||
using namespace Aurora;
|
||||
|
||||
Matrix Recon::imageExtrapolation(const Matrix& aImg, int aDim)
|
||||
{
|
||||
if(aDim == 3)
|
||||
{
|
||||
size_t zSize = aImg.getDimSize(2);
|
||||
Matrix zIndexZero = Matrix::fromRawData(new double[zSize], zSize);
|
||||
std::vector<int> indexe;
|
||||
for(int i=0; i<zSize; ++i)
|
||||
{
|
||||
double value = sum(aImg($,$,i).toMatrix(), FunctionDirection::All)[0];
|
||||
if(value == 0)
|
||||
{
|
||||
zIndexZero[i] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
zIndexZero[i] = 0;
|
||||
indexe.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(!indexe.empty())
|
||||
{
|
||||
Matrix result = aImg;
|
||||
std::vector<int> lowerZIndexe;
|
||||
for(int i=0; i<=indexe[0] - 1; ++i)
|
||||
{
|
||||
lowerZIndexe.push_back(i);
|
||||
}
|
||||
for(int i=0; i<lowerZIndexe.size(); ++i)
|
||||
{
|
||||
Matrix insert = repmat(aImg($,$,indexe[0]).toMatrix(), 1, 1, sum(zIndexZero.block(0, 0, *lowerZIndexe.end()), FunctionDirection::All)[0]);
|
||||
}
|
||||
|
||||
// lowerZIndexe.clear();
|
||||
// for(size_t i=0; i<=*indexe.end(); ++i)
|
||||
// {
|
||||
// lowerZIndexe.push_back(i);
|
||||
// }
|
||||
Matrix insert = repmat(aImg($,$,*(indexe.end() - 1)).toMatrix(), 1, 1, sum(zIndexZero, FunctionDirection::All)[0]);
|
||||
result.setBlock(2, *(indexe.end()-1) + 1, zSize-1, insert);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return aImg;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef IMAGE_EXTRA_POLATION
|
||||
#define IMAGE_EXTRA_POLATION
|
||||
|
||||
#include "Matrix.h"
|
||||
|
||||
namespace Recon
|
||||
{
|
||||
Aurora::Matrix imageExtrapolation(const Aurora::Matrix& aImg, int aDim);
|
||||
}
|
||||
|
||||
|
||||
#endif // IMAGE_EXTRA_POLATION
|
||||
Reference in New Issue
Block a user