colorsample function

Hi 

I have been trying to use colorsample function to detect pixel color. The function works but I cannot put it inside a loop.

My intention is to plot an outline of an image using moore’s neighbourhood algo. I got it to work by using performWithdelay to replace recursiveness, but it is slow - limited to the frames per sec in config.

Is there another function without  “listener” as in colorsample? e.g. a display.pixelColor(x,y) and it returns the color in a table?

Thanks

Rgds

TH

Hi.

How interactive will this process be? If the outline is only needed visually, there might be acceptable alternatives, e.g. Laplacians or multi-passing on the Sobel filter. If you will be making the image dynamically, see memory bitmaps.

The color picker needs to pull data from the graphics card, which is generally an expensive process, as well as doing so at a consistent time, thus the delay. That said, glReadPixels() does take a rectangle, so maybe there’s a case to be made for a batched color sampler. Did you try sending several samples at a time, rather than one per frame?

I have a (paid) plugin coming up that will let you load files as their decoded bytes, e.g. see this load function. You could, of course, inspect these very bytes in the way you want. I’ve used them to play around with Philip Rideout’s msquares, for example.

Otherwise, if space isn’t an issue, and you don’t need to dynamically obtain images, you could always pre-decode the images into bytes and save the raw bytes somewhere. (I’ve got some stuff for that as well, though it’s atrociously slow for images of any size. But this matters less when it’s a one-time thing.)

Hi.

How interactive will this process be? If the outline is only needed visually, there might be acceptable alternatives, e.g. Laplacians or multi-passing on the Sobel filter. If you will be making the image dynamically, see memory bitmaps.

The color picker needs to pull data from the graphics card, which is generally an expensive process, as well as doing so at a consistent time, thus the delay. That said, glReadPixels() does take a rectangle, so maybe there’s a case to be made for a batched color sampler. Did you try sending several samples at a time, rather than one per frame?

I have a (paid) plugin coming up that will let you load files as their decoded bytes, e.g. see this load function. You could, of course, inspect these very bytes in the way you want. I’ve used them to play around with Philip Rideout’s msquares, for example.

Otherwise, if space isn’t an issue, and you don’t need to dynamically obtain images, you could always pre-decode the images into bytes and save the raw bytes somewhere. (I’ve got some stuff for that as well, though it’s atrociously slow for images of any size. But this matters less when it’s a one-time thing.)