photoshop paint bucket
Does anyone know how to fill a custom shape made in lcd (or jit.lcd) with full color?
Is there a paint pot feature somewhere or at least a way to do it …?
But I use photoshop. its coool.
wow, that would be cool… and I’m thinking pretty tough. maybe you could do a hack like this:
1–start where you click, and assume you’re inside the shape.
2–get the color where you are, and assume the color is the same everywhere in the shape. change the pixel to the desired new color.
3–go left (- pixels in X direction) and repeat until you hit another color, and assume that’s the shape edge. stop.
4–go right (+ pixels in X direction, from original point, do similar change until the other edge. stop.
5–go up one pixel and repeat everything, until another edge. then repeat going down. however, this won’t work all the way unless you’re in the middle of the shape, argh.
Probably there is a much more savvy trick using better edge detection techniques. But this might provide some interesting results, even if it doesn’t always work perfectly. Example: if the shape is mostly closed, but not all the way, will it spill out? With this technique it would, but only in the direction of the break. Etc…
An interesting challenge regardless. Just trying to make something hacked together for it should yield some new tools and insights. Using jit.lcd is probably better, so you can take advantage of the matrix operations. Maybe there’s a combination of several jit.ops which will do most of what you want.
A flood fill algorithm isn’t too hard to build, but i’m not sure how to do the recursion in Max. It’ll probably generate a stack overflow relatively quickly if you do it with Max-objects, but maybe in Java?
This will fill a space (and go around corners too and spill) and stop when it reaches pixels with a different color. Anyone feel like getting this into Max? Hehe.
Edit: you could probably build a stack of pixels to be updated in Max as well and pop items to avoid recursion.
floodfill(x, y, selectedcolor, newcolor)
if (kleur(x, y) == selectedcolor) // insert threshold here
changecolor(x, y, newcolor) //function that sets new color
floodfill(x, y + 1, selectedcolor, newcolor)
floodfill(x, y – 1, selectedcolor, newcolor)
floodfill(x + 1, y, selectedcolor, newcolor)
floodfill(x – 1, y, selectedcolor, newcolor)
The recursion/stack overflow might not be an issue, as long as you have a comparison operator for each new pixel tested, and you also stop the recursion if X or Y coordinates go below 0 or above your maximum (dimensions of the LCD or whatever you’re using). A [trigger b b b b] where each of the bangs deals with the X+1, X-1, Y+1, Y-1 respectively, and probably a [defer] before the recursion in each. Though I don’t know if the [defer] or a [deferlow] would allow the other trigger bangs to fire before the recursion is done?
By comparison operator, do you mean a boolean per pixel that says whether it’s triggered? You don’t need that, when a pixel is tested that’s already colored it will not have the original color, and will not add new pixels to the ‘stack’, and the code will continue to the next pixel.
And you’re correct about the edges, of course. I’m a little bit scared of using [deferlow] and [defer] in cases like this, but in theory it doesn’t matter in what order pixels are handled, as long as every item is processed. So you could theoretically use the thread as a stack, but I don’t know how long the stack can be (theorically it could reach 4 * amount of pixels in the image). May be a better idea to build a separate stack?
so I suppose dilate and erode and morphology objects would be of any use in that case.
As the jit.conway object …
Also the xray data process objects can probably do something here.
I’m just starting with OOP, but I understand that it would be easy to do it in JS.
So many thanks, I will investigate further and come back here if I get clever results.
Did you know this cv.jit.floodfill?
Forums > Jitter