Marshall,

That clarifies a great deal to me.
It is fast and implements well.
It seems to give almost the same recommendation for all 4 suits, too.

Thanks, very much.

On Tue, Jun 27, 2017 at 2:29 PM, Marshall Lochbaum <mwlochb...@gmail.com>
wrote:

> My answer was intended to help you find the optimal threshold to use.
> You are trying to interpret it as a way to measure how good a given
> threshold is. It turns out that the computations you did contain that
> information, but my method is much faster than checking each individual
> threshold.
>
> The input I had assumed was a matrix of intensities ranging from 0 to
> 255. From this I computed a "score" for each threshold without
> calculating any thresholded images. This is likely orders of magnitude
> faster than running contigmd on many thresholded images.
>
> The metric used for a threshold is essentially the length of the
> diamond's boundary. It's the number of places where a 1 is next to a 0,
> and minimizing it will tend to remove holes, which add to the boundary.
> If you imagine the initial image as a grid of points, where each has
> height equal to its intensity (like you would get with
> ('surface' plot img)), then a threshold can be represented as a
> horizontal plane, and the value to be minimized is the number of grid
> lines which it crosses.
>
> That condition is independent of the horizontal position of the
> endpoints of each grid line, and if we ignore that information, we find
> each line spans some interval within the range 0-255 of possible
> intensities. The threshold cuts that line if it lies within the
> interval. So we want to count the number of intervals containing the
> threshold.
>
> To do that, the first step is to find all of the pairs of adjacent
> intensities, which is performed by the function you used below. When
> applied to a thresholded image containing only zeros and ones, there are
> only four possible pairs. Making a histogram of these values like
> freqcount does then gives four numbers:
>
> > 0 0 1034
> > 1 1  302
> > 1 0   84
> > 0 1   84
>
> These are the number of pairs of adjacent zeros, ones, and zero-one
> pairs in both directions. The sum of the last two numbers (i.e. 84+84)
> is the value to be minimized, since it is the number of places where the
> threshold left two adjacent pixels next to each other.
>
> Marshall
>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to