Commit 3c3eddd1 authored by Cédric Traizet's avatar Cédric Traizet
Browse files

app added

No related merge requests found
Showing with 78 additions and 6 deletions
+78 -6
...@@ -3,3 +3,4 @@ cmake_minimum_required(VERSION 2.8.9) ...@@ -3,3 +3,4 @@ cmake_minimum_required(VERSION 2.8.9)
project(CbDimensionalityReduction) project(CbDimensionalityReduction)
#set(CbDimensionalityReduction_LIBRARIES CbDimensionalityReduction) #set(CbDimensionalityReduction_LIBRARIES CbDimensionalityReduction)
otb_module_impl() otb_module_impl()
OTB_CREATE_APPLICATION(NAME CbDimensionalityReductionTrainer OTB_CREATE_APPLICATION(
NAME CbDimensionalityReductionTrainer
SOURCES cbDimensionalityReductionTrainer.cxx SOURCES cbDimensionalityReductionTrainer.cxx
LINK_LIBRARIES ${${otb-module}_LIBRARIES} LINK_LIBRARIES ${${otb-module}_LIBRARIES}
) )
OTB_CREATE_APPLICATION(
NAME CbDimensionalityReduction
SOURCES cbDimensionalityReduction.cxx
LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES}
)
#include "otbWrapperApplication.h" #include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h" #include "otbWrapperApplicationFactory.h"
#include "otbWrapperChoiceParameter.h"
#include <iostream>
#include "otbImage.h"
//#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include <shark/Models/Autoencoder.h>//normal autoencoder model
#include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights
#include <shark/Models/Normalizer.h>
#include "encode_filter.h"
namespace otb
{
namespace Wrapper
{
class CbDimensionalityReduction : public otb::Wrapper::Application class CbDimensionalityReduction : public otb::Wrapper::Application
{ {
...@@ -13,6 +34,19 @@ private: ...@@ -13,6 +34,19 @@ private:
{ {
SetName("CbDimensionalityReduction"); SetName("CbDimensionalityReduction");
SetDescription("Perform dimensionality reduction on the input image"); SetDescription("Perform dimensionality reduction on the input image");
AddParameter(ParameterType_InputImage, "in", "Input Image");
SetParameterDescription( "in", "The input image to perform dimensionality reduction on.");
AddParameter(ParameterType_InputFilename, "model", "Model file");
SetParameterDescription("model", "A model file (produced by the cbDimensionalityReductionTrainer application).");
AddParameter(ParameterType_InputFilename, "normalizer", "Normalizer model file");
SetParameterDescription("normalizer", "A normalizer model file (produced by the cbDimensionalityReductionTrainer application).");
AddParameter(ParameterType_OutputImage, "out", "Output Image");
SetParameterDescription("out", "Output image");
AddRAMParameter(); AddRAMParameter();
} }
...@@ -22,10 +56,36 @@ private: ...@@ -22,10 +56,36 @@ private:
void DoExecute() void DoExecute()
{ {
typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType;
using image_type = otb::VectorImage<double, 2>;
using FilterType = EncodeFilter<image_type, AutoencoderType, shark::Normalizer<shark::RealVector>> ;
std::cout << "Appli !" << std::endl; std::cout << "Appli !" << std::endl;
int ThisDoesNothing = 0; FloatVectorImageType::Pointer inImage = GetParameterImage("in");
std::string encoderPath = GetParameterString("model");
std::string normalizerPath = GetParameterString("normalizer");
//inImage->UpdateOutputInformation();
using ReaderType = otb::ImageFileReader<image_type>;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName("/mnt/data/home/vincenta/features_2014/SL_MultiTempGapF_Brightness_NDVI_NDWI__.tif");
FilterType::Pointer filter = FilterType::New();
filter->SetAutoencoderModel(encoderPath);
filter->SetNormalizerModel(normalizerPath);
filter->SetInput(reader->GetOutput());
//filter->SetInput(inImage);
filter->UpdateOutputInformation();
SetParameterOutputImage("out", filter->GetOutput());
} }
}; };
}
OTB_APPLICATION_EXPORT(CbDimensionalityReduction) }
OTB_APPLICATION_EXPORT(otb::Wrapper::CbDimensionalityReduction)
...@@ -13,6 +13,7 @@ private: ...@@ -13,6 +13,7 @@ private:
{ {
SetName("CbDimensionalityReductionTrainer"); SetName("CbDimensionalityReductionTrainer");
SetDescription("Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application."); SetDescription("Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application.");
AddRAMParameter();
} }
void DoUpdateParameters() void DoUpdateParameters()
...@@ -20,7 +21,8 @@ private: ...@@ -20,7 +21,8 @@ private:
} }
void DoExecute() void DoExecute()
{ {
std::cout << "Appli !" << std::endl;
int ThisDoesNothing = 0; int ThisDoesNothing = 0;
} }
......
...@@ -3,7 +3,9 @@ otb_module(CbDimensionalityReduction ...@@ -3,7 +3,9 @@ otb_module(CbDimensionalityReduction
DEPENDS DEPENDS
OTBCommon OTBCommon
OTBApplicationEngine OTBApplicationEngine
OTBITK
OTBShark
OTBBoost
DESCRIPTION DESCRIPTION
"${DOCUMENTATION}" "${DOCUMENTATION}"
) )
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment