alyyousuf7 / Weaver

Weaving algorithm based on work by Petros Vrellis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Color variant support

alyyousuf7 opened this issue · comments

Many people have requested color variant support on Weaver.

https://www.saatchiart.com/art/New-Media-Color-knit-5-Limited-Edition-of-4/858823/6200223/view

Let's discuss here the possible solution to the issue.

Some of the discussion are in #1, and from now on we'll be using this issue to follow up.

[Update]
You can create color variant output using Example03 code in the master branch. You have to choose the colors very meticulously. It can be a real pain to choose correct colors.
Keeping the issue opened until we find a better approach to automatically pick colors. [I hope that's possible]

I also think so, multiple colors follow the smooth, but how does this color distinguish?

Oh wow @Panda0003, I’m getting many notifications. Can you please compile a complete message and then send?

And yes, we need to separate out colors from an image, let’s say 4 colors: Black, Blue, Yellow, Red. (These colors are used in the link mentioned in the top comment)

Then we use the same strategy to detect weave pattern for individual colors and overlay individual colors on top of each other.

This is what I have got so far:
Screenshot 2019-09-26 at 7 54 27 pm

The result on the left can improve ALOT! This is just my first attempt at setting the correct colors, I got so excited to share the work-in-progress!

Right now, I'm manually separating out colors from the original image using Photoshop and saving it into 4 new images, and then running the same algorithm on all 4 images one by one.

It contains 2000 lines for each color, making it 8000 lines.

Wow, it’s great.
The first time can be so good
If you can be clearer, it will be even better.
I think the image you are looking for contains as few colors as possible.
This is better to separate.
And can make the image more vivid

I have completely rewritten the code to allow many more improvements. Previously, the code was pretty procedural, now i have broken things down to follow OOP.

I'll merge the code once I clean up the rest of the code.

@Panda0003, the explanation is in the README.md.

I have pushed a basic support for multiple colors.

It won't work for all images out of the box. Check example03().

You'll have to tweak with the following parameters to get the perfect result:

  • Color of each thread
  • Number of lines for each thread color
  • Order of color threads
  • Input image size (small images require lesser number of lines of threads)

At this point, we have reached to the following result with Lenna image:

Wow
Great
In which file the complete code is located
What are the parameters that need to be modified?
Do you need to process photos before running?

Just run the application as usual.

I have updated the README with new instructions.

And no, you don’t need to process images before. But there is capability to process it manually if you want to and give it to the software.

I understand that this tool right now requires basic programming skills to play with it.

This is excellent! Apparently I don't look at my github notifications enough. I'll do a full look through the code when I'm able.

Hi
Great job
Hope it improves

@alyyousuf7 Hi ! I was wondering, is there any way to pick up the color sequence from the last knit ? What I mean is, for example: I start by weaving the black lines, then the white ones, and then the yellow ones, then I want to continue with the black ones, continuing from the last knitted point.

Yes, you can change the order of color from example.pde where they are defined.

@alyyousuf7 Yes, i already did it, but the code starts again by overlapping the black lines with the previous ones, I wonder if it is possible instead to continue with the sequence of black lines from the last previous point knitted. You know what I mean?

@Enomis9339, it always starts the new color from point zero.

It shouldn't matter much because usually the number of lines of each color is so high.
If you add an extra line from the last point of previous color to the first point of next color, it won't make a difference.

@alyyousuf7 What I mean is that, in my opinion, it has reached a satisfactory result if the layers of a single color could alternate with the others continuously.
For example, if you used a black and white image with 1000 lines for each color.
I would get two layers of 1000 lines each, but in my opinion you could get a result more faithful to the original image if you divide a single layer of 1000 lines into multiple layers.
Example:
50 black lines
50 white lines
50 black lines
50 white lines
and so on ... up to 1000 for each level.
Feel free to write me if my idea is not clear enough.

Oh, you mean that we alternate the colors after every few lines to get a better result. Is that what you mean?

@alyyousuf7 Exactly! the ideal would be to superimpose one line at a time the different colors, but this in reality would take an absurd time, so why not try to change color only after a series of lines to be defined? Reduce the time of realization and also the error.

It's a great idea and might get us better results!

I'll try to work on it (i'm quite busy these days though). I'm not sure if that's possible with the current implementation, it will need a bit tweaking to support a layer continuing from middle.

