image processing

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE

image processing

Postby 0x69 » Sun Jul 25, 2010 9:33 am

Hi,

I want to manipulate individual pixels of image - is it possible in newLISP ?
That is, I want to get RGB values of each pixel and change these values by my needs.
[If such functionality isn't there - maybe newLISP can be extended to support that ? If so - when ? :) ]

Thanks for answer.
0x69
 
Posts: 3
Joined: Sun Jul 25, 2010 9:27 am

Re: image processing

Postby 0x69 » Sun Jul 25, 2010 1:09 pm

As for now -I found workarround - read,modify & save PPM image file. It's trivial to work with PPM images, because format is very simple, kinda-
Code: Select all
P3
# The P3 means colors are in ASCII, then 3 x 2 image size, then 255 for max color, then RGB triplets
3 2
255
255   0   0     0 255   0     0   0 255
255 255   0   255 255 255     0   0   0

Happy image processing !
0x69
 
Posts: 3
Joined: Sun Jul 25, 2010 9:27 am

Re: image processing

Postby cormullion » Sun Jul 25, 2010 5:03 pm

I don't think you can do it newLISP-GS.

You can (sort of) do it with HTML5 canvas, although this involves so much intermediate JavaScript as to be depressingly slow. The relevant bits of the code I hacked together are:

Code: Select all
(write-buffer page [text]
<script type="text/javascript" language="javascript" charset="utf-8">
    var a_canvas = document.getElementById("a");
    var a_context = a_canvas.getContext("2d");
    var input = a_context.getImageData(0, 0, a_canvas.width, a_canvas.height);
    var output = a_context.createImageData(a_canvas.width, a_canvas.height);
    var w = input.width, h = input.height;
    var inputData = input.data;
    var oD = output.data;
[/text])

; set pixel c to colour (where colour is RGB list eg  (0 0 0)):
(write-buffer page
   (string
        "oD[" c "] = "         (first colour) ";\n"
        "oD[" (+ c 1) "] = " (colour 1) ";\n"
        "oD[" (+ c 2) "] = " (colour 2) ";\n"
        "oD[" (+ c 3) "] = " 200 ";\n")

; and to output the array
(write-buffer page {
   a_context.putImageData(output, 0, 0);
  })


Have you seen onographic - here's my Mandelbrot attempt http://www.dmemos.de/onographic/contributions.htm with a version of didi's code. (I used a PPM to PNG converter, since PPM files aren't that useful...)
cormullion
 
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W


Return to newLISP Graphics & Sound

Who is online

Users browsing this forum: No registered users and 1 guest