Skip to content

Commit 7a7d561

Browse files
committed
2 parents 6a8ec22 + 7d8a4f5 commit 7a7d561

7 files changed

+52
-4
lines changed

src/filters/output/BlackWhiteOptions.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace output
2626

2727
BlackWhiteOptions::BlackWhiteOptions()
2828
: m_thresholdMethod(OTSU),
29+
m_morphology(true),
2930
m_dimmingColoredCoef(0.0),
3031
m_thresholdAdjustment(0),
3132
m_thresholdWindowSize(200),
@@ -41,6 +42,7 @@ BlackWhiteOptions::BlackWhiteOptions()
4142

4243
BlackWhiteOptions::BlackWhiteOptions(QDomElement const& el)
4344
: m_thresholdMethod(parseThresholdMethod(el.attribute("thresholdMethod"))),
45+
m_morphology(el.attribute("morphology") == "1"),
4446
m_dimmingColoredCoef(el.attribute("dimmingColoredCoef").toDouble()),
4547
m_thresholdAdjustment(el.attribute("thresholdAdj").toInt()),
4648
m_thresholdWindowSize(el.attribute("thresholdWinSize").toInt()),
@@ -91,6 +93,7 @@ BlackWhiteOptions::toXml(QDomDocument& doc, QString const& name) const
9193
{
9294
QDomElement el(doc.createElement(name));
9395
el.setAttribute("thresholdMethod", formatThresholdMethod(m_thresholdMethod));
96+
el.setAttribute("morphology", m_morphology ? "1" : "0");
9497
el.setAttribute("dimmingColoredCoef", m_dimmingColoredCoef);
9598
el.setAttribute("thresholdAdj", m_thresholdAdjustment);
9699
el.setAttribute("thresholdWinSize", m_thresholdWindowSize);
@@ -111,6 +114,10 @@ BlackWhiteOptions::operator==(BlackWhiteOptions const& other) const
111114
{
112115
return false;
113116
}
117+
if (m_morphology != other.m_morphology)
118+
{
119+
return false;
120+
}
114121
if (m_dimmingColoredCoef != other.m_dimmingColoredCoef)
115122
{
116123
return false;

src/filters/output/BlackWhiteOptions.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ class BlackWhiteOptions
4646
m_thresholdMethod = val;
4747
}
4848

49+
bool morphology() const
50+
{
51+
return m_morphology;
52+
}
53+
void setMorphology(bool val)
54+
{
55+
m_morphology = val;
56+
}
57+
4958
double dimmingColoredCoef() const
5059
{
5160
return m_dimmingColoredCoef;
@@ -141,6 +150,7 @@ class BlackWhiteOptions
141150
bool operator!=(BlackWhiteOptions const& other) const;
142151
private:
143152
ThresholdFilter m_thresholdMethod;
153+
bool m_morphology;
144154
double m_dimmingColoredCoef;
145155
int m_thresholdAdjustment;
146156
int m_thresholdWindowSize;

src/filters/output/OptionsWidget.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ OptionsWidget::OptionsWidget(
205205
thresholdMethodSelector, SIGNAL(currentIndexChanged(int)),
206206
this, SLOT(thresholdMethodChanged(int))
207207
);
208+
connect(
209+
morphologyCB, SIGNAL(clicked(bool)),
210+
this, SLOT(morphologyToggled(bool))
211+
);
208212
connect(
209213
dimmingColoredCoef, SIGNAL(valueChanged(double)),
210214
this, SLOT(dimmingColoredCoefChanged(double))
@@ -569,6 +573,16 @@ OptionsWidget::thresholdMethodChanged(int idx)
569573
emit reloadRequested();
570574
}
571575

576+
void
577+
OptionsWidget::morphologyToggled(bool const checked)
578+
{
579+
BlackWhiteOptions black_white_options(m_colorParams.blackWhiteOptions());
580+
black_white_options.setMorphology(checked);
581+
m_colorParams.setBlackWhiteOptions(black_white_options);
582+
m_ptrSettings->setColorParams(m_pageId, m_colorParams);
583+
emit reloadRequested();
584+
}
585+
572586
void
573587
OptionsWidget::setLighterThreshold()
574588
{
@@ -926,6 +940,7 @@ OptionsWidget::updateColorsDisplay()
926940
{
927941
BlackWhiteOptions black_white_options(m_colorParams.blackWhiteOptions());
928942
thresholdMethodSelector->setCurrentIndex((int) black_white_options.thresholdMethod());
943+
morphologyCB->setChecked(black_white_options.morphology());
929944
dimmingColoredCoef->setValue(black_white_options.dimmingColoredCoef());
930945
thresholdSlider->setValue(black_white_options.thresholdAdjustment());
931946
thresholdWindowSize->setValue(black_white_options.thresholdWindowSize());

src/filters/output/OptionsWidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ private slots:
103103

104104
void thresholdMethodChanged(int idx);
105105

106+
void morphologyToggled(bool checked);
107+
106108
void dimmingColoredCoefChanged(double value);
107109

108110
void bwThresholdChanged();

src/filters/output/OutputGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,8 @@ OutputGenerator::process(
427427
status.throwIfCancelled();
428428

429429
QImage maybe_smoothed;
430-
431430
// We only do smoothing if we are going to do binarization later.
432-
if (render_params.needBinarization())
431+
if ((render_params.needBinarization()) && (black_white_options.morphology()))
433432
{
434433
maybe_smoothed = smoothToGrayscale(transformed_image, accel_ops);
435434
coloredDimmingFilterInPlace(maybe_smoothed, coloredSignificance);
@@ -442,6 +441,7 @@ OutputGenerator::process(
442441
{
443442
maybe_smoothed = transformed_image;
444443
}
444+
445445
BinaryImage colored_mask;
446446
if ((black_white_options.dimmingColoredCoef() > 0.0) && (black_white_options.coloredMaskCoef() > 0.0))
447447
{

src/filters/output/ui/OutputOptionsWidget.ui

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,21 @@
612612
</widget>
613613
</item>
614614
<item row="0" column="1">
615-
<widget class="QComboBox" name="thresholdMethodSelector"/>
615+
<widget class="QComboBox" name="thresholdMethodSelector">
616+
<property name="toolTip">
617+
<string>Select threshold method.</string>
618+
</property>
619+
</widget>
620+
</item>
621+
<item row="0" column="2">
622+
<widget class="QCheckBox" name="morphologyCB">
623+
<property name="text">
624+
<string>M</string>
625+
</property>
626+
<property name="toolTip">
627+
<string>Morphology ON/OFF.</string>
628+
</property>
629+
</widget>
616630
</item>
617631
</layout>
618632
</item>

src/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
#define SCANTAILOR_VERSION_H_
2121

2222
#define STFAMILY "experimental"
23-
#define VERSION "0.2023.10.18" // Must be "x.x.x.x" or an empty string.
23+
#define VERSION "0.2023.10.24" // Must be "x.x.x.x" or an empty string.
2424

2525
#endif

0 commit comments

Comments
 (0)