Commit 125df33e authored by Yann Jacquelet's avatar Yann Jacquelet
Browse files

Work on Millet saturation descriptor.

	* green/exp/annotating/saturation: New directory.
	* green/exp/annotating/saturation/Makefile.am: New Makefile.
	* green/exp/annotating/saturation/saturation.cc: New source file.
parent b9a5b97f
......@@ -75,12 +75,24 @@
* bin/pgm_to_pbm.cc,
* bin/ppm_negate.cc: New.
2010-06-21 Yann Jacquelet <jacquelet@lrde.epita.fr>
Work on Millet saturation descriptor.
* green/exp/annotating/saturation: New directory.
* green/exp/annotating/saturation/Makefile.am: New Makefile.
* green/exp/annotating/saturation/saturation.cc: New source file.
* green/exp/annotating/saturation/text-color.txt: New image class.
* green/exp/annotating/saturation/text-img.txt: New image class.
* green/exp/annotating/saturation/text-only.txt: New image class.
2010-06-21 Yann Jacquelet <jacquelet@lrde.epita.fr>
Work on Millet hsv descriptors.
* green/exp/annotating/hsv: New directory.
* green/Exp/annotating/hsv/hsv.cc: New source file.
* green/exp/annotating/hsv/hsv.cc: New source file.
2010-06-21 Yann Jacquelet <jacquelet@lrde.epita.fr>
......
#
# Generic Makefile
#
#########
# TOOLS #
#########
LOADLIBES= -lboost_filesystem
INCLUDES1= -I$(HOME)/git/olena/milena/sandbox/green
INCLUDES2= -I$(HOME)/git/olena/milena
INCLUDES= $(INCLUDES1) $(INCLUDES2)
#CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
CXXFLAGS= -DNDEBUG -O3 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
ECHO= echo
RM= rm
MKDIR= mkdir -p
CP= cp
SOURCE_PATTERN= green/exp
BUILD__PATTERN= green/build/exp
ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
# Case where make is done from build directory.
SOURCE_DIR= $(subst $(BUILD__PATTERN),$(SOURCE_PATTERN),$(PWD))
BUILD__DIR= $(PWD)/
else
# Case where make is done from source directory.
SOURCE_DIR= $(PWD)/
BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
endif
SRC= $(notdir $(wildcard $(SOURCE_DIR)/*.cc))
OLD= $(notdir $(wildcard $(SOURCE_DIR)/*~))
OBJ= $(patsubst %.cc,%.o,$(SRC))
SOURCE_MAKEFILE=Makefile.am
BUILD__MAKEFILE=Makefile
TARGET_FILE= $(notdir $(PWD))
SOURCE_FILES= $(notdir $(wildcard $(SOURCE_DIR)/*.*))
BUILD__FILES= $(filter-out $(SRC) $(SOURCE_MAKEFILE), $(SOURCE_FILES))
BUILD__F_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__FILES))
SOURCE_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_FILES))
BUILD__M_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__MAKEFILE))
SOURCE_M_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_MAKEFILE))
TARGET_F_PATH= $(addprefix $(BUILD__DIR)/,$(TARGET_FILE))
OBJ_F_PATH= $(addprefix $(BUILD__DIR)/,$(OBJ))
SRC_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SRC))
OLD_F_PATH= $(addprefix $(SOURCE_DIR)/,$(OLD))
#############
# BOOTSTRAP #
#############
bootstrap: $(BUILD__DIR) $(BUILD__F_PATH) $(BUILD__M_PATH)
# Create, if nessary, the destination directory
$(BUILD__DIR):
$(MKDIR) $(BUILD__DIR)
# Copy, if nessary, all the files, except the Makefile.am
$(BUILD__F_PATH): $(SOURCE_F_PATH)
$(CP) $(addprefix $(SOURCE_DIR),$(@F)) $@
# Copy if nessary, the Makefile.am into Makefile
$(BUILD__M_PATH): $(SOURCE_M_PATH)
$(CP) $(SOURCE_M_PATH) $(BUILD__M_PATH)
#######
# ALL #
#######
# We assume that the call is done from the build directory.
# With the directive vpath, hidden files are found in the source directory.
all: $(TARGET_F_PATH)
$(TARGET_F_PATH): $(OBJ_F_PATH)
$(LINK.cc) $< $(LOADLIBES) $(LDLIBS) -o $@
$(OBJ_F_PATH):$(SRC_F_PATH)
$(COMPILE.cc) $(OUTPUT_OPTION) $<
#########
# CLEAN #
#########
# Force every time the deletion
clean: clean_target clean_obj clean_dst clean_old #clean_make
clean_target:
-@$(RM) $(TARGET_F_PATH) &> /dev/null
clean_obj:
-@$(RM) $(OBJ_F_PATH) &> /dev/null
clean_dst:
-@$(RM) $(BUILD_F_PATH) &> /dev/null
clean_make:
-@$(RM) $(BUILD_M_PATH) &> /dev/null
clean_old:
-@$(RM) $(OLD_F_PATH) &> /dev/null
#########
# PRINT #
#########
print: print_tools print_bootstrap
print_tools:
@$(ECHO) "HOME = $(HOME)"
@$(ECHO) "INCLUDES = $(INCLUDES)"
@$(ECHO) "CXXFLAGS = $(CXXFLAGS)"
@$(ECHO) "ECHO = $(ECHO)"
@$(ECHO) "RM = $(RM)"
@$(ECHO) "MKDIR = $(MKDIR)"
@$(ECHO) "CP = $(CP)"
@$(ECHO)
print_bootstrap:
@$(ECHO) "PWD = $(PWD)"
@$(ECHO) "SOURCE_PATTERN = $(SOURCE_PATTERN)"
@$(ECHO) "BUILD__PATTERN = $(BUILD__PATTERN)"
@$(ECHO) "SOURCE_DIR = $(SOURCE_DIR)"
@$(ECHO) "BUILD__DIR = $(BUILD__DIR)"
@$(ECHO) "SOURCE_MAKEFILE = $(SOURCE_MAKEFILE)"
@$(ECHO) "BUILD__MAKEFILE = $(BUILD__MAKEFILE)"
@$(ECHO) "TARGET_FILE = $(TARGET_FILE)"
@$(ECHO) "SOURCE_FILES = $(SOURCE_FILES)"
@$(ECHO) "SOURCE_F_PATH = $(SOURCE_F_PATH)"
@$(ECHO) "BUILD__FILES = $(BUILD__FILES)"
@$(ECHO) "BUILD__F_PATH = $(BUILD__F_PATH)"
@$(ECHO) "BUILD__M_PATH = $(BUILD__M_PATH)"
@$(ECHO) "SOURCE_M_PATH = $(SOURCE_M_PATH)"
@$(ECHO) "SRC = $(SRC)"
@$(ECHO) "OBJ = $(OBJ)"
@$(ECHO) "OLD = $(OLD)"
@$(ECHO) "SRC_F_PATH = $(SRC_F_PATH)"
@$(ECHO) "OBJ_F_PATH = $(OBJ_F_PATH)"
@$(ECHO) "OLD_F_PATH = $(OLD_F_PATH)"
@$(ECHO)
// SATURATION TEST CF MILLET 2008
#include <iostream>
#include <sstream>
#include <boost/filesystem.hpp>
#include <mln/img_path.hh>
#include <mln/accu/stat/histo1d.hh>
#include <mln/core/image/image1d.hh>
#include <mln/core/image/image2d.hh>
#include <mln/core/image/dmorph/image_if.hh>
#include <mln/data/compute.hh>
#include <mln/data/stretch.hh>
#include <mln/data/transform.hh>
#include <mln/math/max.hh>
#include <mln/math/min.hh>
#include <mln/geom/nsites.hh>
#include <mln/fun/v2v/rgb_to_saturation_map.hh>
#include <mln/io/ppm/load.hh>
//#include <mln/io/pgm/save.hh>
#include <mln/io/plot/save_image_sh.hh>
#include <mln/value/rgb8.hh>
template <typename I>
unsigned count_histo(const mln::Image<I>& img_)
{
const I& img = exact(img_);
mln_precondition(img.is_valid());
unsigned result = 0;
mln_piter(I) p(img.domain());
for_all(p)
result += img(p);
return result;
}
float saturation_test(const std::string input,
const std::string output,
// const std::string tmp,
const unsigned threshold)
{
typedef mln::fun::v2v::rgb_to_saturation_map<8> t_rgb_to_saturation_map;
mln::image2d<mln::value::rgb8> input_rgb8;
mln::image2d<mln::value::int_u8> map;
mln::image1d<unsigned> histo;
unsigned cnt1;
unsigned cnt2;
float prop;
mln::io::ppm::load(input_rgb8, input.c_str());
map = mln::data::transform(input_rgb8, t_rgb_to_saturation_map());
histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map);
cnt1 = count_histo(histo | mln::box1d(mln::point1d(0),
mln::point1d(threshold)));
cnt2 = mln::geom::nsites(input_rgb8);
prop = ((100.0 * cnt1) / cnt2);
mln::io::plot::save_image_sh(histo, output.c_str());
// mln::io::pgm::save(map, tmp.c_str());
return prop;
}
int main()
{
typedef boost::filesystem::path t_path;
typedef boost::filesystem::directory_iterator t_iter_path;
t_path full_path[] = {t_path(ICDAR_20P_PPM_IMG_PATH)};
for (int i = 0; i < 1; ++i)
{
std::cout << "entering " << full_path[i] << std::endl;
if (boost::filesystem::exists(full_path[i]) &&
boost::filesystem::is_directory(full_path[i]))
{
boost::filesystem::system_complete(full_path[i]);
const t_iter_path end_iter;
float prop = 0.0;
for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter)
{
// concatenation de chaine
t_path directory(ANNOTATING_SATURATION_RET_PATH);
t_path leaf = dir_iter->path().leaf();
t_path output = change_extension(directory / leaf, ".sh");
t_path tmp = change_extension(directory / leaf, ".pgm");
prop = saturation_test(dir_iter->path().string(),
output.string(),
// tmp.string(),
25);
std::cout << output << " : " << prop << std::endl;
std::cerr << output << " : " << prop << std::endl;
}
}
}
return 0;
}
mp00262c_20p.ppm
mp00263c_20p.ppm
mp00319c_20p.ppm
mp00440c_20p.ppm
mp00608c_20p.ppm
mp00630c_20p.ppm
mp00631c_20p.ppm
ta00028c_20p.ppm
ta00037c_20p.ppm
ta00043c_20p.ppm
ta00046c_20p.ppm
ta00073c_20p.ppm
ta00081c_20p.ppm
ta00089c_20p.ppm
ta00090c_20p.ppm
mp00032c_20p.ppm
mp00042c_20p.ppm
mp00076c_20p.ppm
mp00082c_20p.ppm
mp00142c_20p.ppm
mp00215c_20p.ppm
mp00228c_20p.ppm
mp00234c_20p.ppm
mp00248c_20p.ppm
mp00252c_20p.ppm
mp00253c_20p.ppm
mp00255c_20p.ppm
mp00259c_20p.ppm
mp00271c_20p.ppm
mp00290c_20p.ppm
mp00293c_20p.ppm
mp00304c_20p.ppm
mp00307c_20p.ppm
mp00311c_20p.ppm
mp00376c_20p.ppm
mp00411c_20p.ppm
mp00419c_20p.ppm
mp00447c_20p.ppm
mp00498c_20p.ppm
mp00510c_20p.ppm
mp00550c_20p.ppm
mp00573c_20p.ppm
mp00589c_20p.ppm
mp00592c_20p.ppm
mp00597c_20p.ppm
mp00599c_20p.ppm
mp00600c_20p.ppm
ta00031c_20p.ppm
ta00034c_20p.ppm
ta00063c_20p.ppm
ta00065c_20p.ppm
ta00072c_20p.ppm
ta00081c_20p.ppm
ta00083c_20p.ppm
mp00329c_20p.ppm
ta00036c_20p.ppm
ta00039c_20p.ppm
ta00040c_20p.ppm
ta00049c_20p.ppm
ta00055c_20p.ppm
ta00057c_20p.ppm
ta00068c_20p.ppm
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