nortikin / sverchok

Sverchok
http://nortikin.github.io/sverchok/
GNU General Public License v3.0
2.21k stars 231 forks source link

SV Image Processing #1059

Closed enzyme69 closed 7 years ago

enzyme69 commented 7 years ago

For doing stuff like IMAGE PIXEL processing like Median Stacking, can Sverchok be hacked to do that with Image?

Just like Compositor?

I think it would be nice to SOURCE IMAGE > DO SOMETHING TO PIXEL > OUTPUT IMAGE.

Or IMAGE SAMPLING example.

Because 2D Image is like GRID, and I realized that under certain configuration, especially when working with Face Color via Vertex Color, it's like making image processing.

Kosvor2 commented 7 years ago

Here hack with v # command is used to apply entire list of values to object instead one by one:

image_mod

tested with only one image with very low amount of pixels.

Kosvor2 commented 7 years ago

Previous method changes the image from which pixels are taken. Here's a way to keep the original image such as it was:

image_mod2

That is, needed to create two images, share them with the filter node and changing the values of pixels of the first image, apply these values to the pixels of the second image.

enzyme69 commented 7 years ago

Thanks Kosvor for some examples to get me started!

I always wonder what Object ID can and cannot do --- together with MultiLines Exec or ScriptNode.

I will give this a try.

I was previously trying to use SV Vertex Color node. Maybe under 4 Megapixels (4 million ish faces) should still be possible.

If animating, maybe Dynamic Paint can bake out the Face Vertex Color. But don't know yet.

In one side, I think OSL and Blender Material Noding is probably a more suitable tool.

I'll investigate your example.

enzyme69 commented 7 years ago

The funny thing is that we can probably save vector positions of an object as image, and then if the image is sequence, it can be read in Unity or UE as "vertex displacement".

I remember one guy doing this using Houdini.

enzyme69 commented 7 years ago

From your method, I am using 35 x 25 pixels of emoji and the list I get is list of 3500 (35 x 25 x 4). I assume they represent RBGA (4 values)?

This is actually really interesting, but might be slow for big hires pixel image. But I can make video tutorial about it I guess.

screen shot 2016-12-27 at 22 34 00

🍩

enzyme69 commented 7 years ago

screen shot 2016-12-27 at 22 52 15

640 x 480 pixels are pretty fast, just few seconds to process :)

But 100 x 100 should be a good start. I remember DBN Program.

I can finally make Node Script that bend and move pixels, thanks for the tool~

enzyme69 commented 7 years ago

screen shot 2016-12-27 at 23 00 40

Any tips on handling RGBA? Should I use LIST ZIP?

enzyme69 commented 7 years ago

screen shot 2016-12-27 at 23 08 00

Finally we have SV Color Viewer. But it's RGBA. Need HSV mode, will use Script node.

enzyme69 commented 7 years ago

Just wondering, I plug in 40000 list of values into Object ID Set, but the output of Object ID Set is 4 x 40000 = 160000, any idea why?

enzyme69 commented 7 years ago

@zeffii any idea of previous Script node that deals with RGBA that I could study and implement here?

enzyme69 commented 7 years ago

I remember my old blog post... will attempt to convert to SN Lite DrawPixel and SN Lite Draw Pixel RGBA

http://blendersushi.blogspot.com.au/2013/03/python-pixel-art-in-blender.html

enzyme69 commented 7 years ago

screen shot 2016-12-28 at 12 54 02

This one is sampling texture back into the Pixel Generator. It's probably a bit stupid because I am using Blender's own Procedural Texture to create pixel.

I would like to study number pattern more. Somewhat it needs to meet half way.

enzyme69 commented 7 years ago

Using Sverchok or Python NumPy can be interesting though. PIL stuff.

enzyme69 commented 7 years ago

Basically want to use NumPy, but skipping PIL, but in something that Sverchok can work with.

enzyme69 commented 7 years ago

https://gist.github.com/bb2d12e8213ebe3ee744ca942817d20a

pixelstory_002

enzyme69 commented 7 years ago

Trying to think how to make a single white pixel just swim around...

enzyme69 commented 7 years ago

screen shot 2016-12-28 at 17 13 01 screen shot 2016-12-28 at 17 11 35 screen shot 2016-12-28 at 17 06 49 torusknot

zeffii commented 7 years ago

@zeffii any idea of previous Script node that deals with RGBA that I could study and implement here?

all scripts that read/write to blender image.pixels must deal with rgba, exercise some google fu.

zeffii commented 7 years ago

image i'd come up with something similar... mesh -> png

zeffii commented 7 years ago

image png -> mesh

enzyme69 commented 7 years ago

That's SVORGASMIC!! Will stare at them and study them for a bit.

enzyme69 commented 7 years ago

It's gone slightly off topic, but very well done 💃 thanks so much~

XYZ to RGBA https://gist.github.com/enzyme69/8e8284ed2f3fb2701ccfe455ffc73114

screen shot 2016-12-29 at 11 26 28

enzyme69 commented 7 years ago

screen shot 2016-12-29 at 11 46 09 screen shot 2016-12-29 at 11 46 04 screen shot 2016-12-29 at 11 46 01

The RGBA to XYZ seems to fail, but I learn something about the masking, super interesting...

https://gist.github.com/b9bbec8eb61583366cd2dc249551fbf5

enzyme69 commented 7 years ago

I do not get the last part....

screen shot 2016-12-29 at 11 48 19

enzyme69 commented 7 years ago

After the magic of tweaking and more careful observation of the recipe....

https://gist.github.com/9e3471a7590dd22b8d8e260d2323d977

This is a very good example of Sverchok :)

enzyme69 commented 7 years ago

@zeffii You also have some kind of Bounding Box and Centering mechanism. Very nice.

zeffii commented 7 years ago

that/my layout assumes the object's coordinates on any axis don't go beyond [-1.0 .... +1.0] hence it's OK to +1 -> / 2 . I imagine some interesting processing (hue, lightness... or jst in-painting) can be done to the bitmap to modify the resulting geometry..

enzyme69 commented 7 years ago

I realized that maybe I should study Processing and algorithm more which could help with what I am trying to pursue.

zeffii commented 7 years ago

just do it.