Monday, April 13, 2015

ASCII Anomaly with Illustrations !


An ASCII Image is simply an Ordinary Photographic Picture that has been reduced to a Gray Scale of 16 Shades of Gray, Then Converted to A Set of Characters from a Given Alphabet.


The ASCII      Conversation Program ( written for this series in ‘Scratch’ ) then Samples The Picture at Various Points to Determine which Gray Shade is at that location— Then it Selects from a List of Characters, One which Ostensibly Conveys that Same ‘Sense’ of ‘Darkness’ or ‘Lightness’ —

e.g.;  A very Light Swatch ( Pixel ) in The Photograph will be rendered on The ASCII Image as a :    . , ‘ or a -

A Dark Swatch ( Pixel ) would be Translated into a :   W M R or K


The Internet has many such ASCII Conversation Programs Available for you to use;

But i have found that many of them; Nearly All in fact, Are very lazy about choosing which Characters are used for Which Shades of Gray. Even if you were to find an ASCII Conversion Program that Uses more than 16 Shades of Grey; Say— 24, 36, 128 or 256; The Generic Approach is to Use One Single Character for Each Shade of Gray; So that there is a Consistent 1::1 Correspondence with Grey Swatch to Character Used.


The Problem; As i Perceived it; Was that this approach created Regions in which a Single Character was Used Exclusively, & Worse, Far Worse ( !!! ) — Was that when a Given Gray Region would Buttress another Gray Region; The Boundary of these Two Regions would create an UnSightly & UnNatural Looking Ridgeway ( ! )


When there are Several of these Ridgeways Defining a Larger Swatch which in The Photograph looks like a Smooth Gradation from Very Light to Very Dark— When it is Translated into as ASCII Region, It becomes a Garish Series of Stripes ( !!! ) That is Unbearable !


So The Solution that i incorporated into my ASCII Program; Originally Pioneered on my HP48sx Programmable Calculator— Was to allow The Program to PseudoRandomly Choose a Character from A List or Region in A Continuum of Characters for Each Gray Shade !

e.g.; A Given Shade of Middling Gray may be Either a :   y 2 3 6 9 or P


This Results in a ‘Noisier’ Gray Region,

Which seems to ‘Imply’ a Greater Resolution !


Such a Rendering Looks Something Like This :



The Chances of Two of The Same Characters Appearing Side by Side given that The Two Gray Swatches are Equal is The First Character x The Second Character from a List of Six Characters or 1 in 6.

Three Characters Sides by Side would be 1 x 6 x 6 or : 1 in 36

But.

i thought that this would be ‘Too Often !’

So i wrote a little Loop into my Program that would try to Find a Unique Character 3 Times.

So that; Now— Two Characters side by side would be 1 x ( 6 x 6 x 6 )

or 1 in 216.

But in a Very Large ASCII Picture, is is bound to happen many times.

But 3 Characters side by side would 1 in 432.

& that would happen many times still, When— The Three Gray Sampled Patches are all Equal, which happens pretty often.

So for there to be a Truly Anomalous Region to Exist;

There has to be Quite a Bit of Repetition, & Additionally; By my Reckoning, There has to be Several Lines, Vertically Arranged, in a Particular Horizontal Region—

In Other Words; A 2D Blob of Repetition !

The Bigger this Blob is; The More Anomalous it is. ( !!! ) ( ? )


The Chances of this Occurring, According to my Calculation is :

Something like 1.0 with 57,132 Zeros after that.

In other Words; Very Unlikely for this Tiny Swatch.



This one as shorter Horizontal Repetition Sequences,

Each only Bucking The Odds to Something like 10_million per line,

But then they are arranged Vertically, about 7 high;

So that makes it about ( ? ) 1 with 300,000 Zeros to 1.

Very Unlikely.

So when one of these shows up :



What does this mean ?

The Fact that these are occurring very irregularly;

Means that The Program is Working as it should, most of The Time.

Nearly all of The Time, The Distribution looks exactly as it should.

What is Going on ?

i’m thinking that it -Must Be- somekind of weird anomaly in The Scratch Application, but How or What is it doing ( ? )

This is The Whole ‘Kaden’ Image that The Really Weird Patch Came from; With The Other ‘Anomalous’ Regions in Red.


No comments: