Adjust Morphology in NConvert?

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

Moderators: XnTriq, xnview

Post Reply
PRFreeman
Posts: 5
Joined: Tue Oct 17, 2017 3:33 am

Adjust Morphology in NConvert?

Post by PRFreeman » Sat Mar 02, 2019 1:20 am

I have been using nconvert quite successfully as part of a front end for optical mark recognition. Recently, however, my workplace converted all scanners to a new manufacturer and my recognition rate has fallen apart.
It seems to me, looking at what is happening, that I could solve a lot of the issues by using a close morphological operation on the scan (reducing lone pixels but leaving enough for the recognition where it is intended). However I cannot see if this can be done in nconvert.

The program is so wonderfully broad and flexible that I suspect this is just me not being knowledgeable or careful enough in reading the documentation, but I thought maybe someone here might have a suggestion?

Thank you very much!
Philip

cday
XnThusiast
Posts: 2190
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Adjust Morphology in NConvert?

Post by cday » Sat Mar 02, 2019 8:01 am

PRFreeman wrote:
Sat Mar 02, 2019 1:20 am
I have been using nconvert quite successfully as part of a front end for optical mark recognition. Recently, however, my workplace converted all scanners to a new manufacturer and my recognition rate has fallen apart.
One wonders why images from the new scanner are significantly different, possibly due to using different settings such as scanning to black and white instead of grayscale or colour, or a higher DPI setting? You have no control over the settings used?

It seems to me, looking at what is happening, that I could solve a lot of the issues by using a close morphological operation on the scan (reducing lone pixels but leaving enough for the recognition where it is intended). However I cannot see if this can be done in nconvert.
You might try the following option for a start:

Code: Select all

 -noise reduce     : Reduce noise
There are various other supported filter settings, and also resampling methods, or you might try resizing to smaller pixel dimensions if you can adapt your algorithm. Best to download the latest version of NConvert, create a help file and peruse the options available.

PRFreeman
Posts: 5
Joined: Tue Oct 17, 2017 3:33 am

Re: Adjust Morphology in NConvert?

Post by PRFreeman » Sat Mar 02, 2019 9:20 pm

Thank you for your suggestions!

The issue is that the new printer is in fact more aggressive about trying to get a good scan... but what it sees as 'good' is different than I have been optimizing for. So it is taking elements such as faint labels on regions to be marked and making them dark, while removing the scribbles of students filling in 'bubbles', especially for certain shades. I have made some progress adjusting settings, but they are all presented in 'user friendly' ways like "original printed from a black and white laser printer" or "newpaper article" or the like... and I have to try to find out what these mean in practical terms by trial and error.

In case it is of any help to others (though it seems unlikely this is a common problem) I have groped my way to a reasonable point by telling the scanner that it is reading black and white graphics (quite the opposite of the old scanner where claiming black and white text was the ticket). But this still makes some markings go away. However I can see in examining the scans that eroding with, say, a 2x2 pixel square pattern would eliminate most of what is giving false positives, and I could then crank up the sensitivity to avoid the false negatives.

I have poured over the listed options in nconvert, but they are phrased in the language of graphics users (as they should be) and not the basic operations that I am more familiar with (such as closures, dilations, or erosion). I will continue to try things, and do thank you for the suggestions!

cday
XnThusiast
Posts: 2190
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Adjust Morphology in NConvert?

Post by cday » Sat Mar 02, 2019 9:53 pm

PRFreeman wrote:
Sat Mar 02, 2019 9:20 pm
In case it is of any help to others (though it seems unlikely this is a common problem) I have groped my way to a reasonable point by telling the scanner that it is reading black and white graphics (quite the opposite of the old scanner where claiming black and white text was the ticket). But this still makes some markings go away.

Converting the images to black and white, or a levels adjustment on grayscale images to intensify lighter gray shades, wouldn't help? Experimenting to test alternative settings using one of the XnView GUI programs ('Classic or 'MP) might assist with the latter.

PRFreeman
Posts: 5
Joined: Tue Oct 17, 2017 3:33 am

Re: Adjust Morphology in NConvert?

Post by PRFreeman » Sun Mar 03, 2019 4:39 pm

This is more-or-less where I have wound up, and it is working (sort of). Images are converted to black and white for processing, its the subtle ways in which that interacts with the OMR that are causing issues. I have managed to get something workable by trial-and-error with some guestimation... but I may end up writing a small stand alone program to do some morphology on the files, since it seems otherwise I still lose some functionality compared to the old scanner. Just differences in technology that I wasn't aware even existed before! I am sure that there are ways in which these differences are also helpful... one just sees the negatives first.

I had not considered adjusting parameters in xnview to look for thresholds that work better, I've just been estimating what I think would work based on images out of the program, but that would be much better so thank you for that suggestion! I'll go and fiddle!

Post Reply