Share your repls and programming experiences

← Back to all posts
Edge detection
Codemonkey51 (1057)

So I have seen edge detection all the time it's amazing right, recited to make shape detection. And I always wanted to make it so here we are. (I think it took 6+ hours to make)

Input (credit @eekboi )






This was almost 100% made by me (the color diff function I found online) to use it 1) fork then add your image and name it 'in' then in the code make in.jpeg(or .png) to simple.(ur extension) then change the scale on line 14 enjoy. Also the higher the hardness var (line 15) the cleaner the image (less bad lines) but also less good lines

PS I'll fill in the ???'s when I post this
PPS the higher the scale lower quality so scale of 2 is 1/2 scale
PPPS output is out.png

How it works:
first it takes an image and turns it into a numpy array (it's like a list of lists).

then I go through teach element in that array (which are all lists) and for each I go through all the elements in that array

and for each element I check if it a different color than the same element for the array before, if it is I add the rgb code (diff is the diff minus an offset) (diff,diff,diff) to that pixel in a new array

next I flip that array, and the base image and repeat that scan but this time only adding the pixel if the diff is bigger than the one the first scan provided

finally I convert that into an image and save it to a file

so it would look like if each step was a function:


How I built it:
So one day I was just thinking oh if you just detect darkness change then edge detection should be so easy, so then the next day I made that it just went row by row on the pixels, I realized I would need to do this 4 times top down, left right, down top, right left.

Then someone suggested color change instead, that would make it only 2 scans, one vertically, and one horizontally, I then would mix the two outputs together, that worked but not well since it took a lot of time to do both and merge.

So the final iteration I made it flip the existing array and if the difference was higher then the current one it would overwrite it, this made it much easier as now there was 1 clean output file and no combination.

I really enjoyed making this project and I hope you enjoy using it

DynamicSquid (4932)

The coolest thing about this project is that the loading messages aren't fake.

Also good work with this!

DavidShen2 (60)

Amazing! Also, isn't this just Canny Edge Detection does?

Codemonkey51 (1057)

i dont know, but ill go check out what Canny Edge Detection is @DavidShen2

Kookiez (400)

This is really good

RiazuMacroni (47)

Where did you learn these programming languages from? I also want to learn these things but do not know where to learn from and which ones are good. Please tell me

Kookiez (400)

@uhmansoori kinda of a newbie statement, but all languages are good.

PhilipHenkelman (0)

@OrangeJooce123 I have been doing some minecraft modding so I use Java. (Windows and bedrock suck) It really depends on what you wanna do.

lukechu10 (4)

@uhmansoori personally, I really like c# but support is not that good (yet)

EpicGamer007 (1736)

OMG, this is amazing, I might make something like this for my java project MyCMD. This is godly and amazing.

Edit: One of my java projects

firefish (949)

It converted the firefish to the coalfish. Hrm...

ChezCoder (1605)




wanna help me w/ something my brain is to small for?

ChezCoder (1605)

@Codemonkey51 basically i got this stupid idea where we have a textarea, but multiple people can edit it xD

Codemonkey51 (1057)

Great actually I think I may also want something like this for my IDE I'll dm you on discord when I can help (coderman51#8112) @ChezCoder

ChezCoder (1605)

@Codemonkey51 oke :D also im making a few bookmarklets to help people whos schools block inspect element and console.

the bookmarklets basically recreate inspect element and gives them all sorts of easy to use "html hacking" tools :D wanna help?

Codemonkey51 (1057)

Sure I'll also dm about that when I can @ChezCoder

k9chelsea2 (734)

hmms… are u on scratch if yes whats ur username is iy the same as you one? because i regonise the username