Page 1 of 1

Removing noise from -fx minima.r and maxima.r calculations

Posted: 2017-12-26T06:01:50-07:00
by TedBaker
Analysing film scans I use the values of -fx minima.r, maxima.r, minima.g, maxima.g etc.

Is there a fast (these are 50mb files or more), way of calculating these values but removing outliers, (which is noise either from the scanning process or scratches on the original)

I am currently using -blur 0x7, before calculating the max and min etc. Looking for ideas? I am only interested in removing the noise around the max and minimum values.

Re: Removing noise from -fx minima.r and maxima.r calculations

Posted: 2017-12-26T07:27:53-07:00
by snibgo
How many pixels wide and high?

The "-blur 0x7" will take time. Supplying a radius will reduce this, eg "-blur 21x7". Faster still, use integral images (see Windowed mean and standard deviation), eg:

Code: Select all

convert in.tiff -process integim -process 'deintegim w 21x21' out.tiff

Re: Removing noise from -fx minima.r and maxima.r calculations

Posted: 2017-12-26T08:27:16-07:00
by TedBaker
snibgo wrote:
2017-12-26T07:27:53-07:00
How many pixels wide and high?

The "-blur 0x7" will take time. Supplying a radius will reduce this, eg "-blur 21x7". Faster still, use integral images (see Windowed mean and standard deviation), eg:

Code: Select all

convert in.tiff -process integim -process 'deintegim w 21x21' out.tiff
some scans 3000px others 7000px

Thanks, I have been steadily going through your pages, they are very helpful. I had seen the integim process, which actually inspired my question, for a "-fx" style solution.

I will give integim a whirl

Re: Removing noise from -fx minima.r and maxima.r calculations

Posted: 2017-12-26T08:47:01-07:00
by snibgo
Integim suggests another possibility: it can calculate the mean and standard deviation for a window around each pixel. We can then determine whether the pixel lies within the range (mean plus or minus k*SD), where k is whatever you decide is reasonable, eg 1 or 2 or 3. If it is outside the range, we declare the pixel an outlier, so we replace it by the range limit. Otherwise we leave it alone.

This is a smarter method of removing outliers than simply replacing each pixel with a mean, which is what blur does. However, it adds time and complexity, and may be overkill.

EDIT: I should add, as you may know, "-fx" expressions are re-interpreted at every pixel, so is painfully slow, and unusable for images around 5000x5000 pixels. But it can be a useful prototyping tool.