@Enomis9339, I was thinking about the solution, and I think there will be some minor issues.

For example, when you define each color with the number of lines, those numbers represents the maximum number of lines for that color, that means it’s not necessary that each color has same number of lines, each color may have less number of lines than other color.

So at one point, superimposing will stop working.

Nevertheless, it looks like that it will give better result.

And I think it can be done with minor changes. We just need to change the logic to draw lines in different order.

@alyyousuf7 You got it right:)
For example in the file published by i-make robot, I have changed the parameters several times making different attempts to get an image as much faithful to the original.

It is logical that there will be more lines of one color than another, It all depends on how much color is present in the image of course.

So if we could create in the program the change I proposed, then it might be possible, by trying, to find the right number of lines of a color that leads to the best result.

@alyyousuf7 I was still thinking about the logic we could use to get the desired result.

I was wondering if it is better to:

  • Insert a new interaction in the "WeaveConfig" TAB, for example immediately after the number of lines "((int lines, ..... ,int jump lines, etc...))" ,which defines the number of lines to be drawn per layer.

  • Or:
    "new WeaveConfig (100 ,0, 50, color (color (0, 0, 0), 20)),
    new WeaveConfig (10 , 0, 35, color (color (255, 255, 255), 20)),
    new WeaveConfig (50 , 0, 50, color (color (0, 0, 0), 20)),
    ...and continue "

Insert multiple layers as above, but make sure that next layer of the same color starts from the last point to which the line of the previous layer of the same color was connected.
In this last case, each layer, even of the same color, could be composed of more or less lines.

I don't know which one is more logical and easy to do.

If you look at the implementation of MultipleImageLayer class, it takes n images and n configs. If we modify it to accept pointer of images (instead of images), we can make it work to use the same old layer images for newer layer configs.

Suppose we have 3 colors to weave with, red, green, and blue. But we want to repeat the layer again, so we might have 6 or 9 or 12 configs (multiple of the number of colors). We can create a function similar to “createColorLayer”, which will instead of mapping one config with one image, we will map multiple configs for a single image, and repeat this for each color. (Look at the last line of the createColorLayer function)

What this will do is, suppose if in the first configs, the color is red, it will draw 50 lines for it, and then move on to the next color. But on the 4th config, the color will be red again, but instead of the initial image for red, it will have the images on which the first config had already worked on* (due to pointer to the same PImage).

*This requires you to understand that the original algorithm actually works by “subtracting” the color line by line.

I’ve tried to explain my best, but I’m sure you might not understand completely. Feel free to question.

I admit I have not fully understood, unfortunately my processing knowledge is limited to the basic tutorials that I followed on the internet. However, I continue to be convinced that this logic could lead to a better result.

@alyyousuf7
I think Enomis9339 is right!
It's a right idea and might get the better results!
I have done some work as Enomis9339's idea. The result is so good!

100 lines back
100 lines red
100 lines yellow
100 lines white
100 lines back
100 lines red
100 lines yellow
100 lines white
...
...
and go on...

100 lines each layer just so good!

Later I'll upload my handle image

@alyyousuf7
I think Enomis9339 is right!
It's a right idea and might get the better results!
I have done some work as Enomis9339's idea. The result is so good!

100 lines back
100 lines red
100 lines yellow
100 lines white
100 lines back
100 lines red
100 lines yellow
100 lines white
...
...
and go on...

100 lines each layer just so good!

Later I'll upload my handle image

I can't wait to see the result :D

Monalisa
It's 400 lines each layer.

Have you edited the previous code posted by @alyyousuf7 ?
I really think that you're near a good result :)

Monalisa
It's 400 lines each layer.

@kitor7, I'd also like to see the screenshot of what the simulation showed you. That's how I judge that what it might look like in real life.

@khuongtrung936, please choose the input image with higher resolution.

Can you create a new ticket for that please?

could you optimize rgb version

I admit I have not fully understood, unfortunately my processing knowledge is limited to the basic tutorials that I followed on the internet. However, I continue to be convinced that this logic could lead to a better result.

Could you code your idea?

hi. how to change image in code? in folder are black,red,blue,yellow. is this is a color chanels? or what is it. how to replace this images?