Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Test] Can Stata read colors aloud?

    What would "Hello, Stata!" look like as a picture?
    Click image for larger version

Name:	hello_stata.png
Views:	1
Size:	965 Bytes
ID:	1787695


    The attached PNG stores 13 text bytes as grayscale tiles, with RGB=(b,b,b) for each byte b. An experimental user-written command, pngread, reads the pixels entirely in Stata/Mata. A short example recovers the greeting and saves it as text. This is an encoding experiment, not OCR.

    Source, help, and examples: Speak-Read-Write-Listening-Stata on GitHub.

    In a scratch folder and session, try the following. The example replaces data in memory and writes hello_stata_decoded.txt.

    Code:
    local source "https://raw.githubusercontent.com/renegade68/Speak-Read-Write-Listening-Stata/main"
    net install pngread, from("`source'")
    net get pngread, from("`source'")
    do read_hello_stata.do
    Expected text:

    Code:
    Hello, Stata!
    Optional speech on macOS, using the recovered file:

    Code:
    shell /usr/bin/say -f "hello_stata_decoded.txt"
    To create the picture yourself, run do make_hello_stata.do. PNG reading uses only Stata/Mata; speech uses the macOS speech service. Tested with Stata/MP 16.1 on macOS. The reader currently supports 8-bit, noninterlaced PNGs; other systems are not yet validated.

    The package includes the original PNG. To test the forum attachment itself, save it as hello_stata.png in the current folder before running the example; that local file takes priority. Keep the original 624 x 160 pixels: no resizing or screenshot.

    Does it recover the greeting on your system? Please mention your Stata version and operating system if you try it.
    Last edited by Choonjoo Lee; 24 Oct 2026, 00:49.

  • #2
    Can two Stata sessions talk through grayscale pictures?

    Following the color-to-text experiment, I have added a small PNG request/reply example. Stata A writes a grayscale PNG, Stata B reads it and writes a reply PNG, and A reads the reply. Both sessions keep their own data. This uses Stata/Mata only, with a defined message format rather than OCR or AI.

    Source, help, and examples: Speak-Read-Write-Listening-Stata. Tested with Stata/MP 16.1 on macOS only.

    In each of two independent Stata sessions, use a scratch working folder and install the examples:

    Code:
    local source "https://raw.githubusercontent.com/renegade68/Speak-Read-Write-Listening-Stata/main"
    net install pngread, from("`source'") replace
    net get pngread, from("`source'")
    Choose the same new shared-folder path in both sessions (its parent must exist). Start B first:

    Code:
    do pngmessage_demo.do B "/your/path/exchange_01"
    Then start A within 60 seconds:

    Code:
    do pngmessage_demo.do A "/your/path/exchange_01"
    Expected exchanges include PING 417 -> PONG 417, SUM 2 3 -> RESULT 5, SUM 10 -4 -> RESULT 6, and NOBS -> the observation count in B. An invalid SUM request returns an error PNG. The shared folder contains ten PNGs and no communication text files.

    Use a new folder for another run: existing outputs are not overwritten. This is a short-message prototype (up to 1024 UTF-8 bytes), not a general conversation engine or network service. Please use the original PNG files without resizing or screenshots.

    Do the two sessions exchange the expected replies on your system? Please include your operating system and Stata version when reporting a result.

    Comment


    • #3
      Hello—or Jello, Stata?

      I made the first tile just two gray levels lighter: RGB(72,72,72) became RGB(74,74,74). In this encoding, that changes H to J. All pixels outside the first tile remain unchanged.
      Click image for larger version

Name:	jello.png
Views:	1
Size:	965 Bytes
ID:	1787699

      To try it, save the attached original PNG as jello.png in your working folder. Please do not resize it or use a screenshot.

      Run the following in a scratch Stata session; it replaces the data in memory. The net install line installs or updates the user-written reader.

      Code:
      version 16.1
      local source "https://raw.githubusercontent.com/renegade68/Speak-Read-Write-Listening-Stata/main"
      net install pngread, from("`source'") replace
      
      pngread using "jello.png", clear
      assert r(width)==624 & r(height)==160
      assert r(has_icc)==0 & r(has_srgb)==1
      
      keep if y==80 & mod(x,48)==24
      sort x
      assert _N==13 & red==green & green==blue & alpha==255
      
      mata: st_strscalar("decoded",char(st_data(.,"red")'))
      display as result decoded
      assert decoded=="Jello, Stata!"
      Expected text:

      Code:
      Jello, Stata!
      This is a byte-encoding experiment: each grayscale tile represents one byte. Tested with Stata/MP 16.1 on macOS.

      One tile, two gray levels—and suddenly we have dessert.

      Comment

      Working...
      X