Perhaps use http://www.jsoftware.com/pipermail/general/2005-August/024174.html and then count the length of the nub of the ravel?
I hope this helps, -- Raul On Mon, Jun 26, 2017 at 5:54 PM, Brian Schott <[email protected]> wrote: > In my webcam playing-card image recognizer, I am trying to set a threshold > that depends on the amount of ambient lighting on the playing cards. If the > threshold is set well than I can better distinguish between the card suits > and pips. The threshold is a number between 0 and 255 and my experience has > seen it between 100 and 180. But I have no algorithm to get a best value, > only an eyeballed acceptable value. > > My idea is to present the webcam with any card with the diamond suit and to > search for a threshold value that produces the best diamond (during the > setup period of the app usage, and then to leave the threshold value alone > later). > > The image is always inside a boolean array of shape 30 26. The center of > the array always is inside the diamond image but that's about the only > known fact, because the image can be off-center slightly and even tilted > slightly and the size of the diamond in the image is unknown. If the > threshold is set too high the boolean image is all 1s, if the threshold is > set too low, the boolean image is all 0s. (The diamond suit is easiest to > use because of its relatively regular shape on almost any card deck.) > > The two examples below are meant to show a dirty diamond and a very clean > diamond. The clean example has no holes of 0s internal to the external > perimeter of the diamond. I cannot guarantee that every image can be > captured with a perfectly clean diamond, so I would sort of like to find > the threshold that produces the diamond with the greatest number of > contiguous 1's, sort of. I feel as if there is likely to be a gradual > increase in the number of contiguous 1's in the sweetspot range of the > threshold value, but I'm not sure of this. > > I am open to other ideas for accomplishing this thresholding, btw. But > mostly I am looking for J code ideas. > > You may be able to copy and paste each example from this email. I suppose I > could > > 00000000000000000000000000 > 00000000000000000000000000 > 00000000000000000000000000 > 00000000000000000000000000 > 00000000000000100000000000 > 00000000000001110000000000 > 00000000000001110000000000 > 00000000000011111000000000 > 00000000000111111100000000 > 00000000000111101100000000 > 00000000001111111110000000 > 00000000011111111100000000 > 00000000111111111111100000 > 00000001111111111111010000 > 00000011111111111111010000 > 00000101111111111110011100 > 00001111011110110101011100 > 00000111111111111111110000 > 00000011110011100101100000 > 00000001111111111101100000 > 00000001111111110100000000 > 00000000011111110110000000 > 00000000010101010000000000 > 00000000000010110000000000 > 00000000000110111000000000 > 00000000000110110000000000 > 00000000000010100000000000 > 00000000000000000000000000 > 00000000000000000000000000 > 00000000000000000000000000 > > 00000000000000000000000000 > 00000000000000000000000000 > 00000000000000000000000000 > 00000000000000100000000000 > 00000000000001110000000000 > 00000000000001111000000000 > 00000000000011111000000000 > 00000000000111111100000000 > 00000000001111111100000000 > 00000000011111111111000000 > 00000000011111111111000000 > 00000001111111111111100000 > 00000001111111111111110000 > 00000011111111111111111100 > 00000111111111111111111100 > 00001111111111111111111100 > 00001111111111111111111000 > 00000111111111111111110000 > 00000011111111111111100000 > 00000001111111111111000000 > 00000000111111111110000000 > 00000000011111111100000000 > 00000000001111111100000000 > 00000000000111111000000000 > 00000000000111110000000000 > 00000000000011110000000000 > 00000000000011100000000000 > 00000000000001000000000000 > 00000000000001000000000000 > 00000000000000000000000000 > > > Thanks, > > > -- > (B=) <-----my sig > Brian Schott > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
