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.
image processing
Re: image processing
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-
Happy image processing !
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
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
Re: image processing
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:
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...)
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);
})