cindyli-13 / Drawing-With-Fourier

Drawing images with the Fourier transform!
7 stars 0 forks source link

ask for advice #1

Open zcdliuwei opened 3 years ago

zcdliuwei commented 3 years ago

Hello, I'm very interested in your work. What a wonderful display !! Personally, Fourier seems to imitate the process of human painting, and all the examples you show can be drawn with one stroke. I would like to ask if Fourier supports multiple strokes. Suppose there are two butterflies in the original PNG image, or there are multiple paths in my SVG file, I want to draw two butterflies with two strokes, because if one stroke is used, there will be a big jump between the two targets, And even if there is only one target or path, I also want to use multiple strokes in order to simplify and not cause a lot of jumping details, So in general, my question is how to control Fourier drawing so that it can support user-defined stroke number? I'm looking forward to your answer,Thank you very much。

cindyli-13 commented 3 years ago

Hi there, thanks for the comment and I appreciate your interest! I also find it really fascinating how the Fourier series can be so elegantly visualized in an artistic form.

The challenge of drawing images with multiple "strokes" was definitely something that I faced when designing the program. The idea I had with this project was to be able to draw any image, regardless of its composition. I do this by first extracting all the relevant contours in the image, then combining them into one giant contour which can be repeatedly traced out by a Fourier series. By "contour", I mean a closed-loop "stroke". This does mean that there will be "jumping" between contours, which you can clearly see the bot, Homer Simpson, and Joseph Fourier sample drawings in the readme.

A Fourier series will trace out a continuous path. To trace out multiple disconnected paths, you will either have to connect the paths together into one or generate a separate Fourier series for each path. The first option (which is the one I went with) will result in extra unwanted lines in places where one contour is bridging to the next. To get rid of these lines, the program will need to be modified to stop rendering when it's drawing the bridging parts, and only render when it's drawing the actual contours. Currently, this feature isn't implemented, but it is definitely something that could be looked into to improve the project. The second option will require more changes to be made to the code - each of the desired contours from the image would be treated as a separate Fourier series, so the result will be multiple independent Fourier drawings happening simultaneously.

Having a user-defined contour number would be trickier, since you would need to specify each individual contour you want to draw. The current program generates the contours for you, so there would have to be changes to the way contours are extracted to make it user-configurable.

I hope that answers your question, let me know if you have more!

zcdliuwei commented 3 years ago

Hi there, thanks for the comment and I appreciate your interest! I also find it really fascinating how the Fourier series can be so elegantly visualized in an artistic form.

The challenge of drawing images with multiple "strokes" was definitely something that I faced when designing the program. The idea I had with this project was to be able to draw any image, regardless of its composition. I do this by first extracting all the relevant contours in the image, then combining them into one giant contour which can be repeatedly traced out by a Fourier series. By "contour", I mean a closed-loop "stroke". This does mean that there will be "jumping" between contours, which you can clearly see the bot, Homer Simpson, and Joseph Fourier sample drawings in the readme.

A Fourier series will trace out a continuous path. To trace out multiple disconnected paths, you will either have to connect the paths together into one or generate a separate Fourier series for each path. The first option (which is the one I went with) will result in extra unwanted lines in places where one contour is bridging to the next. To get rid of these lines, the program will need to be modified to stop rendering when it's drawing the bridging parts, and only render when it's drawing the actual contours. Currently, this feature isn't implemented, but it is definitely something that could be looked into to improve the project. The second option will require more changes to be made to the code - each of the desired contours from the image would be treated as a separate Fourier series, so the result will be multiple independent Fourier drawings happening simultaneously.

Having a user-defined contour number would be trickier, since you would need to specify each individual contour you want to draw. The current program generates the contours for you, so there would have to be changes to the way contours are extracted to make it user-configurable.

I hope that answers your question, let me know if you have more!

Hello, I'm so excited to see your timely and useful reply. I am a deep learning practitioner from Hangzhou, China. At present, I work for a company dedicated to artificial intelligence and design.

What I want to do now is like this: first upload an original PNG image, we need to generate a logo and deliver it to customers. In order to avoid possible copyright problems from the source and make the whole painting process simpler, I want to simplify the image by using the Canny algorithm of OpenCV, and then detect all the contours in the image, a Fourier series is generated for each contour to draw, so like your reply, need to modified the program to stop rendering when it's drawing the bridging parts, and only render when it's drawing the actual contours, I want to konw how to modified your code ?

Taking the drawing of bot in readme as an example, I think that the two eyes should be drawn separately. In addition, the two larger outlines on the outside should be added. So if four brushes are used, those invalid details can be eliminated, and the final result is closer to the logo, because the logo design itself should be concise and beautiful. In order to achieve the above effects, what efforts do I need to make? I look forward to your suggestions

Because this matter is very important to me, I will describe my request in detail as far as possible. I hope to get your reply. Thank you again

cindyli-13 commented 3 years ago

Hi, I took a closer look at the code and I think that the option I stated previously about not rendering the bridging parts is actually much harder to implement than I originally thought... Since the operating principle of the Fourier transform is to convert the time-domain x, y coordinates of the contour into the frequency domain, the unwanted segments of the contour would get encoded into the frequency parameters. So I can't think of an easy way to retrieve the exact times that the Fourier series would be drawing the unwanted versus the wanted lines.

If you really want to draw multiple separate contours, I suggest splitting the drawing into separate independent Fourier series, one for each contour. Sorry that I can't give you the exact instructions on what to do with the code - I would have to take more time to look at it and play around with it again.

Also, it seems like you are looking to use my code for commercial purposes, is that right? Since this repo is unlicensed, I'm not sure if there would be copyright concerns depending on how it's used. Could you tell me more about how you plan on using this code?

Thanks and have a nice day

zcdliuwei commented 3 years ago

Hello, I pay attention to your code because I want to try to see if I can get beneficial results through Fourier drawing recently. The first problem is how to use multiple strokes and stop rendering unnecessary lines, and the second is how to write the results to SVG. At present, it's just an idea, and it doesn't involve commercial use. If it's really used for business, I'll definitely get your approval first。Because it's just an assumption, I haven't studied your code carefully. Just thinking about the feasibility of this idea。

I should like to ask you more about Fourier. I hope we can have more discussions,Thanks again. Good luck

cindyli-13 commented 3 years ago

Ok I see, that's understandable, thanks for clarifying. I'm definitely open to more discussions - just let me know what else you wanted to ask about.

zcdliuwei commented 3 years ago

OK, thank you. I'll study your code carefully in the next few days, and I'll consult you if I have any questions, have a nice day