URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-03 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Create plot files depending on labels.
* fabien/igr/Makefile: Add new targets.
* fabien/igr/check.sh: Update.
* fabien/igr/clo_vol.cc: Minor update, helped for debug.
* fabien/igr/fun_labels.cc: Create plot files with labels value.
* fabien/igr/fun_labels.sh: New script file for testing fun_labels.
* fabien/igr/time_smooth/linear.cc: Update tumeur point.
---
TODO | 4 -
igr/Makefile | 13 +--
igr/check.sh | 12 +--
igr/clo_vol.cc | 14 +++
igr/fun_labels.cc | 163 ++++++++++++++++++++++++++++++++++++++++++++++
igr/fun_labels.sh | 20 +++++
igr/time_smooth/linear.cc | 8 +-
7 files changed, 211 insertions(+), 23 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/clo_vol.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/clo_vol.cc (revision 3602)
+++ trunk/milena/sandbox/fabien/igr/clo_vol.cc (revision 3603)
@@ -16,6 +16,13 @@
+
+
+#include <mln/canvas/morpho/attribute_filter.hh>
+#include <mln/morpho/attribute/volume.hh>
+
+
+
///////////////////
// //
// Main Function //
@@ -53,9 +60,12 @@
}
else
{
- image3d<int_u12> input;
+ typedef image3d<int_u12> I;
+
+ I input;
io::dump::load(input, argv[1]);
- image3d<int_u12> clo = morpho::closing::volume(input, c6(), closure_lambda);
+
+ I clo = morpho::closing::volume(input, c6(), closure_lambda);
io::dump::save(clo, "clo_vol.dump");
}
Index: trunk/milena/sandbox/fabien/igr/fun_labels.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/fun_labels.sh (revision 0)
+++ trunk/milena/sandbox/fabien/igr/fun_labels.sh (revision 3603)
@@ -0,0 +1,20 @@
+#!/bin/zsh
+
+process_file ()
+{
+ echo "Processing $3..."
+ input=$1
+ dim=$2
+
+ ./grad $input $dim
+ for lambda_closing in 5000; do
+ echo " for lambda_closing = ${lambda_closing}";
+ ./clo_vol grad.dump $dim ${lambda_closing}
+ nbasins=`./wst clo_vol.dump $dim`
+ echo " nbasins = $nbasins"
+#../bin/dumpl32_to_colorize wst.dump $dim $nbasins colorize_${3}_${lambda_closing}.ppm
+ ./fun_labels wst.dump $dim $input $nbasins
+ done
+}
+
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" 3
"52"
Property changes on: trunk/milena/sandbox/fabien/igr/fun_labels.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/fabien/igr/check.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/check.sh (revision 3602)
+++ trunk/milena/sandbox/fabien/igr/check.sh (revision 3603)
@@ -15,7 +15,7 @@
echo " nbasins = $nbasins"
../bin/dumpl32_to_colorize wst.dump $dim $nbasins
results/colorize_${3}_${lambda_closing}.ppm
median=`./med wst.dump $dim $input $nbasins`
-#echo " median = $median"
+ echo " median = $median"
threshold=$(($median / 2))
../bin/dumpi12_to_pgm med.dump $dim results/median_${3}_${lambda_closing}.pgm
./thres med.dump $dim $threshold
@@ -38,9 +38,9 @@
# rm *.dump
}
-process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0049.dcm" 2
"49"
+#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0049.dcm" 2
"49"
process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" 3
"52"
-process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0055.dcm" 2
"55"
-process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0058.dcm" 2
"58"
-process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0061.dcm" 3
"61"
-process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0064.dcm" 3
"64"
+#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0055.dcm" 2
"55"
+#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0058.dcm" 2
"58"
+#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0061.dcm" 3
"61"
+#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0064.dcm" 3
"64"
Index: trunk/milena/sandbox/fabien/igr/time_smooth/linear.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/time_smooth/linear.cc (revision 3602)
+++ trunk/milena/sandbox/fabien/igr/time_smooth/linear.cc (revision 3603)
@@ -66,11 +66,11 @@
// Outputs //
// //
/////////////
- io::plot::save(ima_arr(point2d(160, 120)), "ref_tumeur.plot");
- io::plot::save(ima_linear(point2d(160, 120)), "linear_tumeur.plot");
- io::plot::save(ima_arr(point2d(34, 94)), "ref_air.plot");
+ //io::plot::save(ima_arr(point2d(160, 120)), "ref_tumeur.plot");
+ io::plot::save(ima_linear(point2d(156, 114)), "linear_tumeur.plot");
+ //io::plot::save(ima_arr(point2d(34, 94)), "ref_air.plot");
io::plot::save(ima_linear(point2d(34, 94)), "linear_air.plot");
- io::plot::save(ima_arr(point2d(122, 115)), "ref_poumon.plot");
+ //io::plot::save(ima_arr(point2d(122, 115)), "ref_poumon.plot");
io::plot::save(ima_linear(point2d(122, 115)), "linear_poumon.plot");
return 0;
Index: trunk/milena/sandbox/fabien/igr/fun_labels.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/fun_labels.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/fun_labels.cc (revision 3603)
@@ -0,0 +1,163 @@
+#include <iostream>
+#include <sstream>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/image_if.hh>
+#include <mln/core/image/slice_image.hh>
+#include <mln/core/routine/duplicate.hh>
+
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/core/alias/window3d.hh>
+
+#include <mln/geom/nslis.hh>
+
+#include <mln/io/dump/all.hh>
+#include <mln/io/dicom/load.hh>
+#include <mln/io/plot/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/accu/mean.hh>
+#include <mln/accu/median_h.hh>
+#include <mln/level/compute.hh>
+#include <mln/pw/all.hh>
+#include <mln/util/array.hh>
+#include <mln/util/set.hh>
+
+
+
+using namespace mln;
+using value::int_u8;
+using value::int_u12;
+using value::label_16;
+using value::label_32;
+
+
+template <typename I, typename L, typename V>
+inline
+void plot_label(I ima, L ima_labels, V lbl)
+{
+ I ima_spe = duplicate(ima | pw::value(ima_labels) == pw::cst(lbl));
+ util::array<float> arr;
+ for (int i = 0; i < ima_spe.domain().pmin().sli(); ++i)
+ arr.append(0.0);
+ for (int sli = ima_spe.domain().pmin().sli(); sli <= ima_spe.domain().pmax().sli();
++sli)
+ {
+ image2d<int_u12> tmp_slice = duplicate(slice(ima_spe, sli));
+ accu::mean<int_u12> accu_mean;
+ float mean = level::compute(accu_mean, tmp_slice);
+ arr.append(mean);
+ }
+ for (int i = ima_spe.domain().pmax().sli() + 1; i <= ima.domain().pmax().sli();
++i)
+ arr.append(0.0);
+ std::ostringstream slabel;
+ slabel << "label_" << lbl << ".plot";
+ io::plot::save(arr, slabel.str());
+}
+
+
+template <typename I, typename L>
+inline
+void plot_point(I ima, L ima_labels, point2d point, const char* desc)
+{
+ util::array<float> arr;
+ label_32 prev_lbl;
+ int start = 0;
+ int count = 1;
+ for (unsigned sli = 0; sli < geom::nslis(ima); ++sli)
+ {
+ image2d<int_u12> ima_slice = duplicate(slice(ima, sli));
+ image2d<label_32> lbl_slice = duplicate(slice(ima_labels, sli));
+ if (sli == 0)
+ prev_lbl = lbl_slice(point);
+ if (lbl_slice(point) != prev_lbl)
+ {
+ std::ostringstream slabel;
+ slabel << desc << "_" << count <<
"_label_" << prev_lbl << ".plot";
+ count++;
+ io::plot::save(arr, slabel.str(), start);
+ arr.clear();
+ start = sli + 1;
+ }
+ // Taking the mean value of the region.
+ accu::mean<int_u12> accu_mean;
+ float mean = level::compute(accu_mean, ima_slice | pw::value(lbl_slice) ==
pw::cst(lbl_slice(point)));
+ arr.append(mean);
+ prev_lbl = lbl_slice(point);
+ }
+ if (!arr.is_empty())
+ {
+ std::ostringstream slabel;
+ slabel << desc << "_" << count <<
"_label_" << prev_lbl << ".plot";
+ io::plot::save(arr, slabel.str(), start);
+ }
+}
+
+
+///////////////////
+// //
+// Main Function //
+// //
+///////////////////
+
+
+int main(int argc, char *argv[])
+{
+ typedef label_32 L;
+
+ if (argc != 5)
+ {
+ std::cout << "Usage: " << argv[0] << "
<ima.dump> <dimensions> <ima.dcm> <nbasins>"
+ << std::endl;
+ return 1;
+ }
+
+ unsigned dim = atoi(argv[2]);
+ if (dim != 2 && dim != 3)
+ {
+ std::cout << "<dimensions> invalid" << std::endl;
+ return 1;
+ }
+
+ L nlabels = atoi(argv[4]);
+
+ if (dim == 2)
+ {
+ // FIXME
+ }
+ else
+ {
+ point2d p_tumeur(156, 114);
+ point2d p_air(34, 94);
+ point2d p_poumon(122, 115);
+ image3d<L> ima_labels;
+ io::dump::load(ima_labels, argv[1]);
+ image3d<int_u12> ima;
+ io::dicom::load(ima, argv[3]);
+
+ plot_point(ima, ima_labels, p_tumeur, "tumeur");
+ plot_point(ima, ima_labels, p_air, "air");
+ plot_point(ima, ima_labels, p_poumon, "poumon");
+ /*util::set<L> lbl_set;
+ for (int sli = 0; sli < geom::nslis(ima_labels); ++sli)
+ {
+ image2d<L> tmp_slice = duplicate(slice(ima_labels, sli));
+ lbl_set.insert(tmp_slice(p_tumeur));
+ lbl_set.insert(tmp_slice(p_air));
+ lbl_set.insert(tmp_slice(p_poumon));
+ }
+
+ util::set_fwd_iter<L> siter(lbl_set);
+ for_all(siter)
+ {
+ plot_label(ima, ima_labels, siter.element());
+ }*/
+ }
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile (revision 3602)
+++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3603)
@@ -1,12 +1,4 @@
-CXX = llvm-g++
-CXXFLAGS = -DNDEBUG -O4
-
-DICOM_INC = -I/usr/local/include/gdcm-2.0
-DICOM_LIBS = -lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF -lgdcmexpat
-lgdcmjpeg12 -lgdcmjpeg16 -lgdcmjpeg8 -lgdcmopenjpeg -lgdcmuuid -lgdcmzlib \
- -framework CoreFoundation
-DICOM = ${DICOM_INC} ${DICOM_LIBS}
-
-MAGICK = `Magick++-config --cppflags --ldflags --libs`
+include Makefile.rules
seg2d: seg_vol_irm.hh seg2d.cc
${CXX} -I../../../ ${DICOM} ${CXXFLAGS} seg2d.cc -o seg2d
@@ -50,6 +42,9 @@
first_slice_dicom: first_slice_dicom.cc
${CXX} -I../../../ ${DICOM} ${MAGICK} ${CXXFLAGS} -lm $^ -o first_slice_dicom
+fun_labels: fun_labels.cc
+ ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} $^ -o fun_labels
+
clean:
rm -rf *.dump *.p?m *.plot *.log *.csv *.dSYM
rm seg2d seg3d wsd2d wsd3d nbasins_finder grad clo_vol wst graph med thres matlab
time_max first_slice_dicom
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 3602)
+++ trunk/milena/sandbox/fabien/TODO (revision 3603)
@@ -38,9 +38,9 @@
[ ] Profile for performance
[X] ImageMagick support
[ ] Integrate external libraries (GDCM, IM)
-[ ] Send result images to lrde account
+[X] Send result images to lrde account
[X] Translate Matlab code
[X] Subsample binary images
[X] Fast projected histogram
[ ] Triple histogram
-[ ] Create plot for each kind of point with each method
+[X] Create plot for each kind of point with each method