Новая сборка.
Добавил новую опцию:
Dont_Equalize_Illumination_Pic_ZonesНе применять выравнивание освещённости к зонам иллюстраций.
Опция - глобальная, оформлена в виде новой галки в окне Настройки. Влияет исключительно на процесс создания выводных "смешанных" сканов.
Возможный сценарий использования:
1. Сделать сканобработку как обычно.
2. Просмотреть сканы на стадии "Вывод", и те "смешанные" сканы, где образовались "пересвеченные" зоны иллюстраций, удалить физически из папки out.
3. Установить галку "Не выравнивать освещённость в зонах иллюстраций" в окне Инструменты - Настройки...
4. Запустить пакетную обработку всех сканов на стадии "Вывод" и уйти заниматься своими делами.
Вместо физического удаления можно применить любой иной способ воздействия на нужный выводной смешанный скан - с таким расчётом, чтобы на него выставился знак вопроса - и потом переобработать его. Но удалить, мне кажется, проще всего.
Опцию я сделал глобальной (а не постраничной) по 2 причинам:
1. Это очень редко нужный функционал. Я сколько лет книги сканирую - и у меня ни разу в ней нужды не возникало. А ведь, как говорит Tulon - "каждая новая галочка - это удар по простоте интерфейса".
2. Сделай я эту опцию постраничной, мне потребовалось бы ставить программно знак вопроса на соответствующий скан и записывать состояния опции в файл задания. Всё это - значительный геморрой, и для такой пустячной вещи это было бы слишком большие усилия с моей стороны.
Коды исправления:
//Dont_Equalize_Illumination_Pic_Zones
C:\build\scantailor_featured\SettingsDialog.h
class SettingsDialog : public QDialog
{
.......
public:
signals:
.......
void DontEqualizeIlluminationPicZonesSignal(bool state);
private slots:
.......
void OnCheckDontEqualizeIlluminationPicZones(bool);
C:\build\scantailor_featured\SettingsDialog.cpp
SettingsDialog::SettingsDialog(QWidget* parent)
......
{
......
ui.DontEqualizeIlluminationPicZones->setChecked(settings.value("settings/dont_equalize_illumination_pic_zones").toBool());
connect(ui.DontEqualizeIlluminationPicZones, SIGNAL(toggled(bool)), this, SLOT(OnCheckDontEqualizeIlluminationPicZones(bool)));
......
void
SettingsDialog::OnCheckDontEqualizeIlluminationPicZones(bool state)
{
QSettings settings;
settings.setValue("settings/dont_equalize_illumination_pic_zones", state);
emit DontEqualizeIlluminationPicZonesSignal(state);
}
C:\build\scantailor_featured\MainWindow.h
class MainWindow :
.......
public slots:
......
void DontEqualizeIlluminationPicZones(bool);
......
private:
......
bool m_dont_equalize_illumination_pic_zones;
}
C:\build\scantailor_featured\MainWindow.cpp
MainWindow::MainWindow()
......
m_dont_equalize_illumination_pic_zones = settings.value("settings/dont_equalize_illumination_pic_zones").toBool();
}
void
MainWindow::DontEqualizeIlluminationPicZones(bool state)
{
m_dont_equalize_illumination_pic_zones = state;
}
void
MainWindow::openSettingsDialog()
{
.....
connect(dialog, SIGNAL(DontEqualizeIlluminationPicZonesSignal(bool)), this, SLOT(DontEqualizeIlluminationPicZones(bool)));
dialog->show();
}
BackgroundTaskPtr
MainWindow::createCompositeTask(
.....
if (last_filter_idx >= m_ptrStages->outputFilterIdx()) {
output_task = m_ptrStages->outputFilter()->createTask(
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//page.id(), m_ptrThumbnailCache, m_outFileNameGen, batch, debug
page.id(), m_ptrThumbnailCache, m_outFileNameGen, batch, debug,
m_dont_equalize_illumination_pic_zones
//end of modified by monday2000
);
..........
C:\build\scantailor_featured\filters\output\Filter.h
class Filter : public AbstractFilter
{
.....
public:
.....
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//bool batch, bool debug);
bool batch, bool debug, bool dont_equalize_illumination_pic_zones=false); // "false" as cli workaround
//end of modified by monday2000
C:\build\scantailor_featured\filters\output\Filter.cpp
IntrusivePtr<Task>
Filter::createTask(
......
OutputFileNameGenerator const& out_file_name_gen,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//bool const batch, bool const debug)
bool const batch, bool const debug,
bool dont_equalize_illumination_pic_zones)
//end of modified by monday2000
{
......
new Task(
IntrusivePtr<Filter>(this), m_ptrSettings,
thumbnail_cache, page_id, out_file_name_gen,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//lastTab, batch, debug
lastTab, batch, debug, dont_equalize_illumination_pic_zones
//end of modified by monday2000
)
);
}
C:\build\scantailor_featured\filters\output\Task.h
class Task : public RefCountable
{
......
public:
Task(IntrusivePtr<Filter> const& filter,
......
PageId const& page_id, OutputFileNameGenerator const& out_file_name_gen,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//ImageViewTab last_tab, bool batch, bool debug);
ImageViewTab last_tab, bool batch, bool debug, bool dont_equalize_illumination_pic_zones);
//end of modified by monday2000
......
FilterResultPtr process(
TaskStatus const& status, FilterData const& data,
QPolygonF const& content_rect_phys);
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
bool m_dont_equalize_illumination_pic_zones;
//end of modified by monday2000
C:\build\scantailor_featured\filters\output\Task.cpp
Task::Task(IntrusivePtr<Filter> const& filter,
.......
PageId const& page_id, OutputFileNameGenerator const& out_file_name_gen,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//ImageViewTab const last_tab, bool const batch, bool const debug)
ImageViewTab const last_tab, bool const batch, bool const debug,
bool dont_equalize_illumination_pic_zones)
//end of modified by monday2000
: m_ptrFilter(filter),
........
m_batchProcessing(batch),
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//m_debug(debug)
m_debug(debug),
m_dont_equalize_illumination_pic_zones(dont_equalize_illumination_pic_zones)
//end of modified by monday2000
{
if (debug) {
......
FilterResultPtr
Task::process(
.....
if (need_reprocess) {
// Even in batch processing mode we should still write automask, because it
.....
out_img = generator.process(
......
params.depthPerception(),
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
m_dont_equalize_illumination_pic_zones,
//end of modified by monday2000
write_automask ? &automask_img : 0,
.....
C:\build\scantailor_featured\filters\output\OutputGenerator.h
class OutputGenerator
{
public:
.....
QImage process(
TaskStatus const& status, FilterData const& input,
.....
DepthPerception const& depth_perception,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
bool dont_equalize_illumination_pic_zones,
//end of modified by monday2000
imageproc::BinaryImage* auto_picture_mask = 0,
......
private:
QImage processImpl(
TaskStatus const& status, FilterData const& input,
......
DepthPerception const& depth_perception,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
bool dont_equalize_illumination_pic_zones,
//end of modified by monday2000
imageproc::BinaryImage* auto_picture_mask = 0,
......
QImage processWithoutDewarping(
TaskStatus const& status, FilterData const& input,
ZoneSet const& picture_zones, ZoneSet const& fill_zones,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
bool dont_equalize_illumination_pic_zones,
//end of modified by monday2000
imageproc::BinaryImage* auto_picture_mask = 0,
.......
QImage processWithDewarping(
TaskStatus const& status, FilterData const& input,
.......
DepthPerception const& depth_perception,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
bool dont_equalize_illumination_pic_zones,
//end of modified by monday2000
imageproc::BinaryImage* auto_picture_mask = 0,
......
static imageproc::GrayImage normalizeIlluminationGray(
......
QTransform const& xform, QRect const& target_rect,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
QImage& original_image,
//end of modified by monday2000
imageproc::GrayImage* background = 0, DebugImages* dbg = 0);
.........
C:\build\scantailor_featured\filters\output\OutputGenerator.cpp
template<typename MixedPixel>
void combineMixed(
QImage& mixed, BinaryImage const& bw_content,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//BinaryImage const& bw_mask)
BinaryImage const& bw_mask,
//added:
QImage& original_image,
bool dont_equalize_illumination_pic_zones
)
//end of modified by monday2000
{
.....
uint32_t const msb = uint32_t(1) << 31;
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
uchar* original_image_line = original_image.bits();
int const original_image_stride = original_image.bytesPerLine();
//end of modified by monday2000
for (int y = 0; y < height; ++y) {
.....
} else {
// Non-B/W content.
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//mixed_line[x] = reserveBlackAndWhite<MixedPixel>(mixed_line[x]);
if (dont_equalize_illumination_pic_zones)
mixed_line[x] = reserveBlackAndWhite<MixedPixel>(original_image_line[x]);
else
mixed_line[x] = reserveBlackAndWhite<MixedPixel>(mixed_line[x]);
//end of modified by monday2000
}
.....
bw_mask_line += bw_mask_stride;
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
original_image_line += original_image_stride;
//end of modified by monday2000
}
......
QImage
OutputGenerator::process(
TaskStatus const& status, FilterData const& input,
......
DepthPerception const& depth_perception,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
bool dont_equalize_illumination_pic_zones,
//end of modified by monday2000
imageproc::BinaryImage* auto_picture_mask,
......
QImage image(
processImpl(
status, input, picture_zones, fill_zones,
dewarping_mode, distortion_model, depth_perception,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
dont_equalize_illumination_pic_zones,
//end of modified by monday2000
auto_picture_mask, speckles_image, dbg
........
GrayImage
OutputGenerator::normalizeIlluminationGray(
.......
QTransform const& xform, QRect const& target_rect,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
QImage& original_image,
//end of modified by monday2000
GrayImage* background, DebugImages* const dbg)
{
.......
if (dbg) {
dbg->add(to_be_normalized, "to_be_normalized");
}
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
original_image = to_be_normalized;
//end of modified by monday2000
status.throwIfCancelled();
.....
QImage
OutputGenerator::processImpl(
TaskStatus const& status, FilterData const& input,
......
DepthPerception const& depth_perception,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
bool dont_equalize_illumination_pic_zones,
//end of modified by monday2000
imageproc::BinaryImage* auto_picture_mask,
......
return processWithDewarping(
status, input, picture_zones, fill_zones,
dewarping_mode, distortion_model, depth_perception,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
dont_equalize_illumination_pic_zones,
//end of modified by monday2000
auto_picture_mask, speckles_image, dbg
........
return processWithoutDewarping(
status, input, picture_zones, fill_zones,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
dont_equalize_illumination_pic_zones,
//end of modified by monday2000
auto_picture_mask, speckles_image, dbg
.......
QImage
OutputGenerator::processWithoutDewarping(
TaskStatus const& status, FilterData const& input,
ZoneSet const& picture_zones, ZoneSet const& fill_zones,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
bool dont_equalize_illumination_pic_zones,
//end of modified by monday2000
imageproc::BinaryImage* auto_picture_mask,
........
normalize_illumination_crop_area.translate(-normalize_illumination_rect.topLeft());
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
QImage original_image;
//end of modified by monday2000
if (render_params.normalizeIllumination()) {
maybe_normalized = normalizeIlluminationGray(
status, input.grayImage(), orig_image_crop_area,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//m_xform.transform(), normalize_illumination_rect, 0, dbg
m_xform.transform(), normalize_illumination_rect, original_image, 0, dbg
//end of modified by monday2000
);
.......
if (maybe_normalized.format() == QImage::Format_Indexed8) {
combineMixed<uint8_t>(
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//maybe_normalized, bw_content, bw_mask
maybe_normalized, bw_content, bw_mask,
original_image,
dont_equalize_illumination_pic_zones
//end of modified by monday2000
);
} else {
assert(maybe_normalized.format() == QImage::Format_RGB32
|| maybe_normalized.format() == QImage::Format_ARGB32);
combineMixed<uint32_t>(
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//maybe_normalized, bw_content, bw_mask
maybe_normalized, bw_content, bw_mask,
original_image,
dont_equalize_illumination_pic_zones
//end of modified by monday2000
);
.........
QImage
OutputGenerator::processWithDewarping(
TaskStatus const& status, FilterData const& input,
.......
DepthPerception const& depth_perception,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
bool dont_equalize_illumination_pic_zones,
//end of modified by monday2000
imageproc::BinaryImage* auto_picture_mask,
......
) * m_xform.transformBack()
);
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
QImage original_image;
//end of modified by monday2000
if (!render_params.normalizeIllumination()) {
......
warped_gray_output = normalizeIlluminationGray(
status, input.grayImage(), orig_image_crop_area,
m_xform.transform(), normalize_illumination_rect,
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//added:
original_image,
//end of modified by monday2000
&warped_gray_background, dbg
.......
if (dewarped.format() == QImage::Format_Indexed8) {
combineMixed<uint8_t>(
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//dewarped, dewarped_bw_content, dewarped_bw_mask
dewarped, dewarped_bw_content, dewarped_bw_mask,
original_image,
dont_equalize_illumination_pic_zones
//end of modified by monday2000
);
} else {
assert(dewarped.format() == QImage::Format_RGB32
|| dewarped.format() == QImage::Format_ARGB32);
combineMixed<uint32_t>(
//begin of modified by monday2000
//Dont_Equalize_Illumination_Pic_Zones
//dewarped, dewarped_bw_content, dewarped_bw_mask
dewarped, dewarped_bw_content, dewarped_bw_mask,
original_image,
dont_equalize_illumination_pic_zones
//end of modified by monday2000
);
.......
Сборка от 2013.02.09:
http://rghost.ru/43674111