rename terms
This commit is contained in:
parent
662c86234f
commit
e6e8a68c09
@ -1,20 +1,20 @@
|
|||||||
add_executable(dcode_fcode common.hh dcode_fcode.cc)
|
add_executable(dcode_feat common.hh dcode_feat.cc)
|
||||||
target_link_libraries(dcode_fcode PRIVATE args)
|
target_link_libraries(dcode_feat PRIVATE args)
|
||||||
|
|
||||||
add_executable(fcode_bidx common.hh fcode_bidx.cc)
|
add_executable(feat_block common.hh feat_block.cc)
|
||||||
target_link_libraries(fcode_bidx PRIVATE args)
|
target_link_libraries(feat_block PRIVATE args)
|
||||||
|
|
||||||
add_executable(bidx_stego common.hh bidx_stego.cc)
|
add_executable(block_stego common.hh block_stego.cc)
|
||||||
target_link_libraries(bidx_stego PRIVATE args minimp4 openh264)
|
target_link_libraries(block_stego PRIVATE args minimp4 openh264)
|
||||||
|
|
||||||
add_executable(stego_fprob common.hh stego_fprob.cc)
|
add_executable(stego_aprob common.hh stego_aprob.cc)
|
||||||
target_link_libraries(stego_fprob PRIVATE args minimp4 openh264)
|
target_link_libraries(stego_aprob PRIVATE args minimp4 openh264)
|
||||||
|
|
||||||
add_executable(fprob_fcprob common.hh fprob_fcprob.cc)
|
add_executable(aprob_fprob common.hh aprob_fprob.cc)
|
||||||
target_link_libraries(fprob_fcprob PRIVATE args)
|
target_link_libraries(aprob_fprob PRIVATE args)
|
||||||
|
|
||||||
add_executable(fcprob_fcode common.hh fcprob_fcode.cc)
|
add_executable(fprob_feat common.hh fprob_feat.cc)
|
||||||
target_link_libraries(fcprob_fcode PRIVATE args)
|
target_link_libraries(fprob_feat PRIVATE args)
|
||||||
|
|
||||||
add_executable(fcode_dcode common.hh fcode_dcode.cc)
|
add_executable(feat_dcode common.hh feat_dcode.cc)
|
||||||
target_link_libraries(fcode_dcode PRIVATE args)
|
target_link_libraries(feat_dcode PRIVATE args)
|
||||||
|
66
conv/aprob_fprob.cc
Normal file
66
conv/aprob_fprob.cc
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <args.hxx>
|
||||||
|
|
||||||
|
#include "common.hh"
|
||||||
|
|
||||||
|
|
||||||
|
namespace param {
|
||||||
|
using namespace ::args;
|
||||||
|
|
||||||
|
ArgumentParser parser {
|
||||||
|
"converter: alter-probability matrix -> feature probability matrix"
|
||||||
|
};
|
||||||
|
HelpFlag help {
|
||||||
|
parser, "help", "display this menu", {'h', "help"},
|
||||||
|
};
|
||||||
|
|
||||||
|
ValueFlag<std::string> smap {
|
||||||
|
parser, "path", "step map file path", {"smap"},
|
||||||
|
};
|
||||||
|
ValueFlag<std::string> fmap {
|
||||||
|
parser, "path", "feature map file path", {"fmap"},
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace param
|
||||||
|
|
||||||
|
|
||||||
|
static void Exec() {
|
||||||
|
const auto aprobs = ReadMatrix<double>(std::cin);
|
||||||
|
Enforce(aprobs.size() > 0 && aprobs[0].size() > 0, "empty matrix");
|
||||||
|
|
||||||
|
std::ifstream fmap_st {args::get(param::fmap)};
|
||||||
|
Enforce(!!fmap_st, "fmap path is invalid");
|
||||||
|
const auto fmap = ReadMatrix<uint32_t>(fmap_st);
|
||||||
|
Enforce(fmap.size() > 0, "empty fmap");
|
||||||
|
for (auto& idxs : fmap) {
|
||||||
|
Enforce(idxs.size() > 0, "fmap has empty item");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t t = 0; t < aprobs.size(); ++t) {
|
||||||
|
Enforce(aprobs[t].size() <= fmap.size(), "unmatched aprobs and fmap");
|
||||||
|
for (size_t c = 0; c < fmap.size(); ++c) {
|
||||||
|
double sum = 0;
|
||||||
|
for (auto i : fmap[c]) {
|
||||||
|
sum += aprobs[t][i];
|
||||||
|
}
|
||||||
|
std::cout << sum / fmap[c].size() << ' ';
|
||||||
|
}
|
||||||
|
std::cout << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
try {
|
||||||
|
param::parser.ParseCLI(argc, argv);
|
||||||
|
Exec();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} catch (const args::Help&) {
|
||||||
|
std::cout << param::parser << std::endl;
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
@ -11,7 +11,7 @@ namespace param {
|
|||||||
using namespace ::args;
|
using namespace ::args;
|
||||||
|
|
||||||
ArgumentParser parser {
|
ArgumentParser parser {
|
||||||
"converter: feature code probability matrix -> feature code"
|
"converter: data code -> feature"
|
||||||
};
|
};
|
||||||
HelpFlag help {
|
HelpFlag help {
|
||||||
parser, "help", "display this menu", {'h', "help"},
|
parser, "help", "display this menu", {'h', "help"},
|
||||||
@ -22,18 +22,18 @@ ValueFlag<std::string> smap {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ValueFlag<uint32_t> first {
|
ValueFlag<uint32_t> first {
|
||||||
parser, "0", "first fcode", {"first"}, 0
|
parser, "0", "first feature", {"first"}, 0
|
||||||
};
|
};
|
||||||
ValueFlag<uint32_t> fcnum {
|
ValueFlag<uint32_t> fnum {
|
||||||
parser, "50", "number of fcode alphabet", {"fc-num"}, 50
|
parser, "50", "number of feature kinds", {"fnum"}, 50
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace param
|
} // namespace param
|
||||||
|
|
||||||
|
|
||||||
static void Exec() {
|
static void Exec() {
|
||||||
const auto fcnum = args::get(param::fcnum);
|
const auto fnum = args::get(param::fnum);
|
||||||
Enforce(fcnum > 0, "fc-num must be greater than 0");
|
Enforce(fnum > 0, "fnum must be greater than 0");
|
||||||
|
|
||||||
std::ifstream smap_st {args::get(param::smap)};
|
std::ifstream smap_st {args::get(param::smap)};
|
||||||
Enforce(!!smap_st, "smap path is invalid");
|
Enforce(!!smap_st, "smap path is invalid");
|
||||||
@ -45,14 +45,14 @@ static void Exec() {
|
|||||||
Enforce(br.size() == bn, "all node should have the same number of branch");
|
Enforce(br.size() == bn, "all node should have the same number of branch");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t fcode = args::get(param::first);
|
uint32_t feat = args::get(param::first);
|
||||||
std::cout << fcode << '\n';
|
std::cout << feat << '\n';
|
||||||
|
|
||||||
for (uint32_t dcode, t = 0; std::cin >> dcode; ++t) {
|
for (uint32_t dcode, t = 0; std::cin >> dcode; ++t) {
|
||||||
Enforce(dcode < bn, "dcode must be lower than number of branch");
|
Enforce(dcode < bn, "dcode must be lower than number of branch");
|
||||||
Enforce(fcnum*(t+1) <= smap.size(), "smap row shortage");
|
Enforce(fnum*(t+1) <= smap.size(), "smap row shortage");
|
||||||
fcode = smap[t*fcnum + fcode][dcode];
|
feat = smap[t*fnum + feat][dcode];
|
||||||
std::cout << fcode << '\n';
|
std::cout << feat << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,33 +11,33 @@ namespace param {
|
|||||||
using namespace ::args;
|
using namespace ::args;
|
||||||
|
|
||||||
ArgumentParser parser {
|
ArgumentParser parser {
|
||||||
"converter: feature codes -> block indices"
|
"converter: feature -> block"
|
||||||
};
|
};
|
||||||
HelpFlag help {
|
HelpFlag help {
|
||||||
parser, "help", "display this menu", {'h', "help"},
|
parser, "help", "display this menu", {'h', "help"},
|
||||||
};
|
};
|
||||||
|
|
||||||
ValueFlag<std::string> fcmap {
|
ValueFlag<std::string> fmap {
|
||||||
parser, "path", "feature code map", {"fc-map"},
|
parser, "path", "path to feature map", {"fmap"},
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace param
|
} // namespace param
|
||||||
|
|
||||||
|
|
||||||
static void Exec() {
|
static void Exec() {
|
||||||
std::ifstream fcmap_st {args::get(param::fcmap)};
|
std::ifstream fmap_st {args::get(param::fmap)};
|
||||||
Enforce(!!fcmap_st, "fcmap path is invalid");
|
Enforce(!!fmap_st, "fmap path is invalid");
|
||||||
const auto fcmap = ReadMatrix<uint32_t>(fcmap_st);
|
const auto fmap = ReadMatrix<uint32_t>(fmap_st);
|
||||||
Enforce(fcmap.size() > 0, "empty fcmap");
|
Enforce(fmap.size() > 0, "empty fmap");
|
||||||
for (auto& idxs : fcmap) {
|
for (auto& idxs : fmap) {
|
||||||
Enforce(idxs.size() > 0, "fcmap has empty item");
|
Enforce(idxs.size() > 0, "fmap has empty item");
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t fcode;
|
size_t feat;
|
||||||
while (std::cin >> fcode) {
|
while (std::cin >> feat) {
|
||||||
Enforce(fcode < fcmap.size(), "fcode overflow");
|
Enforce(feat < fmap.size(), "feat overflow");
|
||||||
|
|
||||||
for (const auto idx : fcmap[fcode]) {
|
for (const auto idx : fmap[feat]) {
|
||||||
std::cout << idx << ' ';
|
std::cout << idx << ' ';
|
||||||
}
|
}
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
@ -21,16 +21,16 @@ ValueFlag<std::string> smap {
|
|||||||
parser, "path", "step map file path", {"smap"},
|
parser, "path", "step map file path", {"smap"},
|
||||||
};
|
};
|
||||||
|
|
||||||
ValueFlag<uint32_t> fcnum {
|
ValueFlag<uint32_t> fnum {
|
||||||
parser, "50", "number of fcode alphabet", {"fc-num"}, 50
|
parser, "50", "number of feature kinds", {"fnum"}, 50
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace param
|
} // namespace param
|
||||||
|
|
||||||
|
|
||||||
static void Exec() {
|
static void Exec() {
|
||||||
const auto fcnum = args::get(param::fcnum);
|
const auto fnum = args::get(param::fnum);
|
||||||
Enforce(fcnum > 0, "fc-num must be greater than 0");
|
Enforce(fnum > 0, "fc-num must be greater than 0");
|
||||||
|
|
||||||
std::ifstream smap_st {args::get(param::smap)};
|
std::ifstream smap_st {args::get(param::smap)};
|
||||||
Enforce(!!smap_st, "smap path is invalid");
|
Enforce(!!smap_st, "smap path is invalid");
|
||||||
@ -42,17 +42,17 @@ static void Exec() {
|
|||||||
Enforce(br.size() == bn, "all node should have the same number of branch");
|
Enforce(br.size() == bn, "all node should have the same number of branch");
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t fcode_p;
|
size_t feat_p;
|
||||||
std::cin >> fcode_p;
|
std::cin >> feat_p;
|
||||||
for (uint32_t fcode, t = 0; std::cin >> fcode; ++t) {
|
for (uint32_t feat, t = 0; std::cin >> feat; ++t) {
|
||||||
Enforce(fcode < fcnum, "fcode overflow");
|
Enforce(feat < fnum, "feat overflow");
|
||||||
Enforce(fcnum*(t+1) <= smap.size(), "smap row shortage");
|
Enforce(fnum*(t+1) <= smap.size(), "smap row shortage");
|
||||||
|
|
||||||
const auto& row = smap[t*fcnum + fcode_p];
|
const auto& row = smap[t*fnum + feat_p];
|
||||||
auto itr = std::find(row.begin(), row.end(), fcode);
|
auto itr = std::find(row.begin(), row.end(), feat);
|
||||||
Enforce(itr != row.end(), "invalid step detected");
|
Enforce(itr != row.end(), "invalid step detected");
|
||||||
std::cout << std::distance(row.begin(), itr) << '\n';
|
std::cout << std::distance(row.begin(), itr) << '\n';
|
||||||
fcode_p = fcode;
|
feat_p = feat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,66 +0,0 @@
|
|||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <args.hxx>
|
|
||||||
|
|
||||||
#include "common.hh"
|
|
||||||
|
|
||||||
|
|
||||||
namespace param {
|
|
||||||
using namespace ::args;
|
|
||||||
|
|
||||||
ArgumentParser parser {
|
|
||||||
"converter: feature codes -> feature indices"
|
|
||||||
};
|
|
||||||
HelpFlag help {
|
|
||||||
parser, "help", "display this menu", {'h', "help"},
|
|
||||||
};
|
|
||||||
|
|
||||||
ValueFlag<std::string> smap {
|
|
||||||
parser, "path", "step map file path", {"smap"},
|
|
||||||
};
|
|
||||||
ValueFlag<std::string> fcmap {
|
|
||||||
parser, "path", "feature code map", {"fc-map"},
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace param
|
|
||||||
|
|
||||||
|
|
||||||
static void Exec() {
|
|
||||||
const auto fprobs = ReadMatrix<double>(std::cin);
|
|
||||||
Enforce(fprobs.size() > 0 && fprobs[0].size() > 0, "empty matrix");
|
|
||||||
|
|
||||||
std::ifstream fcmap_st {args::get(param::fcmap)};
|
|
||||||
Enforce(!!fcmap_st, "fcmap path is invalid");
|
|
||||||
const auto fcmap = ReadMatrix<uint32_t>(fcmap_st);
|
|
||||||
Enforce(fcmap.size() > 0, "empty fcmap");
|
|
||||||
for (auto& idxs : fcmap) {
|
|
||||||
Enforce(idxs.size() > 0, "fcmap has empty item");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t t = 0; t < fprobs.size(); ++t) {
|
|
||||||
Enforce(fprobs[t].size() <= fcmap.size(), "unmatched fprobs and fcmap");
|
|
||||||
for (size_t c = 0; c < fcmap.size(); ++c) {
|
|
||||||
double sum = 0;
|
|
||||||
for (auto i : fcmap[c]) {
|
|
||||||
sum += fprobs[t][i];
|
|
||||||
}
|
|
||||||
std::cout << sum / fcmap[c].size() << ' ';
|
|
||||||
}
|
|
||||||
std::cout << '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
try {
|
|
||||||
param::parser.ParseCLI(argc, argv);
|
|
||||||
Exec();
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
} catch (const args::Help&) {
|
|
||||||
std::cout << param::parser << std::endl;
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
std::cerr << e.what() << std::endl;
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
@ -18,7 +18,7 @@ namespace param {
|
|||||||
using namespace ::args;
|
using namespace ::args;
|
||||||
|
|
||||||
ArgumentParser parser {
|
ArgumentParser parser {
|
||||||
"converter: feature code probability matrix -> feature code"
|
"converter: feature probability matrix -> feature series"
|
||||||
};
|
};
|
||||||
HelpFlag help {
|
HelpFlag help {
|
||||||
parser, "help", "display this menu", {'h', "help"},
|
parser, "help", "display this menu", {'h', "help"},
|
@ -20,7 +20,7 @@ namespace param {
|
|||||||
using namespace ::args;
|
using namespace ::args;
|
||||||
|
|
||||||
ArgumentParser parser {
|
ArgumentParser parser {
|
||||||
"converter: stego -> feature probability matrix"
|
"converter: stego -> alter-probability matrix"
|
||||||
};
|
};
|
||||||
HelpFlag help {
|
HelpFlag help {
|
||||||
parser, "help", "display this menu", {'h', "help"},
|
parser, "help", "display this menu", {'h', "help"},
|
@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# generate random feature indices
|
|
||||||
|
|
||||||
row=$1
|
|
||||||
col=$2
|
|
||||||
max=$3
|
|
||||||
|
|
||||||
for ((y = 0; y < row; ++y)); do
|
|
||||||
n=$((RANDOM%col + 1))
|
|
||||||
for ((x = 0; x < n; ++x)); do
|
|
||||||
printf "$((RANDOM%max)) "
|
|
||||||
done
|
|
||||||
printf "\n"
|
|
||||||
done
|
|
@ -1,55 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# calculate fprob from indices and fprob matrix
|
|
||||||
# output: average feature's feature probability and average non-feature's feature probability
|
|
||||||
|
|
||||||
bidx=$1
|
|
||||||
fprob=$2
|
|
||||||
n=$3
|
|
||||||
|
|
||||||
script=$(cat - <<EOS
|
|
||||||
BEGIN {
|
|
||||||
type = 0; # 0: bidx, 1: fprob
|
|
||||||
|
|
||||||
nprob = 0;
|
|
||||||
nprob_max = 0;
|
|
||||||
pprob = 0;
|
|
||||||
pprob_max = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
if (type == 0) {
|
|
||||||
split("", feats);
|
|
||||||
|
|
||||||
for (i = 1; i <= NF; ++i) {
|
|
||||||
feats[i] = \$i;
|
|
||||||
}
|
|
||||||
|
|
||||||
type = 1;
|
|
||||||
} else if (type == 1) {
|
|
||||||
sum = 0;
|
|
||||||
for (i = 1; i <= NF; ++i) {
|
|
||||||
sum += \$i;
|
|
||||||
}
|
|
||||||
|
|
||||||
lprob = 0;
|
|
||||||
for (i = 1; i <= length(feats); ++i) {
|
|
||||||
lprob += \$(feats[i]+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
nprob += sum-lprob;
|
|
||||||
pprob += lprob;
|
|
||||||
|
|
||||||
nprob_max += NF-length(feats)
|
|
||||||
pprob_max += length(feats)
|
|
||||||
|
|
||||||
type = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
END {
|
|
||||||
print pprob/pprob_max, nprob/nprob_max;
|
|
||||||
}
|
|
||||||
EOS
|
|
||||||
)
|
|
||||||
paste -d "\n" $bidx $fprob | head -n$((n*2)) | awk "$script"
|
|
Loading…
x
Reference in New Issue
Block a user