Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/image import #291

Merged
merged 10 commits into from
Jul 1, 2024
Merged

Feature/image import #291

merged 10 commits into from
Jul 1, 2024

Conversation

bobnik
Copy link
Collaborator

@bobnik bobnik commented Jun 7, 2024

This is an alternative interpretation of the idea presented in #174, importing images as plotter lines. I used https://mitxela.com/plotterfun/ as the basis for the plotting. Images are loaded and stored as data URLs within the state (and are also exported in SDF files).

To import an image, select 'File, Import image...".

As you'll see, imported images require some fiddling to get looking okay. I'm going to test a few samples on my table to see if the defaults need adjusting, but please feel free to suggest values.

@jeffeb3
Copy link
Owner

jeffeb3 commented Jun 13, 2024

This is pretty fun and definitely a value add. I can't seem to get the sawtooth to work on the images I've tried. It looks like it maybe has a math error in it. I was mostly playing with high contrast images like this batman logo: https://i.pinimg.com/originals/1e/43/01/1e4301c5b23b4e54cf6b79743f8bf6a2.png

I tried an svg, but that wasn't supported. It seems like logos or cartoons would be ideal for this format.

The plotterfun seems to work much better and is much quicker. Why is that site so fast and ours is so slow? Would it make sense to push people into that site and then support importing svg line art instead? I'd like to fine tune the amplitude or contrast, but it takes so long to render, it just isn't worth it. We should probably add the delayed execution (like we do with the math operations) to make it not get stuck updating 5 times when you change the value by 0.1 increments 5 times.

I tried some photos with our family's faces, but that wasn't that interesting. Maybe it would look better if I plotted it. I would have to know which photo it was for me to be able to know who it was. I can imagine knowing it was a dog, but not which dog. Here is an example of Mr Beast, which should be pretty recognizable: https://firstsportz.com/wp-content/uploads/2022/11/Adobe_Express_20221105_1105500_1.jpg . That may be pretty hard to do when we are talking about line art.

The FM squiggles sometimes had funky spacing on pure white areas. But that may just be part of the math. It probably switches to zero frequency change and keeps whatever phase it was set to when it stopped. The AM only seems better in the preview, but I don't know how that will translate to the sand. Did you have any luck with that?

@bobnik
Copy link
Collaborator Author

bobnik commented Jun 13, 2024 via email

@jeffeb3
Copy link
Owner

jeffeb3 commented Jun 13, 2024

th-1201244194

Here is another picture type (landscape). From another image search for maroon bells.

I'm not expecting miracles with these. I am just trying to build a small suite of examples so we know what to expect (and I don't want to paste my family's face everywhere).

I am leaning towards building defaults that are better for logos than for images. The images just aren't that compelling to me, and I expect them to take a lot of tweaking to look right. But I expect a batman logo, or a brewery/bar logo to look good enough to be recognizable. Ideally without a lot of tweaking.

@bobnik
Copy link
Collaborator Author

bobnik commented Jun 14, 2024

I've tracked down and fixed two issues that resulted in an over-large canvas (performance) and out-of-bounds rendering. I'm still going to test out patterns on the table for tweak defaults as needed. But it's ready to play around with again...

image

@bobnik
Copy link
Collaborator Author

bobnik commented Jun 16, 2024

@jeffeb3 As mentioned, I think that the performance and rendering issues are fixed.

After drawing various images on the table, I've realized (as you did) that most images do not have enough contrast to produce interesting sand designs. The height of the ball as it moves through the sand on each line is too relatively large, and subtle "squiggles" are relatively small and get lost in the line and make a muddled mess.

Ideally, we would be able to infer what parts of the image are background noise and can be "clipped", allowing us to focus on patterns within the image. I have some vague ideas on how to approach this, so if it's ok with you, let's put this PR on hold for now and I'll circle back after some experimentation.

@bobnik bobnik mentioned this pull request Jun 16, 2024
@bobnik
Copy link
Collaborator Author

bobnik commented Jun 28, 2024

@jeffeb3 I'm done with my additional changes and think this is ready to merge, barring any issues you find. I've added a slider component, used by the image import for now, but I can see us using it in other shapes. In addition, there is a new "Brightness filter" option for some of the plotter types that filters out background. It works best when the background is solid. I think I could eventually get it working for all types, but I hit some snags and decided not to delay this PR any further.

image

@jeffeb3
Copy link
Owner

jeffeb3 commented Jul 1, 2024

I had some time to check this out today. It is looking really good. It's much faster for me, and the example images seem to do reasonable things. This is great.

@jeffeb3 jeffeb3 merged commit f02d0d4 into master Jul 1, 2024
2 checks passed
@jeffeb3 jeffeb3 deleted the feature/image-import branch July 1, 2024 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants