Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions src/nyx/env_metaparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,89 @@ std::optional<std::string> Environment::set_metaparam (const std::string & p_val
return "error: unrecognized feature parameter of feature 3glcm: \"" + ppath[1] + "\"";
}
}
else if (ppath[0] == "3gldm")
{
// check feature-specific parameter name
if (ppath[1] == "greydepth")
{
// interpret eq_sides[1] as int
int n_greys;
if (Nyxus::parse_as_int(eq_sides[1], n_greys) == false)
{
return "error: cannot parse value \"" + eq_sides[1] + "\" of 3gldm/greydepth: expecting an integer";
}
STNGS_GLDM_GREYDEPTH (fsett_D3_GLDM) = n_greys;
}
else
{
return "error: unrecognized feature parameter of feature 3gldm: \"" + ppath[1] + "\"";
}
}
else if (ppath[0] == "3ngtdm")
{
// check feature-specific parameter name
if (ppath[1] == "greydepth")
{
// interpret eq_sides[1] as int
int n_greys;
if (Nyxus::parse_as_int(eq_sides[1], n_greys) == false)
{
return "error: cannot parse value \"" + eq_sides[1] + "\" of 3ngtdm/greydepth: expecting an integer";
}
STNGS_NGTDM_GREYDEPTH(fsett_D3_NGTDM) = n_greys;
}
else
if (ppath[1] == "radius")
{
// interpret eq_sides[1] as int
int radius = -1;
if (Nyxus::parse_as_int(eq_sides[1], radius) == false || radius <= 0)
{
return "error: cannot parse value \"" + eq_sides[1] + "\" of 3ngtdm/radius: expecting a positive integer";
}
STNGS_NGTDM_RADIUS(fsett_D3_NGTDM) = radius;
}
else
{
return "error: unrecognized feature parameter of feature 3gldm: \"" + ppath[1] + "\"";
}
}
else if (ppath[0] == "3glrlm")
{
// check feature-specific parameter name
if (ppath[1] == "greydepth")
{
// interpret eq_sides[1] as int
int n_greys;
if (Nyxus::parse_as_int(eq_sides[1], n_greys) == false)
{
return "error: cannot parse value \"" + eq_sides[1] + "\" of 3glrlm/greydepth: expecting an integer";
}
STNGS_GLRLM_GREYDEPTH (fsett_D3_GLRLM) = n_greys;
}
else
{
return "error: unrecognized feature parameter of feature 3glrlm: \"" + ppath[1] + "\"";
}
}
else if (ppath[0] == "3glszm")
{
// check feature-specific parameter name
if (ppath[1] == "greydepth")
{
// interpret eq_sides[1] as int
int n_greys;
if (Nyxus::parse_as_int(eq_sides[1], n_greys) == false)
{
return "error: cannot parse value \"" + eq_sides[1] + "\" of 3glszm/greydepth: expecting an integer";
}
STNGS_GLSZM_GREYDEPTH(fsett_D3_GLSZM) = n_greys;
}
else
{
return "error: unrecognized feature parameter of feature 3glrlm: \"" + ppath[1] + "\"";
}
}
else
{
return "error: unrecognized feature \"" + ppath[0] + "\"";
Expand Down Expand Up @@ -177,6 +260,69 @@ std::optional<std::string> Environment::get_metaparam (double & p_val, const std
return "error: unrecognized feature parameter of feature 3glcm: \"" + ppath[1] + "\"";
}
}
else if (ppath[0] == "3gldm")
{
// check feature-specific parameter name
if (ppath[1] == "greydepth")
{
// interpret eq_sides[1] as int
int ival = STNGS_GLDM_GREYDEPTH (fsett_D3_GLDM);
p_val = (double)ival;
}
else
{
return "error: unrecognized feature parameter of feature 3gldm: \"" + ppath[1] + "\"";
}
}
else if (ppath[0] == "3ngtdm")
{
// check feature-specific parameter name
if (ppath[1] == "greydepth")
{
// interpret eq_sides[1] as int
int ival = STNGS_NGTDM_GREYDEPTH (fsett_D3_NGTDM);
p_val = (double)ival;
}
else
if (ppath[1] == "radius")
{
// interpret eq_sides[1] as int
int ival = STNGS_NGTDM_RADIUS (fsett_D3_NGTDM);
p_val = (double)ival;
}
else
{
return "error: unrecognized feature parameter of feature 3gldm: \"" + ppath[1] + "\"";
}
}
else if (ppath[0] == "3glrlm")
{
// check feature-specific parameter name
if (ppath[1] == "greydepth")
{
// interpret eq_sides[1] as int
int ival = STNGS_GLRLM_GREYDEPTH (fsett_D3_GLRLM);
p_val = (double)ival;
}
else
{
return "error: unrecognized feature parameter of feature 3glrlm: \"" + ppath[1] + "\"";
}
}
else if (ppath[0] == "3glsz")
{
// check feature-specific parameter name
if (ppath[1] == "greydepth")
{
// interpret eq_sides[1] as int
int ival = STNGS_GLSZM_GREYDEPTH (fsett_D3_GLSZM);
p_val = (double)ival;
}
else
{
return "error: unrecognized feature parameter of feature 3glszm: \"" + ppath[1] + "\"";
}
}
else
{
return "error: unrecognized feature \"" + ppath[0] + "\"";
Expand Down
15 changes: 15 additions & 0 deletions src/nyx/feature_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ enum class NyxSetting : int
GLCM_OFFSET,
GLCM_NUMANG,
GLCM_SPARSEINTENS,
// GLDM
GLDM_GREYDEPTH,
// NGTDM
NGTDM_GREYDEPTH,
NGTDM_RADIUS,
// GLRLM
GLRLM_GREYDEPTH,
// GLSZM
GLSZM_GREYDEPTH,
//
__COUNT__
};
Expand All @@ -50,4 +59,10 @@ enum class NyxSetting : int
#define STNGS_GLCM_OFFSET(obj) (obj[(int)NyxSetting::GLCM_OFFSET].ival)
#define STNGS_GLCM_NUMANG(obj) (obj[(int)NyxSetting::GLCM_NUMANG].ival)
#define STNGS_GLCM_SPARSEINTENS(obj) (obj[(int)NyxSetting::GLCM_SPARSEINTENS].ival)
#define STNGS_GLDM_GREYDEPTH(obj) (obj[(int)NyxSetting::GLDM_GREYDEPTH].ival)
#define STNGS_GLRLM_GREYDEPTH(obj) (obj[(int)NyxSetting::GLRLM_GREYDEPTH].ival)
#define STNGS_GLSZM_GREYDEPTH(obj) (obj[(int)NyxSetting::GLSZM_GREYDEPTH].ival)
#define STNGS_NGTDM_GREYDEPTH(obj) (obj[(int)NyxSetting::NGTDM_GREYDEPTH].ival)
#define STNGS_NGTDM_RADIUS(obj) (obj[(int)NyxSetting::NGTDM_RADIUS].ival)


