r2703: Fix bug in the mean color computation

From: Maxime van Noppen <yabo@lrde.epita.fr> To: olena-patches@lrde.epita.fr Subject: r2703: Fix bug in the mean color computation URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox ChangeLog: 2008-10-27 Maxime van Noppen <yabo@lrde.epita.fr> Fix bug in the mean color computation. * Makefile: Fix. * iccvg04.cc: Use double values instead of unsigned. --- Makefile | 57 +++++++++++++++++++++++++++++++++++++-------------------- iccvg04.cc | 11 ++++++++++- 2 files changed, 47 insertions(+), 21 deletions(-) Index: branches/cleanup-2008/milena/sandbox/classif/iccvg04.cc =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/iccvg04.cc (revision 2702) +++ branches/cleanup-2008/milena/sandbox/classif/iccvg04.cc (revision 2703) @@ -106,7 +106,7 @@ unsigned count[nbasins + 1]; memset(count, 0, (nbasins + 1) * sizeof(unsigned)); - algebra::vec<3, unsigned> sum[nbasins + 1]; + algebra::vec<3, double> sum[nbasins + 1]; for (int i = 0; i < nbasins + 1; ++i) sum[i] = literal::zero; @@ -123,9 +123,16 @@ count[w] += histo(p3); sum[w] += histo(p3) * convert::to< algebra::vec<3, value::int_u8> >(p3); } + + std::cerr << "p3 : " << p3 << " == " << convert::to<algebra::vec<3, value::int_u8> >(p3) << std::endl; } + for (int i = 1; i < nbasins + 1; ++i) + { + std::cout << "sum[" << i << "] = " << sum[i] * f << " / " << count[i] << " == "; sum[i] = (sum[i] * f) / count[i]; + std::cout << sum[i] << std::endl; + } // Make an output image where colors are replaced by their representatives. mln_piter(I) pi(ima.domain()); @@ -138,6 +145,8 @@ //if w == 0, out(pi) = 0 ie is part of a border of the watershed out(pi) = convert::to<value::rgb8>(sum[w]); + + std::cerr << "out(" << pi << ") = sum[" << w << "]; //" << sum[w] << " : rgb8(" << convert::to<value::rgb8>(sum[w]) << ")" << std::endl; } io::ppm::save(out, "out.ppm"); Index: branches/cleanup-2008/milena/sandbox/classif/Makefile =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/Makefile (revision 2702) +++ branches/cleanup-2008/milena/sandbox/classif/Makefile (revision 2703) @@ -1,45 +1,62 @@ -INCLUDES=-I../.. +DISP=xv -SRC=iccvg04.cc -TARGET=iccvg - -TARGET_DBG=iccvg_dbg +# ICCVG +ICCVG_INCLUDES=-I../.. +ICCVG_SRC=iccvg04.cc +ICCVG=iccvg +ICCVG_DBG=iccvg_dbg IMG?=../../img/lena.ppm DIV?=8 LAMBDA?=10 + +# V2 +V2_INCLUDES=-I../.. -I../garrigues/fllt +V2_SRC=v2.cc +V2=v2 +V2_DBG=v2_dbg + + LOG=> stdout.log 2> stderr.log -all: $(TARGET) -$(TARGET): $(SRC) - g++ $(INCLUDES) -O1 -DNDEBUG $(SRC) -o $(TARGET) +$(ICCVG): $(ICCVG_SRC) + g++ $(ICCVG_INCLUDES) -O1 -DNDEBUG $(ICCVG_SRC) -o $(ICCVG) + + +$(ICCVG_DBG): $(ICCVG_SRC) + g++ $(ICCVG_INCLUDES) -O0 -g3 -ggdb3 $(ICCVG_SRC) -o $(ICCVG_DBG) + +$(V2): $(V2_SRC) + g++ $(V2_INCLUDES) -O1 -DNDEBUG $(V2_SRC) -o $(V2) + -debug: $(TARGET_DBG) +$(V2_DBG): $(V2_SRC) + g++ $(V2_INCLUDES) -O0 -g3 -ggdb3 $(V2_SRC) -o $(V2_DBG) -iccvg_dbg: $(SRC) - g++ $(INCLUDES) -O0 -g3 -ggdb3 $(SRC) -o $(TARGET_DBG) .PHONY:clean check check-debug valgrind clean: - rm -f $(TARGET) - rm -f $(TARGET_DBG) + rm -f $(ICCVG) + rm -f $(ICCVG_DBG) + rm -f $(V2) + rm -f $(V2_DBG) -check-debug: $(TARGET_DBG) +check-debug: $(ICCVG_DBG) ./iccvg_dbg $(IMG) $(DIV) $(LAMBDA) $(LOG) cat stdout.log - display out.ppm & + $(DISP) out.ppm & -check: $(TARGET) +check: $(ICCVG) ./iccvg $(IMG) $(DIV) $(LAMBDA) $(LOG) cat stdout.log - display out.ppm & + $(DISP) out.ppm & -valgrind: +valgrind: $(ICCVG_DBG) valgrind --log-file=valgrind.log ./iccvg_dbg ../../img/lena.ppm $(DIV) $(LAMBDA) $(LOG) -gdb: $(TARGET_DBG) +gdb: $(ICCVG_DBG) echo "run ../../img/lena.ppm $(DIV) $(LAMBDA)" > gdb.cmd - gdb $(TARGET_DBG) -x gdb.cmd + gdb $(ICCVG_DBG) -x gdb.cmd
participants (1)
-
Maxime van Noppen