Skip to content

Commit

Permalink
Merge pull request ScanTailor-Advanced#70 from ImageProcessing-Electr…
Browse files Browse the repository at this point in the history
…onicPublications/master

feature ScanTailor-Advanced#50: foreground and background zones
  • Loading branch information
vigri authored Aug 3, 2023
2 parents 6df8b7d + b6f8459 commit c575887
Show file tree
Hide file tree
Showing 13 changed files with 326 additions and 107 deletions.
5 changes: 3 additions & 2 deletions src/app/DefaultParamsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ DefaultParamsDialog::DefaultParamsDialog(QWidget* parent)
thresholdMethodBox->addItem(tr("Otsu"), OTSU);
thresholdMethodBox->addItem(tr("Sauvola"), SAUVOLA);
thresholdMethodBox->addItem(tr("Wolf"), WOLF);
thresholdMethodBox->addItem(tr("Bradley"), BRADLEY);
thresholdMethodBox->addItem(tr("EdgePlus"), EDGEPLUS);
thresholdMethodBox->addItem(tr("BlurDiv"), BLURDIV);
thresholdMethodBox->addItem(tr("EdgeDiv"), EDGEDIV);
Expand Down Expand Up @@ -665,8 +666,8 @@ std::unique_ptr<DefaultParams> DefaultParamsDialog::buildParams() const {
blackWhiteOptions.setBinarizationMethod(binarizationMethod);
blackWhiteOptions.setThresholdAdjustment(thresholdSlider->value());
blackWhiteOptions.setSauvolaCoef(sauvolaCoef->value());
if (binarizationMethod == SAUVOLA || binarizationMethod == EDGEPLUS || binarizationMethod == BLURDIV
|| binarizationMethod == EDGEDIV) {
if (binarizationMethod == SAUVOLA || binarizationMethod == BRADLEY || binarizationMethod == EDGEPLUS
|| binarizationMethod == BLURDIV || binarizationMethod == EDGEDIV) {
blackWhiteOptions.setWindowSize(sauvolaWindowSize->value());
} else if (binarizationMethod == WOLF) {
blackWhiteOptions.setWindowSize(wolfWindowSize->value());
Expand Down
5 changes: 5 additions & 0 deletions src/core/filters/output/BlackWhiteOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ BinarizationMethod BlackWhiteOptions::parseBinarizationMethod(const QString& str
return WOLF;
} else if (str == "sauvola") {
return SAUVOLA;
} else if (str == "bradley") {
return BRADLEY;
} else if (str == "edgeplus") {
return EDGEPLUS;
} else if (str == "blurdiv") {
Expand All @@ -95,6 +97,9 @@ QString BlackWhiteOptions::formatBinarizationMethod(BinarizationMethod type) {
case WOLF:
str = "wolf";
break;
case BRADLEY:
str = "bradley";
break;
case EDGEPLUS:
str = "edgeplus";
break;
Expand Down
2 changes: 1 addition & 1 deletion src/core/filters/output/BlackWhiteOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class QDomDocument;
class QDomElement;

namespace output {
enum BinarizationMethod { OTSU, SAUVOLA, WOLF, EDGEPLUS, BLURDIV, EDGEDIV };
enum BinarizationMethod { OTSU, SAUVOLA, WOLF, BRADLEY, EDGEPLUS, BLURDIV, EDGEDIV };

class BlackWhiteOptions {
public:
Expand Down
4 changes: 4 additions & 0 deletions src/core/filters/output/OptionsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ OptionsWidget::OptionsWidget(std::shared_ptr<Settings> settings, const PageSelec
thresholdMethodBox->addItem(tr("Otsu"), OTSU);
thresholdMethodBox->addItem(tr("Sauvola"), SAUVOLA);
thresholdMethodBox->addItem(tr("Wolf"), WOLF);
thresholdMethodBox->addItem(tr("Bradley"), BRADLEY);
thresholdMethodBox->addItem(tr("EdgePlus"), EDGEPLUS);
thresholdMethodBox->addItem(tr("BlurDiv"), BLURDIV);
thresholdMethodBox->addItem(tr("EdgeDiv"), EDGEDIV);
Expand All @@ -54,6 +55,8 @@ OptionsWidget::OptionsWidget(std::shared_ptr<Settings> settings, const PageSelec
QPointer<BinarizationOptionsWidget> sauvolaBinarizationOptionsWidget
= new SauvolaBinarizationOptionsWidget(m_settings);
QPointer<BinarizationOptionsWidget> wolfBinarizationOptionsWidget = new WolfBinarizationOptionsWidget(m_settings);
QPointer<BinarizationOptionsWidget> bradleyBinarizationOptionsWidget
= new SauvolaBinarizationOptionsWidget(m_settings);
QPointer<BinarizationOptionsWidget> edgeplusBinarizationOptionsWidget
= new SauvolaBinarizationOptionsWidget(m_settings);
QPointer<BinarizationOptionsWidget> blurdivBinarizationOptionsWidget
Expand All @@ -67,6 +70,7 @@ OptionsWidget::OptionsWidget(std::shared_ptr<Settings> settings, const PageSelec
addBinarizationOptionsWidget(otsuBinarizationOptionsWidget);
addBinarizationOptionsWidget(sauvolaBinarizationOptionsWidget);
addBinarizationOptionsWidget(wolfBinarizationOptionsWidget);
addBinarizationOptionsWidget(bradleyBinarizationOptionsWidget);
addBinarizationOptionsWidget(edgeplusBinarizationOptionsWidget);
addBinarizationOptionsWidget(blurdivBinarizationOptionsWidget);
addBinarizationOptionsWidget(edgedivBinarizationOptionsWidget);
Expand Down
Loading

0 comments on commit c575887

Please sign in to comment.