* lazzara/igr/gui/segmentation2dt/src/mln_data.cc,
* lazzara/igr/gui/segmentation2dt/src/mln_data.hh: Add more
temporary images.
* lazzara/igr/gui/segmentation2dt/src/save_widget.cc: Add
checkboxes to select which image to save.
* lazzara/igr/gui/segmentation2dt/src/seg_widget.cc,
* lazzara/igr/gui/segmentation2dt/src/seg_widget.hh,
* lazzara/igr/gui/segmentation2dt/src/tools/seg.cc,
* lazzara/igr/gui/segmentation2dt/src/tools/seg.hh,
* lazzara/igr/gui/segmentation2dt/src/tools/mean_regions.cc:
Compute non-filtered and linearly filtered image.
* lazzara/igr/gui/segmentation2dt/src/task_widget.cc: Avoid a warning.
* lazzara/igr/gui/segmentation2dt/src/tools/save.cc
* lazzara/igr/gui/segmentation2dt/src/tools/save.hh: Allow to save
more images.
* lazzara/igr/gui/segmentation2dt/ui/plot_widget.ui,
* lazzara/igr/gui/segmentation2dt/ui/save_widget.ui: Update widgets.
* lazzara/igr/gui/shared/include/function_means.hh,
* lazzara/igr/gui/shared/include/mean_function_per_region.hh,
* lazzara/igr/gui/shared/include/normalization.hh: Add missing
inlines.
* lazzara/igr/gui/shared/include/mean_regions.hh,
* lazzara/igr/gui/shared/include/time_smooth_morpho.hh: Add
missing includes.
---
milena/sandbox/ChangeLog | 37 +++++++
.../igr/gui/segmentation2dt/src/mln_data.cc | 112 +++++++++++++++-----
.../igr/gui/segmentation2dt/src/mln_data.hh | 50 ++++++---
.../igr/gui/segmentation2dt/src/save_widget.cc | 21 ++++
.../igr/gui/segmentation2dt/src/seg_widget.cc | 30 ++++--
.../igr/gui/segmentation2dt/src/seg_widget.hh | 3 +-
.../igr/gui/segmentation2dt/src/task_widget.cc | 2 +-
.../gui/segmentation2dt/src/tools/mean_regions.cc | 72 +++++++++++--
.../igr/gui/segmentation2dt/src/tools/save.cc | 90 +++++++++++++---
.../igr/gui/segmentation2dt/src/tools/save.hh | 12 ++-
.../igr/gui/segmentation2dt/src/tools/seg.cc | 60 +++++++++--
.../igr/gui/segmentation2dt/src/tools/seg.hh | 10 ++-
.../igr/gui/segmentation2dt/ui/plot_widget.ui | 20 ++++
.../igr/gui/segmentation2dt/ui/save_widget.ui | 80 +++++++++++++--
.../igr/gui/shared/include/function_means.hh | 1 -
.../gui/shared/include/mean_function_per_region.hh | 2 +-
.../lazzara/igr/gui/shared/include/mean_regions.hh | 2 +
.../igr/gui/shared/include/normalization.hh | 1 -
.../igr/gui/shared/include/time_smooth_morpho.hh | 2 +
19 files changed, 508 insertions(+), 99 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 677070c..4f62abc 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,5 +1,42 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Allow to save results filtered differently in the 3D segmentation
+ tool.
+
+ * lazzara/igr/gui/segmentation2dt/src/mln_data.cc,
+ * lazzara/igr/gui/segmentation2dt/src/mln_data.hh: Add more
+ temporary images.
+
+ * lazzara/igr/gui/segmentation2dt/src/save_widget.cc: Add
+ checkboxes to select which image to save.
+
+ * lazzara/igr/gui/segmentation2dt/src/seg_widget.cc,
+ * lazzara/igr/gui/segmentation2dt/src/seg_widget.hh,
+ * lazzara/igr/gui/segmentation2dt/src/tools/seg.cc,
+ * lazzara/igr/gui/segmentation2dt/src/tools/seg.hh,
+ * lazzara/igr/gui/segmentation2dt/src/tools/mean_regions.cc:
+ Compute non-filtered and linearly filtered image.
+
+ * lazzara/igr/gui/segmentation2dt/src/task_widget.cc: Avoid a warning.
+
+ * lazzara/igr/gui/segmentation2dt/src/tools/save.cc
+ * lazzara/igr/gui/segmentation2dt/src/tools/save.hh: Allow to save
+ more images.
+
+ * lazzara/igr/gui/segmentation2dt/ui/plot_widget.ui,
+ * lazzara/igr/gui/segmentation2dt/ui/save_widget.ui: Update widgets.
+
+ * lazzara/igr/gui/shared/include/function_means.hh,
+ * lazzara/igr/gui/shared/include/mean_function_per_region.hh,
+ * lazzara/igr/gui/shared/include/normalization.hh: Add missing
+ inlines.
+
+ * lazzara/igr/gui/shared/include/mean_regions.hh,
+ * lazzara/igr/gui/shared/include/time_smooth_morpho.hh: Add
+ missing includes.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* lazzara/igr/gui/segmentation/src/main_window.cc: Avoid a warning
in 2D segmentation tool.
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mln_data.cc
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mln_data.cc
index c294c73..f8dc7c8 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mln_data.cc
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mln_data.cc
@@ -295,19 +295,19 @@ namespace igr
}
- void mln_data::update_seg(const image3d<seg_data_t>& seg,
- const seg_data_t& nregion)
+ void mln_data::update_seg_smooth(const image3d<seg_data_t>& seg,
+ const seg_data_t& nregion)
{
- update_seg(seg, nregion, 0);
+ update_seg_smooth(seg, nregion, 0);
}
- void mln_data::update_seg(const image3d<seg_data_t>& seg,
- const seg_data_t& nregion,
- int sli)
+ void mln_data::update_seg_smooth(const image3d<seg_data_t>& seg,
+ const seg_data_t& nregion,
+ int sli)
{
- seg_ = seg;
- initialize(seg_dsp_, seg_);
+ seg_smooth_ = seg;
+ initialize(seg_dsp_, seg_smooth_);
// This random function was found here:
//
http://en.wikipedia.org/wiki/Random_number_generation
@@ -324,8 +324,8 @@ namespace igr
for_all(p)
{
value::hsl_<float,float,float> hsl__(
- h_values[seg_(p)],
-// (unsigned(seg_(p)) * 10) % 359 + 1,
+ h_values[seg_smooth_(p)],
+// (unsigned(seg_smooth_(p)) * 10) % 359 + 1,
1,
unsigned(in_(p)) * .002745f); // = 1 / 255 * 0.7);
convert::from_to(hsl__, seg_dsp_(p));
@@ -334,22 +334,51 @@ namespace igr
// Make sure there is no border!
extension::adjust(seg_dsp_, 0);
- nregion_ = nregion;
+ nregion_smooth_ = nregion;
emit image_layer_count(seg_dsp_.nslis());
compute_new_seg_image(sli);
}
- void mln_data::update_mean_regions(const image3d<input_data_t>&
mean_regions)
+
+ void mln_data::update_seg(const image3d<seg_data_t>& seg,
+ const seg_data_t& nregion)
{
- update_mean_regions(mean_regions, 0);
+ seg_ = seg;
+ nregion_ = nregion;
}
- void mln_data::update_mean_regions(const image3d<input_data_t>&
mean_regions,
- int sli)
+ void mln_data::update_seg_smooth_linear(const image3d<seg_data_t>& seg,
+ const seg_data_t& nregion)
+ {
+ seg_smooth_linear_ = seg;
+ nregion_smooth_linear_ = nregion;
+ }
+
+
+ void mln_data::update_mean_regions(const image3d<input_data_t>&
mean_regions)
{
mean_regions_ = mean_regions;
+ }
+
+
+ void mln_data::update_mean_regions_smooth_linear(const
image3d<input_data_t>& mean_regions)
+ {
+ mean_regions_smooth_linear_ = mean_regions;
+ }
+
+
+ void mln_data::update_mean_regions_smooth(const image3d<input_data_t>&
mean_regions)
+ {
+ update_mean_regions_smooth(mean_regions, 0);
+ }
+
+
+ void mln_data::update_mean_regions_smooth(const image3d<input_data_t>&
mean_regions,
+ int sli)
+ {
+ mean_regions_smooth_ = mean_regions;
mean_regions_dsp_ = data::convert(dsp_data_t(),
data::stretch(value::int_u8(),
mean_regions));
@@ -368,7 +397,7 @@ namespace igr
}
- const mln_data::in_t&
+ const in_t&
mln_data::in() const
{
return in_;
@@ -380,38 +409,50 @@ namespace igr
}
- const mln_data::ref_mean_t&
+ const ref_mean_t&
mln_data::ref_mean() const
{
return ref_mean_;
}
- const mln_data::norm_smooth_t&
+ const norm_smooth_t&
mln_data::norm() const
{
return norm_;
}
- const mln_data::norm_smooth_t&
+ const norm_smooth_t&
mln_data::norm_smooth() const
{
return norm_smooth_;
}
- const mln_data::norm_smooth_t&
+ const norm_smooth_t&
mln_data::norm_smooth_linear() const
{
return norm_smooth_linear_;
}
- const mln_data::seg_t&
+ const seg_t&
mln_data::seg() const
{
return seg_;
}
+ const seg_t&
+ mln_data::seg_smooth_linear() const
+ {
+ return seg_smooth_linear_;
+ }
+
+ const seg_t&
+ mln_data::seg_smooth() const
+ {
+ return seg_smooth_;
+ }
+
unsigned mln_data::seg_nslis() const
{
return seg_.nslis();
@@ -422,24 +463,45 @@ namespace igr
return nregion_;
}
+ const seg_data_t& mln_data::nregion_smooth_linear() const
+ {
+ return nregion_smooth_linear_;
+ }
+
+ const seg_data_t& mln_data::nregion_smooth() const
+ {
+ return nregion_smooth_;
+ }
- const mln_data::seg_dsp_t& mln_data::seg_dsp() const
+ const seg_dsp_t& mln_data::seg_dsp() const
{
return seg_dsp_;
}
- mln_data::seg_dsp_t& mln_data::seg_dsp()
+ seg_dsp_t& mln_data::seg_dsp()
{
return seg_dsp_;
}
- const mln_data::mean_regions_t&
+ const mean_regions_t&
mln_data::mean_regions() const
{
return mean_regions_;
}
- const mln_data::mean_regions_dsp_t&
+ const mean_regions_t&
+ mln_data::mean_regions_smooth_linear() const
+ {
+ return mean_regions_smooth_linear_;
+ }
+
+ const mean_regions_t&
+ mln_data::mean_regions_smooth() const
+ {
+ return mean_regions_smooth_;
+ }
+
+ const mean_regions_dsp_t&
mln_data::mean_regions_dsp() const
{
return mean_regions_dsp_;
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mln_data.hh
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mln_data.hh
index 6f1776f..bc75ecb 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mln_data.hh
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mln_data.hh
@@ -26,22 +26,23 @@ namespace igr
};
+ typedef image3d<igr::input_data_t> in_t;
+ typedef image3d<igr::dsp_data_t> in_dsp_t;
+ typedef image2d<igr::mean_t> ref_mean_t;
+ typedef image2d<igr::dsp_data_t> ref_mean_dsp_t;
+ typedef image3d<igr::smoothed_data_t> norm_smooth_t;
+ typedef image3d<igr::dsp_data_t> norm_smooth_dsp_t;
+ typedef image3d<igr::seg_data_t> seg_t;
+ typedef image3d<igr::dsp_data_t> seg_dsp_t;
+ typedef image3d<igr::input_data_t> mean_regions_t;
+ typedef image3d<igr::dsp_data_t> mean_regions_dsp_t;
+
+
class mln_data : public QObject
{
Q_OBJECT;
public:
- typedef image3d<igr::input_data_t> in_t;
- typedef image3d<igr::dsp_data_t> in_dsp_t;
- typedef image2d<igr::mean_t> ref_mean_t;
- typedef image2d<igr::dsp_data_t> ref_mean_dsp_t;
- typedef image3d<igr::smoothed_data_t> norm_smooth_t;
- typedef image3d<igr::dsp_data_t> norm_smooth_dsp_t;
- typedef image3d<igr::seg_data_t> seg_t;
- typedef image3d<igr::dsp_data_t> seg_dsp_t;
- typedef image3d<igr::input_data_t> mean_regions_t;
- typedef image3d<igr::dsp_data_t> mean_regions_dsp_t;
-
mln_data();
~mln_data();
@@ -83,12 +84,19 @@ namespace igr
void update_norm_smooth(const image3d<smoothed_data_t>& norm_smooth);
void update_norm_smooth_linear(const image3d<smoothed_data_t>&
norm_smooth_linear);
+ void update_seg_smooth(const image3d<seg_data_t>& seg,
+ const seg_data_t& nregion);
+ void update_seg_smooth(const image3d<seg_data_t>& seg,
+ const seg_data_t& nregion, int sli);
void update_seg(const image3d<seg_data_t>& seg,
- const seg_data_t& nregion);
- void update_seg(const image3d<seg_data_t>& seg,
- const seg_data_t& nregion, int sli);
+ const seg_data_t& nregion);
+ void update_seg_smooth_linear(const image3d<seg_data_t>& seg,
+ const seg_data_t& nregion);
+
void update_mean_regions(const image3d<input_data_t>& mean_regions);
- void update_mean_regions(const image3d<input_data_t>& mean_regions, int
sli);
+ void update_mean_regions_smooth_linear(const image3d<input_data_t>&
mean_regions);
+ void update_mean_regions_smooth(const image3d<input_data_t>&
mean_regions);
+ void update_mean_regions_smooth(const image3d<input_data_t>&
mean_regions, int sli);
const std::string& filename() const;
@@ -104,13 +112,19 @@ namespace igr
const norm_smooth_t& norm_smooth_linear() const;
const seg_t& seg() const;
+ const seg_t& seg_smooth_linear() const;
+ const seg_t& seg_smooth() const;
unsigned seg_nslis() const;
const seg_data_t& nregion() const;
+ const seg_data_t& nregion_smooth_linear() const;
+ const seg_data_t& nregion_smooth() const;
const seg_dsp_t& seg_dsp() const;
seg_dsp_t& seg_dsp();
const mean_regions_t& mean_regions() const;
+ const mean_regions_t& mean_regions_smooth_linear() const;
+ const mean_regions_t& mean_regions_smooth() const;
const mean_regions_dsp_t& mean_regions_dsp() const;
const log_data& logs() const;
@@ -173,10 +187,16 @@ namespace igr
norm_smooth_t norm_smooth_linear_;
seg_t seg_;
+ seg_t seg_smooth_linear_;
+ seg_t seg_smooth_;
seg_dsp_t seg_dsp_;
igr::seg_data_t nregion_;
+ igr::seg_data_t nregion_smooth_linear_;
+ igr::seg_data_t nregion_smooth_;
mean_regions_t mean_regions_;
+ mean_regions_t mean_regions_smooth_linear_;
+ mean_regions_t mean_regions_smooth_;
mean_regions_dsp_t mean_regions_dsp_;
log_data logs_;
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/save_widget.cc
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/save_widget.cc
index 8d87133..576c6ba 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/save_widget.cc
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/save_widget.cc
@@ -113,13 +113,34 @@ namespace igr
if (logCBox->isChecked())
selected.append(tools::Log);
+
if (meanFunCBox->isChecked())
+ {
selected.append(tools::MeanFunctions);
+
+ if (meanFunNonFilteredCBox->isChecked())
+ selected.append(tools::MeanFunctionsNonFiltered);
+ if (meanFunLinearFilterCBox->isChecked())
+ selected.append(tools::MeanFunctionsLinearFilter);
+ if (meanFunMorphoFilterCBox->isChecked())
+ selected.append(tools::MeanFunctionsMorphoFilter);
+ }
+
if (refImaCBox->isChecked())
selected.append(tools::RefImage);
+
if (segImaCBox->isChecked())
+ {
selected.append(tools::SegImage);
+ if (segImaNonFilteredCBox->isChecked())
+ selected.append(tools::SegImageNonFiltered);
+ if (segImaLinearFilterCBox->isChecked())
+ selected.append(tools::SegImageLinearFilter);
+ if (segImaMorphoFilterCBox->isChecked())
+ selected.append(tools::SegImageMorphoFilter);
+ }
+
return selected;
}
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/seg_widget.cc
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/seg_widget.cc
index 6891432..ff49690 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/seg_widget.cc
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/seg_widget.cc
@@ -43,7 +43,8 @@ namespace igr
{
seg_widget::seg_widget(QWidget *parent)
- : Task_Widget(parent)
+ : Task_Widget(parent),
+ compute_preview_(false), preview_computed_(false)
{
setupUi(this);
}
@@ -63,6 +64,7 @@ namespace igr
connect(viewer_, SIGNAL(slider_valueChanged(int)),
data_, SLOT(compute_new_seg_image(int)));
+ compute_preview_ = true;
emit task_ready();
}
@@ -73,6 +75,7 @@ namespace igr
set_data_and_connections();
clearBtn->setEnabled(false);
nregion_lbl->setText("");
+ preview_computed_ = false;
viewer_->set_image_layer_count(data_->in_nslis());
}
@@ -105,7 +108,7 @@ namespace igr
void seg_widget::run_task_(task_handler& handler)
{
tools::seg*
- task = new tools::seg(data_, get_lambda_value());
+ task = new tools::seg(data_, get_lambda_value(), compute_preview_, preview_computed_);
connect(&handler, SIGNAL(finished()),
this, SLOT(task_finished_slot()));
@@ -118,8 +121,8 @@ namespace igr
{
point3d p3d(viewer_->current_slice(), p.y(), p.x());
- if (clearBtn->isEnabled()) // A segmentation have been computed
- return data_->seg().domain().has(p3d);
+ if (preview_computed_) // A segmentation have been computed
+ return data_->seg_smooth().domain().has(p3d);
else
return data_->norm_smooth().domain().has(p3d);
}
@@ -128,8 +131,8 @@ namespace igr
float seg_widget::compute_mouseover_data(const QPointF& p) const
{
point3d p3d(viewer_->current_slice(), p.y(), p.x());
- if (clearBtn->isEnabled()) // A segmentation have been computed
- return float(data_->seg()(p3d));
+ if (preview_computed_) // A segmentation have been computed
+ return float(data_->seg_smooth()(p3d));
else
return float(data_->norm_smooth()(p3d));
}
@@ -163,8 +166,14 @@ namespace igr
this, SLOT(task_finished_slot()));
clearBtn->setEnabled(true);
- this->already_computed_ = true;
- nregion_lbl->setText(tr("%1 regions").arg(data_->nregion()));
+ if (!compute_preview_)
+ this->already_computed_ = true;
+ else
+ {
+ compute_preview_ = false;
+ preview_computed_ = true;
+ }
+ nregion_lbl->setText(tr("%1
regions").arg(data_->nregion_smooth()));
// Result already refreshed and displayed.
}
@@ -172,26 +181,31 @@ namespace igr
void seg_widget::on_filter_1_clicked(bool)
{
this->already_computed_ = false;
+ preview_computed_ = false;
}
void seg_widget::on_filter_2_clicked(bool)
{
this->already_computed_ = false;
+ preview_computed_ = false;
}
void seg_widget::on_filter_3_clicked(bool)
{
this->already_computed_ = false;
+ preview_computed_ = false;
}
void seg_widget::on_filter_4_clicked(bool)
{
this->already_computed_ = false;
+ preview_computed_ = false;
}
void seg_widget::on_filter_5_clicked(bool)
{
this->already_computed_ = false;
+ preview_computed_ = false;
}
} // end of namespace igr::segmentation
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/seg_widget.hh
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/seg_widget.hh
index bed5e24..26e35fe 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/seg_widget.hh
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/seg_widget.hh
@@ -68,7 +68,8 @@ namespace igr
unsigned get_lambda_value() const;
private: // Attributes
-
+ bool compute_preview_;
+ bool preview_computed_;
};
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/task_widget.cc
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/task_widget.cc
index e3ddce5..c8e6cbc 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/task_widget.cc
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/task_widget.cc
@@ -55,7 +55,7 @@ namespace igr
handler.no_op();
}
- void Task_Widget::run_task_(task_handler& handler)
+ void Task_Widget::run_task_(task_handler& /*handler*/)
{
qDebug() << "WARNING: task_widget::run_task_ should not be
called...";
}
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/mean_regions.cc
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/mean_regions.cc
index 8245a70..6ae3b47 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/mean_regions.cc
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/mean_regions.cc
@@ -32,23 +32,75 @@ namespace igr
void mean_regions::run()
{
- seg_data_t nregion = data_->nregion();
- image3d<seg_data_t>
- seg_packed = labeling::pack(data_->seg(), nregion);
+ // No filter
+ {
+ // FIXME: computed twice? here and in save.cc ?
+ seg_data_t nregion = data_->nregion();
+ image3d<seg_data_t>
+ seg_packed = labeling::pack(data_->seg(), nregion);
- emit next_step();
+ emit next_step();
+
+ data_->update_seg(seg_packed, nregion);
+
+ emit next_step();
+
+ image3d<input_data_t>
+ means = shared::mean_regions(data_->in(),
+ data_->seg(), data_->nregion());
+
+ emit next_step();
- data_->update_seg(seg_packed, nregion);
+ data_->update_mean_regions(means);
+ }
emit next_step();
- image3d<input_data_t>
- means = shared::mean_regions(data_->in(),
- data_->seg(), data_->nregion());
+ // Linear filter
+ {
+ // FIXME: computed twice? here and in save.cc ?
+ seg_data_t nregion = data_->nregion_smooth_linear();
+ image3d<seg_data_t>
+ seg_packed = labeling::pack(data_->seg_smooth_linear(), nregion);
+
+ emit next_step();
+
+ data_->update_seg_smooth_linear(seg_packed, nregion);
+
+ emit next_step();
+
+ image3d<input_data_t>
+ means = shared::mean_regions(data_->in(),
+ data_->seg_smooth_linear(), data_->nregion_smooth_linear());
+
+ emit next_step();
+
+ data_->update_mean_regions_smooth_linear(means);
+ }
emit next_step();
- data_->update_mean_regions(means);
+ // Morpho filter
+ {
+ // FIXME: computed twice? here and in save.cc ?
+ seg_data_t nregion = data_->nregion_smooth();
+ image3d<seg_data_t>
+ seg_packed = labeling::pack(data_->seg_smooth(), nregion);
+
+ emit next_step();
+
+ data_->update_seg_smooth(seg_packed, nregion);
+
+ emit next_step();
+
+ image3d<input_data_t>
+ means = shared::mean_regions(data_->in(),
+ data_->seg_smooth(), data_->nregion_smooth());
+
+ emit next_step();
+
+ data_->update_mean_regions_smooth(means);
+ }
}
@@ -60,7 +112,7 @@ namespace igr
unsigned mean_regions::step_count() const
{
- return 4;
+ return 12;
}
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/save.cc
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/save.cc
index 23e38d1..185ed86 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/save.cc
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/save.cc
@@ -104,6 +104,20 @@ namespace igr
return true;
}
+ void save::save_mean_funs(const seg_t& pseg, const seg_data_t& pnlabels,
+ const mean_regions_t& mean_regions, const QString& prefix)
+ {
+ QString output_base = basedir_ + "/" + prefix;
+ util::array<util::array<input_data_t> >
+ functions = shared::mean_function_per_region(mean_regions, pseg, pnlabels);
+
+ for (unsigned i = 1; i < functions.nelements(); ++i)
+ {
+ QString name = output_base + "_l" + QString::number(i) + ".plot";
+ mln::io::plot::save(functions[i], name.toStdString());
+ }
+ }
+
void save::run()
{
@@ -111,12 +125,19 @@ namespace igr
QString basename = f.baseName();
QString output;
-
- seg_data_t packed_nlabels;
- image3d<seg_data_t> packed_seg;
- if (selected_.contains(SegImage) || selected_.contains(MeanFunctions))
- packed_seg = labeling::pack(data_->seg(), packed_nlabels);
+// seg_data_t pnlabels, pnlabels_smooth, pnlabels_smooth_linear;
+// image3d<seg_data_t>
+// pseg, pseg_smooth, pseg_smooth_linear;
+
+ // Preparing some common data.
+// if (selected_.contains(SegImageNonFiltered) ||
selected_.contains(MeanFunctionsNonFiltered))
+// pseg = labeling::pack(data_->seg(), pnlabels);
+// if (selected_.contains(SegImageLinearFilter) ||
selected_.contains(MeanFunctionsLinearFilter))
+// pseg_smooth_linear = labeling::pack(data_->seg_smooth_linear(),
pnlabels_smooth_linear);
+// if (selected_.contains(SegImageMorphoFilter) ||
selected_.contains(MeanFunctionsMorphoFilter))
+// pseg_smooth = labeling::pack(data_->seg_smooth(), pnlabels_smooth);
+
foreach(SavedData e, selected_)
{
@@ -135,24 +156,57 @@ namespace igr
emit next_step();
break;
- case SegImage:
- output = basedir_ + "/" + basename + "_segmentation.raw";
- io::raw::save(packed_seg, output.toStdString());
+
+ // Segmentations
+
+ case SegImageNonFiltered:
+ output = basedir_ + "/" + basename +
"_segmentation_non_filtered.raw";
+ io::raw::save(data_->seg(), output.toStdString());
+ emit next_step();
+ break;
+
+ case SegImageLinearFilter:
+ output = basedir_ + "/" + basename +
"_segmentation_linear_filter.raw";
+ io::raw::save(data_->seg_smooth_linear(), output.toStdString());
emit next_step();
break;
+ case SegImageMorphoFilter:
+ output = basedir_ + "/" + basename +
"_segmentation_morpho_filter.raw";
+ io::raw::save(data_->seg_smooth(), output.toStdString());
+ emit next_step();
+ break;
+
+
+ // Mean functions
+
+ case MeanFunctionsNonFiltered:
+ save_mean_funs(data_->seg(), data_->nregion(), data_->mean_regions(),
+ basename + "_non_filtered");
+ emit next_step();
+ break;
+
+ case MeanFunctionsLinearFilter:
+ save_mean_funs(data_->seg_smooth_linear(), data_->nregion_smooth_linear(),
+ data_->mean_regions_smooth_linear(),
+ basename + "_linear_filter");
+ emit next_step();
+ break;
+
+ case MeanFunctionsMorphoFilter:
+ save_mean_funs(data_->seg_smooth(), data_->nregion_smooth(),
+ data_->mean_regions_smooth(),
+ basename + "_morpho_filter");
+ emit next_step();
+ break;
+
+
+ default:
+ case SegImage:
case MeanFunctions:
- QString output_base = basedir_ + "/" + basename;
- util::array<util::array<input_data_t> >
- functions = shared::mean_function_per_region(data_->mean_regions(),
- packed_seg, packed_nlabels);
-
- for (unsigned i = 1; i < functions.nelements(); ++i)
- {
- QString name = output_base + "_l" + QString::number(i) + ".plot";
- io::plot::save(functions[i], name.toStdString());
- }
+ // Nothing.
emit next_step();
+ break;
}
}
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/save.hh
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/save.hh
index fc30282..53b61fe 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/save.hh
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/save.hh
@@ -26,7 +26,13 @@ namespace igr
Log,
RefImage,
SegImage,
- MeanFunctions
+ SegImageNonFiltered,
+ SegImageLinearFilter,
+ SegImageMorphoFilter,
+ MeanFunctions,
+ MeanFunctionsNonFiltered,
+ MeanFunctionsLinearFilter,
+ MeanFunctionsMorphoFilter
};
@@ -59,6 +65,10 @@ namespace igr
private: // Members
bool save_log(const QString& output);
+ void save_mean_funs(const seg_t& pseg,
+ const seg_data_t& pnlabels,
+ const mean_regions_t& mean_regions,
+ const QString& prefix);
private: // attributes
mln_data* data_;
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/seg.cc
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/seg.cc
index b57a52f..3769dc4 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/seg.cc
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/seg.cc
@@ -34,9 +34,20 @@ namespace igr
- seg::seg(mln_data* data, unsigned lambda)
- : data_(data), lambda_(lambda)
+ seg::seg(mln_data* data, unsigned lambda,
+ bool compute_preview, bool preview_computed)
+ : data_(data), lambda_(lambda),
+ compute_preview_(compute_preview),
+ preview_computed_(preview_computed)
{
+ // Setting step_count according to options.
+ if (compute_preview)
+ step_count_ = 3;
+ else
+ if (preview_computed)
+ step_count_ = 6;
+ else
+ step_count_ = 9;
}
@@ -45,12 +56,11 @@ namespace igr
}
- void seg::run()
+ const image3d<seg_data_t> seg::compute_seg(const
image3d<igr::smoothed_data_t>& norm,
+ seg_data_t& nregion)
{
- seg_data_t nregion;
image2d<seg_data_t>
- tmp = shared::time_segmentation(data_->norm_smooth(),
- nregion, lambda_);
+ tmp = shared::time_segmentation(norm, nregion, lambda_);
emit next_step();
@@ -58,7 +68,41 @@ namespace igr
emit next_step();
- data_->update_seg(wsd, nregion);
+ return wsd;
+ }
+
+
+ void seg::run()
+ {
+ // Compute result on morpho smooth image only.
+ if (compute_preview_ || !preview_computed_)
+ {
+ seg_data_t nregion;
+ image3d<seg_data_t> wsd = compute_seg(data_->norm_smooth(), nregion);
+ data_->update_seg_smooth(wsd, nregion);
+ }
+
+ if (!compute_preview_)
+ {
+ if (!preview_computed_)
+ emit next_step();
+
+ // Non filtered image.
+ {
+ seg_data_t nregion;
+ image3d<seg_data_t> wsd = compute_seg(data_->norm(), nregion);
+ data_->update_seg(wsd, nregion);
+ }
+
+ emit next_step();
+
+ // Linearly filtered image.
+ {
+ seg_data_t nregion;
+ image3d<seg_data_t> wsd = compute_seg(data_->norm_smooth_linear(),
nregion);
+ data_->update_seg_smooth_linear(wsd, nregion);
+ }
+ }
}
@@ -70,7 +114,7 @@ namespace igr
unsigned seg::step_count() const
{
- return 3;
+ return step_count_;
}
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/seg.hh
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/seg.hh
index 0e3d75e..f2efc90 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/seg.hh
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/tools/seg.hh
@@ -26,7 +26,8 @@ namespace igr
Q_OBJECT;
public:
- seg(mln_data* data, unsigned lambda);
+ seg(mln_data* data, unsigned lambda,
+ bool compute_preview, bool preview_computed);
~seg();
void run();
@@ -46,9 +47,16 @@ namespace igr
/// @}
+ private: // methods
+ const image3d<seg_data_t> compute_seg(const
image3d<igr::smoothed_data_t>& norm,
+ seg_data_t& nregion);
+
private: // attributes
mln_data* data_;
unsigned lambda_;
+ bool compute_preview_;
+ bool preview_computed_;
+ unsigned step_count_;
};
} // end of namespace igr::segmentation::tools
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/ui/plot_widget.ui
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/ui/plot_widget.ui
index adbc296..18d8e91 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/ui/plot_widget.ui
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/ui/plot_widget.ui
@@ -71,6 +71,26 @@
</widget>
</item>
<item>
+ <widget class="Line" name="line" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="savePlotBtn_" >
+ <property name="maximumSize" >
+ <size>
+ <width>16777215</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string>Save plot</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/ui/save_widget.ui
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/ui/save_widget.ui
index c832560..641cea6 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/ui/save_widget.ui
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/ui/save_widget.ui
@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>370</width>
- <height>362</height>
+ <height>470</height>
</rect>
</property>
<property name="sizePolicy" >
@@ -161,23 +161,87 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
- <widget class="QCheckBox" name="segImaCBox" >
- <property name="text" >
+ <widget class="QGroupBox" name="segImaCBox" >
+ <property name="title" >
<string>Segmentation image</string>
</property>
- <property name="checked" >
+ <property name="checkable" >
<bool>true</bool>
</property>
+ <layout class="QVBoxLayout" name="verticalLayout_5"
>
+ <item>
+ <widget class="QCheckBox"
name="segImaNonFilteredCBox" >
+ <property name="text" >
+ <string>Non-filtered</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox"
name="segImaLinearFilterCBox" >
+ <property name="text" >
+ <string>Linear filter</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox"
name="segImaMorphoFilterCBox" >
+ <property name="text" >
+ <string>Morphological filter</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="meanFunCBox" >
- <property name="text" >
- <string>Mean function per region </string>
+ <widget class="QGroupBox" name="meanFunCBox" >
+ <property name="title" >
+ <string>Mean function per region</string>
</property>
- <property name="checked" >
+ <property name="checkable" >
<bool>true</bool>
</property>
+ <layout class="QVBoxLayout" name="verticalLayout_4"
>
+ <item>
+ <widget class="QCheckBox"
name="meanFunNonFilteredCBox" >
+ <property name="text" >
+ <string>Non-filtered</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox"
name="meanFunLinearFilterCBox" >
+ <property name="text" >
+ <string>Linear filter</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox"
name="meanFunMorphoFilterCBox" >
+ <property name="text" >
+ <string>Morphological filter</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
</layout>
diff --git a/milena/sandbox/lazzara/igr/gui/shared/include/function_means.hh
b/milena/sandbox/lazzara/igr/gui/shared/include/function_means.hh
index bdc2098..18cb65a 100644
--- a/milena/sandbox/lazzara/igr/gui/shared/include/function_means.hh
+++ b/milena/sandbox/lazzara/igr/gui/shared/include/function_means.hh
@@ -49,7 +49,6 @@ namespace igr
/// Compute from slice \p sli_first to \p sli_last included.
//
template <typename V>
- inline
image2d<float>
function_means(const image3d<V>& ima, int sli_first, int sli_last);
diff --git a/milena/sandbox/lazzara/igr/gui/shared/include/mean_function_per_region.hh
b/milena/sandbox/lazzara/igr/gui/shared/include/mean_function_per_region.hh
index b0adcfc..75da3a8 100644
--- a/milena/sandbox/lazzara/igr/gui/shared/include/mean_function_per_region.hh
+++ b/milena/sandbox/lazzara/igr/gui/shared/include/mean_function_per_region.hh
@@ -30,6 +30,7 @@
#ifndef IGR_SHARED_INCLUDE_MEAN_FUNCTION_PER_REGION_HH
# define IGR_SHARED_INCLUDE_MEAN_FUNCTION_PER_REGION_HH
+# include <mln/core/var.hh>
# include <mln/core/image/image3d.hh>
# include <mln/core/image/dmorph/slice_image.hh>
@@ -49,7 +50,6 @@ namespace igr
/// Compute from slice \p sli_first to \p sli_last included.
//
template <typename V, typename L>
- inline
util::array<util::array<V> >
mean_function_per_region(const image3d<V>& ima,
const image3d<L>& lbl, const L& nregion);
diff --git a/milena/sandbox/lazzara/igr/gui/shared/include/mean_regions.hh
b/milena/sandbox/lazzara/igr/gui/shared/include/mean_regions.hh
index 85a2e7d..6872683 100644
--- a/milena/sandbox/lazzara/igr/gui/shared/include/mean_regions.hh
+++ b/milena/sandbox/lazzara/igr/gui/shared/include/mean_regions.hh
@@ -34,6 +34,8 @@
# include <mln/core/image/image2d.hh>
# include <mln/core/image/dmorph/slice_image.hh>
+# include <mln/core/var.hh>
+
# include <mln/data/paste.hh>
# include <mln/labeling/mean_values.hh>
# include <mln/labeling/pack.hh>
diff --git a/milena/sandbox/lazzara/igr/gui/shared/include/normalization.hh
b/milena/sandbox/lazzara/igr/gui/shared/include/normalization.hh
index 6ec41a2..e4d91eb 100644
--- a/milena/sandbox/lazzara/igr/gui/shared/include/normalization.hh
+++ b/milena/sandbox/lazzara/igr/gui/shared/include/normalization.hh
@@ -56,7 +56,6 @@ namespace igr
/// number of slices of \p input.
//
template <typename V1, typename V2>
- inline
image3d<float>
normalization(const image3d<V1>& ima, const image2d<V2>& mean);
diff --git a/milena/sandbox/lazzara/igr/gui/shared/include/time_smooth_morpho.hh
b/milena/sandbox/lazzara/igr/gui/shared/include/time_smooth_morpho.hh
index 4515e16..27331a0 100644
--- a/milena/sandbox/lazzara/igr/gui/shared/include/time_smooth_morpho.hh
+++ b/milena/sandbox/lazzara/igr/gui/shared/include/time_smooth_morpho.hh
@@ -31,6 +31,8 @@
# define IGR_SHARED_INCLUDE_TIME_SMOOTH_MORPHO_HH
# include <mln/core/image/image3d.hh>
+# include <mln/accu/stat/mean.hh>
+# include <mln/accu/image/all.hh>
# include <mln/morpho/closing/structural.hh>
# include <mln/morpho/opening/structural.hh>
# include <mln/win/sline3d.hh>
--
1.5.6.5