Add adaptive binarization function to nconvert

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: helmut, XnTriq, xnview

SAMSAM
Posts: 39
Joined: Sun Sep 15, 2019 5:14 pm

Add adaptive binarization function to nconvert

Post by SAMSAM »

First of all, I want to express my gratitude for your wonderful tool. nconvert has been around for a long time. It has become indispensable in my work due to its simplicity and powerful batch image processing capabilities.

However, I am faced with the need to perform adaptive image binarization, which is currently missing from the nconvert functionality. Adaptive binarization is an important operation for processing images with uneven illumination, and its addition it would significantly expand the capabilities of your tool.

I would like to propose an implementation of the adaptive binarization command with three parameters:

1. Radius is a parameter that determines the size of the area for calculating the local threshold (from 4 to 100).
2. Smooth is a parameter that regulates the degree of smoothing of the image before binarization (from 0 to 100).
3. Binarize is the threshold value for binarization (from 0 to 255).

Example of using the command:
nconvert -adaptive_binarize radius=20 smooth=50 threshold=128 input.jpg -o output.png

Such a feature would be extremely useful for tasks of processing scanned documents, text recognition and other tasks where adaptive binarization is required. I would really appreciate it if you would consider adding this feature in future versions of nconvert. If you need additional information or usage examples, I am ready to provide them.

Thank you for your attention and for your hard work!
User avatar
xnview
Author of XnView
Posts: 45988
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Add adaptive binarization function to nconvert

Post by xnview »

yes, please provide some examples
Pierre.
SAMSAM
Posts: 39
Joined: Sun Sep 15, 2019 5:14 pm

Re: Add adaptive binarization function to nconvert

Post by SAMSAM »

I am sending you a link to an archive with sample files for adaptive binarization. The link is valid for 14 days. I am ready to provide additional information and explanations.
https://dropmefiles.com/u428h
User avatar
xnview
Author of XnView
Posts: 45988
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Add adaptive binarization function to nconvert

Post by xnview »

sorry but your link doesnt work
Pierre.
SAMSAM
Posts: 39
Joined: Sun Sep 15, 2019 5:14 pm

Re: Add adaptive binarization function to nconvert

Post by SAMSAM »

Good afternoon!
I put the sample file in the new storage.
https://drive.google.com/file/d/1BLX7GO ... drive_link
cday
XnThusiast
Posts: 4374
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Add adaptive binarization function to nconvert

Post by cday »

You need to use the Google Drive option to make the link available to anyone, otherwise Pierre will have to request access from you.
SAMSAM
Posts: 39
Joined: Sun Sep 15, 2019 5:14 pm

Re: Add adaptive binarization function to nconvert

Post by SAMSAM »

Opened access for everyone.
anfvan6
Posts: 12
Joined: Sun Mar 22, 2020 2:11 pm

Re: Add adaptive binarization function to nconvert

Post by anfvan6 »

Скорее всего вам нужно воспользоваться программой ScanKromsator. Поищете его на руборд.ком.
Также существуют консольный бинаризатор входящий в Potrace (MKbitmap) potrace.sourceforge.net

English:

Most likely you need to use the program ScanKromsator. Look for it on ru-board.com.
There is also a console binarizer included in Potrace (MKbitmap) potrace.sourceforge.net
SAMSAM
Posts: 39
Joined: Sun Sep 15, 2019 5:14 pm

Re: Add adaptive binarization function to nconvert

Post by SAMSAM »

Спасибо, обязательно посмотрю и попробую данные программы. Давно использую nconvert и хотелось бы иметь в одном пакете все необходимые инструменты. :)

Thanks, I will definitely take a look and try these programs. I've been using nconvert for a long time and would love to have all the tools I need in one package. :)
User avatar
xnview
Author of XnView
Posts: 45988
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Add adaptive binarization function to nconvert

Post by xnview »

could you put output that you would like to have?
Pierre.
SAMSAM
Posts: 39
Joined: Sun Sep 15, 2019 5:14 pm

Re: Add adaptive binarization function to nconvert

Post by SAMSAM »

If I understood your question correctly, the output file is in TIF black and white.
anfvan6
Posts: 12
Joined: Sun Mar 22, 2020 2:11 pm

Re: Add adaptive binarization function to nconvert

Post by anfvan6 »

SAMSAM wrote: Tue Apr 15, 2025 10:52 am If I understood your question correctly, the output file is in TIF black and white.
Вероятно Пьер имел ввиду, чтобы вы нафотошопили примерно ожидаемый результат, как он должен выглядеть (техзадание так сказать)
Возможно вы ожидаете примерно такой результат:
https://workupload.com/file/B72vP9rWGjL

In English:
Pierre probably meant that you would "photoshop" the expected result, how it should look (technical specifications, so to speak)
Perhaps you expect something like this:
https://workupload.com/file/B72vP9rWGjL
SAMSAM
Posts: 39
Joined: Sun Sep 15, 2019 5:14 pm

Re: Add adaptive binarization function to nconvert

Post by SAMSAM »

In addition to what was presented earlier. A video on the difference between the two binarization methods can be viewed here.
https://workupload.com/file/H2Fz8RNPdB7
Willing to provide additional information.