Skip to content
Snippets Groups Projects
Commit 80f9d699 authored by Cédric Traizet's avatar Cédric Traizet
Browse files

debugging the vector reduction app

parent e7e3f089
No related branches found
No related tags found
1 merge request!4Dimensionality reduction algorithms
......@@ -222,7 +222,7 @@ private:
}
// Rescale vector image
m_Rescaler->SetScale(stddevMeasurementVector*5);
m_Rescaler->SetScale(stddevMeasurementVector*3);
m_Rescaler->SetShift(meanMeasurementVector);
m_Rescaler->SetInput(inImage);
......
......@@ -103,6 +103,8 @@ private:
}
input->PushBack(mv);
}
std::cout << GetParameterStringList("feat")[0] << std::endl;
std::cout << input->GetMeasurementVector(0) << std::endl;
MeasurementType meanMeasurementVector;
MeasurementType stddevMeasurementVector;
......
......@@ -57,7 +57,7 @@ class CbDimensionalityReductionVector : public Application
/** Filters typedef */
typedef double ValueType;
typedef float ValueType;
typedef itk::VariableLengthVector<ValueType> InputSampleType;
typedef itk::Statistics::ListSample<InputSampleType> ListSampleType;
typedef MachineLearningModel<itk::VariableLengthVector<ValueType>, itk::VariableLengthVector<ValueType>> DimensionalityReductionModelType;
......@@ -136,6 +136,7 @@ class CbDimensionalityReductionVector : public Application
if ( HasValue("in") )
{
std::string shapefile = GetParameterString("in");
otb::ogr::DataSource::Pointer ogrDS;
OGRSpatialReference oSRS("");
......@@ -153,21 +154,32 @@ class CbDimensionalityReductionVector : public Application
key.erase( std::remove_if(key.begin(),key.end(),IsNotAlphaNum), key.end());
std::transform(key.begin(), key.end(), key.begin(), tolower);
OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType();
if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal)
{
/*if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal)
{*/
std::string tmpKey="feat."+key;
AddChoice(tmpKey,item);
}
//}
}
}
}
void DoExecute() ITK_OVERRIDE
{
clock_t tic = clock();
std::cout << GetChoiceKeys("feat")[0] << std::endl;
std::cout << GetChoiceKeys("feat")[1] << std::endl;
std::cout << GetChoiceKeys("feat")[2] << std::endl;
std::cout << GetChoiceKeys("feat")[3] << std::endl;
std::cout << GetChoiceKeys("feat")[4] << std::endl;
std::cout << GetChoiceKeys("feat")[5] << std::endl;
std::cout << GetChoiceKeys("feat")[6] << std::endl;
std::cout << GetChoiceKeys("feat")[7] << std::endl;
std::cout << GetChoiceKeys("feat")[8] << std::endl;
std::string shapefile = GetParameterString("in");
otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read);
otb::ogr::Layer layer = source->GetLayer(0);
......@@ -177,18 +189,31 @@ class CbDimensionalityReductionVector : public Application
input->SetMeasurementVectorSize(nbFeatures);
otb::ogr::Layer::const_iterator it = layer.cbegin();
otb::ogr::Layer::const_iterator itEnd = layer.cend();
std::cout << (*it)[GetSelectedItems("feat")[0]].GetValue<double>() << std::endl;
for( ; it!=itEnd ; ++it)
{
MeasurementType mv;
mv.SetSize(nbFeatures);
for(int idx=0; idx < nbFeatures; ++idx)
{
mv[idx] = (*it)[GetSelectedItems("feat")[idx]].GetValue<double>();
mv[idx] = static_cast<float>( (*it)[GetSelectedItems("feat")[idx]].GetValue<double>() );
}
input->PushBack(mv);
}
std::cout << GetSelectedItems("feat")[0] << std::endl;
std::cout << input->GetMeasurementVector(0) << std::endl;
/** Statistics for shift/scale */
MeasurementType meanMeasurementVector;
......@@ -242,8 +267,9 @@ class CbDimensionalityReductionVector : public Application
ListSampleType::Pointer listSample = trainingShiftScaleFilter->GetOutput();
ListSampleType::Pointer target = m_Model->PredictBatch(listSample);
target = input;
std::cout << target->GetMeasurementVector(0) << std::endl;
std::cout << input->GetMeasurementVector(0) << std::endl;
/** Create/Update Output Shape file */
std::cout << GetParameterStringList("featout").size() << std::endl;
......@@ -350,7 +376,7 @@ class CbDimensionalityReductionVector : public Application
for (std::size_t i=0; i<classfieldname.size(); ++i){
dstFeature[classfieldname[i]].SetValue<ValueType>(target->GetMeasurementVector(count)[i]);
dstFeature[classfieldname[i]].SetValue<double>(target->GetMeasurementVector(count)[i]);
}
if (updateMode)
{
......
......@@ -189,7 +189,7 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage>
// This call is threadsafe
labels = m_Model->PredictBatch(samples);
labels = samples;
// Set the output values
typename TargetListSampleType::ConstIterator labIt = labels->Begin();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment