r3512: Create watershed images in 3D..

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox ChangeLog: 2009-03-11 Fabien Freling <fabien.freling@lrde.epita.fr> Create watershed images in 3D.. * fabien/bin/dump2pgm8b.cc: Fix. * fabien/igr/Makefile: Update. * fabien/igr/nbasins_check.sh: New test file. * fabien/igr/nbasins_finder.cc: New file for finding optimal parameters. * fabien/igr/watershed3d.cc: Update. --- TODO | 4 +- bin/dump2pgm8b.cc | 5 --- igr/Makefile | 5 ++- igr/nbasins_check.sh | 17 ++++++++++ igr/nbasins_finder.cc | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ igr/watershed3d.cc | 1 6 files changed, 105 insertions(+), 7 deletions(-) Index: trunk/milena/sandbox/fabien/igr/watershed3d.cc =================================================================== --- trunk/milena/sandbox/fabien/igr/watershed3d.cc (revision 3511) +++ trunk/milena/sandbox/fabien/igr/watershed3d.cc (revision 3512) @@ -277,6 +277,7 @@ // Watershed label_32 nbasins; image3d<label_32> wshed = morpho::meyer_wst(clo, c6(), nbasins); + std::cout << "nbasins = " << nbasins << std::endl; // Debug io::dump::save(level::stretch(int_u8(), clo), "wsd_02.dump"); Index: trunk/milena/sandbox/fabien/igr/nbasins_check.sh =================================================================== --- trunk/milena/sandbox/fabien/igr/nbasins_check.sh (revision 0) +++ trunk/milena/sandbox/fabien/igr/nbasins_check.sh (revision 3512) @@ -0,0 +1,17 @@ +#!/bin/zsh + +process_file () +{ + echo "Processing $2..." + + for lambda_closure in 500 1000 5000 10000 50000; do + echo " for lambda_closure = ${lambda_closure}"; + ./nbasins_finder $1 $lambda_closure + ../bin/dump2ppm result_nbasins.dump results/nbasins_${2}_${lambda_closure}.ppm + done +} + +#make nbasins +#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" "52" +process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0061.dcm" "61" +process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0064.dcm" "64" Property changes on: trunk/milena/sandbox/fabien/igr/nbasins_check.sh ___________________________________________________________________ Name: svn:executable + * Index: trunk/milena/sandbox/fabien/igr/nbasins_finder.cc =================================================================== --- trunk/milena/sandbox/fabien/igr/nbasins_finder.cc (revision 0) +++ trunk/milena/sandbox/fabien/igr/nbasins_finder.cc (revision 3512) @@ -0,0 +1,80 @@ +#include <iostream> +#include <mln/core/image/image3d.hh> + +#include <mln/core/alias/neighb3d.hh> +#include <mln/core/alias/window3d.hh> +#include <mln/core/image/image_if.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/dicom/load.hh> +#include <mln/io/pgm/save.hh> +#include <mln/io/dump/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/value/int_u12.hh> +#include <mln/value/label_16.hh> +#include <mln/value/label_32.hh> +#include <mln/value/rgb8.hh> + +#include <mln/labeling/regional_minima.hh> + +#include <mln/level/transform.hh> +#include <mln/level/stretch.hh> + +#include <mln/morpho/elementary/gradient.hh> +#include <mln/morpho/closing/volume.hh> +#include <mln/morpho/watershed/flooding.hh> + +#include <mln/fun/l2l/wrap.hh> + +#include <mln/debug/colorize.hh> + + + +/////////////////// +// // +// Main Function // +// // +/////////////////// + + +int main(int argc, char *argv[]) +{ + using namespace mln; + using value::int_u8; + using value::int_u12; + using value::label_16; + using value::label_32; + using value::rgb8; + + if (argc != 3) + { + std::cout << "Usage: " << argv[0] << " <ima.dcm> <closure_lambda>" + << std::endl; + return 1; + } + + unsigned closure_lambda = atoi(argv[2]); + + image3d<int_u12> dcm; + io::dicom::load(dcm, argv[1]); + + // Gradient + image3d<int_u12> grad = morpho::elementary::gradient(dcm, c6()); + + // Closure + image3d<int_u12> clo = morpho::closing::volume(grad, c6(), closure_lambda); + + // Watershed + label_32 nbasins; + image3d<label_32> wshed = morpho::watershed::flooding(clo, c6(), nbasins); + //image3d<label_32> wshed = morpho::watershed::flooding(clo, c6(), nbasins); + + // Visualization + std::cout << " nbasins = " << nbasins << std::endl; + //io::dump::save(level::transform(wshed, fun::l2l::wrap<int_u8>()), "result_nbasins.dump"); + //io::dump::save(level::stretch(int_u8(), wshed), "result_nbasins.dump"); + io::dump::save(debug::colorize(rgb8(), wshed, nbasins), "result_nbasins.dump"); + + return 0; +} Index: trunk/milena/sandbox/fabien/igr/Makefile =================================================================== --- trunk/milena/sandbox/fabien/igr/Makefile (revision 3511) +++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3512) @@ -23,7 +23,10 @@ g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} $^ -o wsd3d wsd3dg: watershed.hh watershed3d.cc - g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} -DNDEBUG -g $^ -o wsd3dg + g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} -g $^ -o wsd3dg + +nbasins: nbasins_finder.cc + g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} $^ -o nbasins_finder clean: rm -rf *.dump *.p?m *.plot *.log *.csv Index: trunk/milena/sandbox/fabien/TODO =================================================================== --- trunk/milena/sandbox/fabien/TODO (revision 3511) +++ trunk/milena/sandbox/fabien/TODO (revision 3512) @@ -25,4 +25,6 @@ [X] US: projection of internal gradient [X] Create 3D US morpho with 2D stack [ ] Create macro for_all_slice -[ ] Batch process watershed with 2D, 3D and any combination of parameters +[X] Batch process watershed with 2D, 3D and any combination of parameters +[ ] Cut into small tools +[ ] Test 3D workflow on 2D images Index: trunk/milena/sandbox/fabien/bin/dump2pgm8b.cc =================================================================== --- trunk/milena/sandbox/fabien/bin/dump2pgm8b.cc (revision 3511) +++ trunk/milena/sandbox/fabien/bin/dump2pgm8b.cc (revision 3512) @@ -3,12 +3,9 @@ #include <mln/debug/slices_2d.hh> #include <mln/value/int_u8.hh> -#include <mln/value/int_u12.hh> #include <mln/io/dump/load.hh> #include <mln/io/pgm/save.hh> -#include <mln/literal/colors.hh> - int usage(char* argv[]) { @@ -21,7 +18,6 @@ int main(int argc, char* argv[]) { using namespace mln; - using value::rgb8; using value::int_u8; if (argc != 3) @@ -30,7 +26,6 @@ image3d<int_u8> vol; io::dump::load(vol, argv[1]); - rgb8 bg = literal::black; image2d<int_u8> ima = debug::slices_2d(vol, 1.f, 0); io::pgm::save(ima, argv[2]);
participants (1)
-
Fabien Freling