continuation of Write a program in your language of choice that does the following:
- load an image (source image) - get a list of all the colors in the source image - create 2 blank images (image1 and image2) - draw a random polygon or circle on image1 using a random color from source image - compare image1 to the source image - if it's closer in color to the source image than image2, copy image1 to image2; if not, copy image2 to image1 and continue drawing more random shapes and comparing - post the results and bits of code
Are you retarded? We've been playing around with this for a couple of days already
Jonathan Torres
Fuck off back to Sup Forums.
David Adams
proof of the pathetic state of this board fucking mods need to start doing their job
Landon Diaz
>technology board >thread about having some fun programming >proof of the pathetic state of this board What did he mean by this?
Benjamin Foster
Don't feed him, he's fishing for (You)s out of desperation. Someone run the program on a screenshot of his post.
Ethan Lopez
Fuck off nodev.
Jaxson King
What do you guys use for comparing the images?
Zachary Brooks
How long before your assignment is due? I'm getting sick of these threads.
Michael Nelson
I've read about euclidean and manhattan distance but I'm too much of a brainlet to implement that.
Carson Jones
I'm barely getitng it to draw a line right now, will worry about comparison when I get that far
Xavier Green
why? euclidean distance is simple sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2) and manhattan distance is even simpler
abs(x2 - x1) + abs(y2 - y1) + abs(z2 - z1)
Kayden Jones
Here's my latest. It uses circles of decreasing size until a minimum, at which point it switches to lines.
Ethan Powell
I have a bunch of code that should do something but doesn't do anything, any suggestions on where I fucked up? private void showButton_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { int Width = Image.FromFile(openFileDialog1.FileName).Width; int Height = Image.FromFile(openFileDialog1.FileName).Height; int x = 0; int y = 0; List srcColors = new List(); using (Bitmap srcPic = new Bitmap(openFileDialog1.FileName)) { if (x < Width && y < Height == true) { Color srcColor = srcPic.GetPixel(x, y); srcColors.Add(srcColor); x++; y++; } }; Bitmap Output = new Bitmap(Width, Height); Random rnd = new Random(); for (int i = 0; i < iterationsController.Value; i++) //iterationsController is a different control (one of those NumericUpDown controls) { int x0 = rnd.Next(0, Output.Width); int y0 = rnd.Next(0, Output.Height); int x1 = rnd.Next(0, Output.Width); int y1 = rnd.Next(0, Output.Height); int clr = rnd.Next(0, srcColors.Count); Color rndColor = srcColors[clr];
Turns out I implemented the manhattan one without knowing of its existence, kek. Shouldn't have skipped math.
Jaxson Brown
jesus christ I was excited when the first of these posts appeared because I thought now new threads with challenges will start to pop up, but now you retards are just reopening the same thread again and again
Aaron Lee
It's because some of us completely suck and can't keep up, but hey you could make a new thread with another challenge.
Alternatively, when I finally get this working I'll definitely make a different thread. I'm very new to programming so it might take some hours tho
Anthony Hill
Exactly, anyone has any ideas for something new?
Lucas Brooks
Then post new challenges, the 'do your own homework' fags will be around, but the fun people will be too
Ian Collins
Maybe something with neural networks? An evolution simulator? Seen a few videos and those seem fun.
Easton Morales
can confirm, I made a flappy bird clone in Lua and made a neural net that played it, was a lot of fun to do
Noah Bailey
Neural nets seem hard to get into, a lot of people on this board (including me) might struggle with that
Elijah Rogers
yeah maybe I got ahead of myself, I thought that with all the tutorials in youtube getting into it shouldn't be too hard but thinking more about it it does seem awfully complicated
Levi Hall
Conway's game of life is some what easy to implement if anyone wants an easier challenge.
Justin Jones
> Having fun is not allowed
Ryan Jones
>- load an image (source image) Constrain this requirement. There is shitload of difference between the file formats.
Evan Harris
that's fair >the 'do your own homework' fags will be around not if op posts his own code/proof that he got it working
Hunter Torres
Nice. Repo where?
Evan Bailey
Now do it in the house and shapes like stars and decagons
Joseph Ortiz
Can someone please make one that's better than tux3/evolve
I need to vectorize images, my screens are high res.
Hudson Cook
show me an image with alpha in it too!
Isaiah James
I tried creating random triangles and comparing the images root-mean square.
Any chance you could get it working with non-isosceles triangles?
Grayson Brooks
This looks nice, any chance of limiting the random positions to a grid? Like randPos = randPos - (randPos % 32);?
I'm gonna give this a shot later tonight.
Elijah Ortiz
anyone got any ideas?
Aaron Davis
This sounds fun, I'll see if I can get it to work using JS.
Don't listen to the 'do your homework' faggots.
Tyler Long
>new to programming >using python >made it to the part where I create another image and shape filled with random color from og pic Not sure how to continue
Sum of squared differences, treating per-pixel R, G, and B channels as separate differences.
Jaxon Carter
Advantages include alpha channel being a trivial extension, and it's possible to weight different channels separately so you can have an image converge in the green before blue, for example.
Jose Stewart
I'm in a similar position but working with Visual C#, got code that should be drawing random shit but nothing is showing up
any ideas?
Kayden Ward
It works with any kind of random shapes.
Carson Reyes
I just this 1000 iters of triangles with random angle and shape but no size and it took 181 seconds. So unless anyone wants to share code I give up on them with Python.
Austin Rivera
Wait a fucking second. My CPU must have been fapping. Now 10000 iters in 205. Very strange.
Oliver Myers
Just check out previous thread
Easton Green
Meant for
Carson Carter
no bad at all.
Robert Wood
Late to the party. Using Java.
100M iterations, random lines between 3 and 20 pixels in length.
Carter Gonzalez
it is possible to do a second sub sampling within the line, so half of it matches more accurately, resulting in a better picture. I'll work on something when I get home from work, this project seems fun.
Eli Garcia
20k iterations took 323 seconds
Carson Cruz
20000 iters in my laptop in about 15 minutes, i3 on 1.6 ghz:
I just checked. Spot on. Saves a lot on the Euclidean distance. Amazing that an interpreted language does not optimize this shit automatically. Also implemented rectangles at an angle too.
Zachary Peterson
those gifs are cool but please give some more time for the last frame to show?
Brayden Campbell
Sorry I am cutting them short as I am not letting the full program to end while testing. I will refrain from posting unfinished ones.
Matthew James
>if it's closer in color to the source image than image2, copy image1 to image2; if not, copy image2 to image1 and continue drawing more random shapes and comparing
>tfw retarded and technically completed the task by comparing histograms
In hindsight, I don't know why I thought that would work lmao
Tyler Cox
Hacked something together quick in C++ and it takes about one and a half minutes to do one hundred million iterations with these random rectangles.
Jordan Bennett
bump
Daniel Rogers
Wtf is this real
Eli Lopez
>one and a half minutes to do one hundred million iterations
HOW
Ryder Hughes
...
Liam Walker
Holy shit, thanks man I also tried with abs() and it seems to be even a bit faster (only a bit it's still better than nothing)
Any tips on an efficient line computation?
Brandon Lee
Mad this with c++, took me arround a day to Write the code. Takes a couple of minutes for 10M iterations. Should be able to optimize a lot and use different shapes.
What image format are you guys using? I'm using .ppm because I wanted to use this to write a reader and writer for ppm
Xavier Nguyen
Bresenham's Line Algorithm Xiaolin Wu's line algorithm
Gabriel Rodriguez
Thanks for the pic, I added it to my collection!
Looks like Terminator arm inspired artificial muscles.
Kayden Roberts
...
Nathaniel Sanders
10M iterations took about 70s using java
Ethan Fisher
I'm new to programming and I am using python with PIL. I'm getting only about 1 iteration for ever 3 seconds what am I doing wrong?
William Roberts
pretty fucking good user
Lucas Collins
post your code
Isaiah Miller
im giving up
Justin Martinez
You're probably testing the entire image when you should only be testing the pixels you drew on.
Colton Thomas
not him but hardstuck at comparison too
can you explain what should I actually look for and why do we need img2
Noah Butler
You don't "need" img2. I would wager the fastest implementations don't have img2. It's included in the original formulation of the problem to make it easier to understand it. img2 is the backup of the image before you added the object (circle, polygon etc) to img1. If the adding of the shape didn't make it more similar to the target image, we restore the backup from img2. If img1 is closer, we copy img1 to img2 in order to update the backup image.
How does the comparison work? Just loop through the entire image and over RGB and add the absolute value (or use any other more suitable norm) of the difference between the target image pixel value and the comparison image pixel value to an accumulator variable. If you compare two images, you'll get two accumulator variables, and the smallest of them represents the most similar image.
Now, if you want to make it faster, you'll need to restrict the area that you compare. Since you're adding an object to an existing image, you only need to compare that specific area, since the rest is the same on both images.
Samuel Murphy
im going to test a slightly new approach to hopefully make the reuslting image more like a sketch my idea is to limit the line length depending on the density of regional detail currently doing canny edge detection and calculating and average over a small region and using threshholding to mark as a detailed region i'd like to do something like the hevc segmenting where more bits are allocated to higher detail areas will also look into adding constraints on line direction dependent on the direction of edges within a region
anyone have any ideas how to best get a measure of detail for a region? first order derivative of each color space and threshhold according to amount of 0s? second order derivate?
>You don't "need" img2 no and you dont have to iterate throught the entire image either you just have to compare the color of the line to be drawn with the appropriate space for the line on the source image image processing libraries might have an implementation for line iteration (e.g. cv::LineIterator in OpenCV) or use y=kx+m to do it with rounding conversion of the calculated coordinates
see my implementation if your interested gitgud.io/sachiko/g-chan-random-lines it performs reasonably well, it does 1m iterations in about 3 sec on a 6200u (compiled with -Ofast)
Hunter James
Dunno why its not doing anything, but shouldnt this >(x < Width && y < Height == true)
work with >(x < Width && y < Height) alone. Also, when making new random, its better to have a seed, if the program runs through the new Random() too fast. By default the seed is based on the clock(changes every one second or something?), so if the function gets called too often, the numbers wont change. Better to call the function with some randomized seed, high precision counter(can't remember the name, but google will help) or something which changes with each clock cycle.
Angel Stewart
Just to add to that, not "randomized" seed or anything, but something which changes more often than the functions default-seed. Theres some different ways to do that, but not really sure which would be the best one. Just saying in case someone else runs to the same problem i ran into before. Had to make a randomized database, which ended up not being so random as the function got called too often.
Zachary Martin
>it does 1m iterations in about 3 sec i should extend on this the speed depends very much on the maximum length of the line, 3s is with the default of min(source.rows, source.cols) / 12 with length set to 10px it does 10m iterations in about 8s
Christian Hernandez
...
Juan White
Might be good to check if the iterationscontroller.Value is correct, might explain something if the for-loop doesnt do anything.
Benjamin Rogers
An excellent challenge thread with no sign whatsoever of the O(n) faggot. Maybe Sup Forums is not dead after all
Elijah Adams
I tried just putting an int there but it still did nothing
Bentley Fisher
thanks for the tips, I'm still trying to get it to work but I think I might be doing some progress
Ryder Martin
10M iterations in 22s in scala
Josiah Jackson
cute
Owen Brooks
Still 10M iterations, but using circles, took 644s
Jace Price
Damn... even at a length of 10pixel it takes 30 seconds to do 10m iterations... How do you access all the Data that efficiently? I'm currently making a copy of the lines from the source image and the new image and then comparing them seperatly, but the copy process still takes up 50% of my compute time...
Dylan Thompson
This loop crashes the program, what do Bitmap srcPic = new Bitmap(openFileDialog1.FileName); int x = 0; int y = 0; List srcColors = new List(); for (x = 0; x < srcPic.Width; x++) { for (y = 0; y < srcPic.Height; y++) { Color srcColor = srcPic.GetPixel(x, y); if (srcColors.Contains(srcColor) != true) { srcColors.Add(srcColor); }
Not very pretty but basically it just compares the rectangle that gets replaced and not the whole image. It compares them in about the same way as what did.
I was thinking it could probably be made faster with AVX but what I wrote quickly which is dead simple and just does it one byte at a time seems pretty fast.