12 changes: 0 additions & 12 deletions src/nyx/features/3d_glcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,18 +1069,6 @@ double D3_GLCM_feature::f_GLCM_JVAR(const SimpleMatrix<double>& P_matrix, double
return f;
}

// 'afv' is angled feature values
double D3_GLCM_feature::calc_ave(const std::vector<double>& afv)
{
if (afv.empty())
return 0;

double n = static_cast<double> (afv.size()),
ave = std::reduce(afv.begin(), afv.end()) / n;

return ave;
}

void D3_GLCM_feature::reduce (size_t start, size_t end, std::vector<int>* ptrLabels, std::unordered_map <int, LR>* ptrLabelData, const Fsettings & s, const Dataset & _)
{
for (auto i = start; i < end; i++)
Expand Down
1 change: 0 additions & 1 deletion src/nyx/features/3d_glcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class D3_GLCM_feature : public FeatureMethod, public TextureFeature
void save_value(std::vector<std::vector<double>>& feature_vals);
static void reduce (size_t start, size_t end, std::vector<int>* ptrLabels, std::unordered_map <int, LR>* ptrLabelData, const Fsettings & s, const Dataset & ds);
static void extract (LR& r, const Fsettings& s);
double calc_ave (const std::vector<double>& angled_feature_vals);

private:

Expand Down
59 changes: 31 additions & 28 deletions src/nyx/features/3d_gldm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,35 @@ struct ShiftToNeighbor
};
const static ShiftToNeighbor shifts[] =
{
{-1, 0, 0}, // West
{-1, -1, 0}, // North-West
{0, -1, 0}, // North
{+1, -1, 0}, // North-East
{+1, 0, 0}, // East
{+1, +1, 0}, // South-East
{0, +1, 0}, // South
{-1, +1, 0} , // South-West

{-1, 0, +1}, // West
{-1, -1, +1}, // North-West
{0, -1, +1}, // North
{+1, -1, +1}, // North-East
{+1, 0, +1}, // East
{+1, +1, +1}, // South-East
{0, +1, +1}, // South
{-1, +1, +1}, // South-West

{-1, 0, -1}, // West
{-1, -1, -1}, // North-West
{0, -1, -1}, // North
{+1, -1, -1}, // North-East
{+1, 0, -1}, // East
{+1, +1, -1}, // South-East
{0, +1, -1}, // South
{-1, +1, -1} // South-West
{-1, 0, 0}, // West
{-1, -1, 0}, // North-West
{ 0, -1, 0}, // North
{+1, -1, 0}, // North-East
{+1, 0, 0}, // East
{+1, +1, 0}, // South-East
{ 0, +1, 0}, // South
{-1, +1, 0}, // South-West

{-1, 0, +1}, // West
{-1, -1, +1}, // North-West
{ 0, -1, +1}, // North
{+1, -1, +1}, // North-East
{+1, 0, +1}, // East
{+1, +1, +1}, // South-East
{ 0, +1, +1}, // South
{-1, +1, +1}, // South-West

{-1, 0, -1}, // West
{-1, -1, -1}, // North-West
{ 0, -1, -1}, // North
{+1, -1, -1}, // North-East
{+1, 0, -1}, // East
{+1, +1, -1}, // South-East
{ 0, +1, -1}, // South
{-1, +1, -1}, // South-West

{ 0, 0, +1}, // up
{ 0, 0, -1} // down
};

const static int nsh = sizeof(shifts) / sizeof(ShiftToNeighbor);
Expand Down Expand Up @@ -87,7 +90,7 @@ void D3_GLDM_feature::calculate (LR& r, const Fsettings& s)
SimpleCube<PixIntens> D;
D.allocate(w, h, d);

auto greyInfo = STNGS_NGREYS(s); // former Nyxus::theEnvironment.get_coarse_gray_depth()
auto greyInfo = STNGS_GLDM_GREYDEPTH(s); // former Nyxus::theEnvironment.get_coarse_gray_depth()
if (STNGS_IBSI(s)) // former Nyxus::theEnvironment.ibsi_compliance
greyInfo = 0;

Expand Down Expand Up @@ -177,7 +180,7 @@ void D3_GLDM_feature::calculate (LR& r, const Fsettings& s)
k++;

// update max referenced dependency
max_Nd = std::max(max_Nd, col + 1);
max_Nd = (std::max) (max_Nd, z.second);
}

// If not IBSI mode, adjust Nd. No need to iterate the GLDM beyond 'max_Nd'
Expand Down
Loading
Loading