2923: Start working on image reconstruction.

https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox Index: ChangeLog from Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr> Start working on image reconstruction. * jardonnet/igr/src/igr.cc(rgb->gs, |egrad|, vclosing and wst): New. * jardonnet/igr/Makefile(tar, bin, deps): New. * jardonnet/igr/check: New check directory. * jardonnet/igr/check/s7.ppm: New test image. * jardonnet/igr/check/tiny.ppm: New tiny test image. abraham/mln/fun/meta/inty.hh | 3 - jardonnet/igr/Makefile | 55 ++++++++++++++++++++ jardonnet/igr/src/igr.cc | 116 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+), 1 deletion(-) Index: jardonnet/igr/src/igr.cc --- jardonnet/igr/src/igr.cc (revision 0) +++ jardonnet/igr/src/igr.cc (revision 0) @@ -0,0 +1,116 @@ +#include <iostream> + +#include <mln/core/image/image2d.hh> +#include <mln/value/rgb8.hh> +#include <mln/literal/colors.hh> + +#include <mln/arith/revert.hh> + +#include <mln/morpho/meyer_wst.hh> +#include <mln/morpho/closing_volume.hh> +#include <mln/morpho/closing_area.hh> +#include <mln/morpho/elementary/gradient.hh> +#include <mln/core/alias/neighb2d.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/ppm/save.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/level/paste.hh> +#include <mln/level/apply.hh> + +#include <mln/fun/v2v/rgb_to_hsi.hh> +#include <mln/fun/v2v/abs.hh> + +#include <mln/value/hsi.hh> + +#include <mln/core/image/thru.hh> + +//FIXME: Alexandre' sandbox +#include <mln/fun/meta/inty.hh> + +using namespace mln; +using namespace value; + +bool usage(int argc, char ** argv) +{ + if (argc != 3) + { + std::cout << "usage: " + << argv[0] << " image1 lambda" << std::endl; + return false; + } + return true; +} + +int main(int argc, char ** argv) +{ + if (not usage(argc, argv)) + return 1; + + image2d<rgb8> ima = + io::ppm::load<value::rgb8>(argv[1]); + unsigned lambda = atoi(argv[2]); + + + // RGB -> GS + //////////////////// + + image2d<hsi_f> hsi = level::transform(ima, fun::v2v::f_rgb_to_hsi_f); + + //FIXME: fix and use alexandre stuff + /* thru<to_hsi, image2d<hsi_f> > tmp(hsi_f); + image2d<int_u8> g_ima; + level::paste(tmp, g_ima);*/ + + image2d<int_u8> g_ima(ima.domain()); + mln_piter_(image2d<rgb8>) p(g_ima.domain()); + for_all(p) + { + g_ima(p) = hsi(p).inty() * 255; + } + + io::pgm::save(g_ima, "g_ima.ppm"); + + + // |grad(ima)| + /////////////////// + + image2d<int_u8> mg_ima(g_ima.domain()); + mg_ima = morpho::elementary::gradient(g_ima, c4()); + + //level::apply(mg_ima, fun::v2v::abs<int_u8>()); + + io::pgm::save(mg_ima, "mg_ima.ppm"); + + + // Volume Closing + /////////////////// + + image2d<int_u8> o_ima(mg_ima.domain()); + morpho::closing_volume(mg_ima, c4(), lambda, o_ima); + + io::pgm::save(o_ima, "o_ima.ppm"); + + + // Watershed + /////////////////// + + int_u16 nbasins = 0; + image2d<int_u16> ws = + morpho::meyer_wst(o_ima, c4(), nbasins); + + std::cout << "nbasins: " << nbasins << std::endl; + + image2d<rgb8> out(ima.domain()); + mln_piter_(image2d<int_u8>) pp(ws.domain()); + for_all(pp) + { + if (ws(pp) == 0u) + out(pp) = literal::red; + else + out(pp) = rgb8(o_ima(pp),o_ima(pp),o_ima(pp)); + } + + io::ppm::save(out, "out.ppm"); +} Index: jardonnet/igr/Makefile --- jardonnet/igr/Makefile (revision 0) +++ jardonnet/igr/Makefile (revision 0) @@ -0,0 +1,55 @@ +### Makefile --- + +## Author: ugo.jardonnet@lrde.epita.fr +## Version: $Id: Makefile,v 0.0 2008/11/19 11:40:34 jardonnet Exp $ +## Keywords: +## X-URL: + +PROJ=igr-reco +SRC=src/igr.cc +BIN=igr +LFLAGS=-I../../abraham/ -I../../../ +CFLAGS=-W -Wall -Wextra -O1 -DNDEBUG +FILES=src configure check README + +$(BIN): Makefile + g++ $(CFLAGS) $(LFLAGS) $(SRC) -o $(BIN) + +check: + cd check && ./check + +clean: + rm -f $(BIN) + rm -f .deps .depsr + rm -f *.ppm + +dist: clean todo AUTHORS svn_check + rm -rf $(PROJ) + mkdir $(PROJ) + cp -r Makefile AUTHORS TODO $(FILES) $(PROJ) + -find $(PROJ) -name ".svn" -exec rm -rf {} \; + -find $(PROJ) -name "*~" -exec rm -rf {} \; + -find $(PROJ) -name "#*" -exec rm -rf {} \; + tar cjvf $(PROJ).tar.bz2 $(PROJ) + rm -rf $(PROJ) + chmod 644 $(PROJ).tar.bz2 + +svn_check: + @svn st | grep \? ; [ $$? = "1" ] \ + || (echo "----------------------------------------------"\ + && echo "SOME FILES ARE MISSING FROM THE SVN REPOSITORY"\ + && echo "----------------------------------------------"); + +todo: + grep "FIXME" -r . --exclude="Makefile" > TODO + +.deps: + g++ $(LFLAGS) -MM $(SRC) > $@ + @sed -ir s/igr.cc// .deps + @sed -ir s/igr.o/igr/ .deps + +.PHONY: doc check .deps + +include .deps + +### Makefile ends here \ No newline at end of file Index: jardonnet/igr/check/s7.ppm Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: jardonnet/igr/check/s7.ppm ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: jardonnet/igr/check/tiny.ppm Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: jardonnet/igr/check/tiny.ppm ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: abraham/mln/fun/meta/inty.hh --- abraham/mln/fun/meta/inty.hh (revision 2921) +++ abraham/mln/fun/meta/inty.hh (working copy) @@ -41,7 +41,8 @@ }; template <class H, class S, class I> - struct function< meta::inty< value::hsi_<H, S, I> > > : public Function_v2w_w2v<function< meta::inty < value::hsi_<H, S, I> > > > + struct function< meta::inty< value::hsi_<H, S, I> > > : + public Function_v2w_w2v<function< meta::inty < value::hsi_<H, S, I> > > > { typedef value::hsi_<H, S, I> value; Index: markov/markov.hh
participants (1)
-
Ugo Jardonnet