r/Python • u/HBRYU • Jul 28 '19
I made a script that uses the mouse and keyboard to scan a grayscale image and replicates it in ms paint
8
u/jantari Jul 28 '19
Hmm.. i"m confused, if it scans and replicates the image why is it not an exact 1:1 copy? It looks lower quality than the original
4
u/HBRYU Jul 28 '19
I zoomed in
1
u/AlcaDotS Jul 29 '19
But there's also much less detail, contrast seems to be higher (blown out white flower and other pieces too dark). Could be a bug?
4
u/HBRYU Jul 29 '19
I can set the "darkness sensitivity". Basicly, i can have less color details and have the process be done in 10 to 15 minutes or I can have maximum details and let it run for hours. In this case, I set it to a low sensitivity, so I could have it done quickly.
33
u/andrekerygma Jul 28 '19
Wow!!
21
u/HBRYU Jul 28 '19
Thank you! It's still a work in progress. I'll post an updated version tomorrow
11
u/andrekerygma Jul 28 '19
If possible, share the code! =D
11
4
u/12si27 Jul 29 '19
If u are Korean I recommend you to use great Korean monoscape fonts like: Noto Sans Mono or 나눔고딕코딩, D2Coding.. Stuff like that
And also, great project 👍
2
u/HBRYU Jul 29 '19
Wait how did you know?
3
u/12si27 Jul 29 '19
스크린샷에 꿀뷰가 있어서 바로 알아챘죠 😎
2
3
u/Gl1tch54 Jul 29 '19
That's not fair, I wanna know how you know too :(
2
u/TrakJohn Python 3 Intermediate Jul 29 '19
I can't read korean but these characters in paint's menu (top left) are definitely not english
2
u/Gl1tch54 Jul 29 '19
Ohhhh I see...Well no, I didn't, because I'm in a tiny mobile, that's why I didn't saw them, thanks xD
1
3
u/Pancake57 Jul 29 '19
Can you record a video of it working? I wanna see it in action.
3
u/HBRYU Jul 29 '19
Coming in 6 hours
0
u/living_undera_rock Jul 29 '19
!remindme 6 hours
1
u/RemindMeBot Jul 29 '19
I will be messaging you on 2019-07-29 14:08:56 UTC to remind you of this link
CLICK THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
Info Custom Your Reminders Feedback
421
u/swethonay Jul 28 '19 edited Jul 28 '19
What kind of monster uses a font that isn't monospaced‽
33
11
13
4
1
192
Jul 28 '19
[removed] — view removed comment
119
39
u/yardshop Jul 28 '19
Now you have to try the new Comic Code!
4
2
0
Jul 29 '19
[deleted]
8
8
Jul 29 '19
It is tempting to bring up an editor during a demo to see how long before someone breaks and says something.
1
u/yardshop Jul 30 '19
I did it! I bought it and got it working in SublimeText, and I like it!!
Now to figure out how to get in the console window!
8
Jul 28 '19
comic Sans all the way. Comes as default font with Linux Mint 19.1 Cinnamon ;) just another reason to love Linux I suppose.
8
4
2
2
32
u/Fiskepudding Jul 28 '19
Good work! Are you coding in notepad++? Did you know there are editors specifically made for coding? They can help out a lot, both explaining the code, automating tasks and detect errors.
If you have some spare time, look into PyCharm or VsCode (with a python plugin). It can make your life easier. Good luck with your coding adventures!
11
u/Hippie23 Jul 28 '19
Spyder is my go to IDE for python, and it installs with the Anaconda distro.
6
Jul 28 '19
Have you tried vsc? Not knocking you, Spyder was my go-to as well.
4
u/Hippie23 Jul 28 '19
I have used VSC. Something that I really like in Spyder is the ability to ‘run cells’ (highlight some text and select option on right click menu) it can make troubleshooting easier in my opinion. To my knowledge there is no way to do that in VSC. I mean you could copy and paste the code directly into the console, but that is less convenient, in my opinion
In my experience IDEs are like types of beer, in that there are die hards for a ton of different ones. I work with some people that swear there isn’t anything better than vim (which really isn’t even an IDE).
7
Jul 28 '19
You can do that in vscode too
4
u/Hippie23 Jul 28 '19
Ooo. I definitely did not know that. Is it the same thing — highlight and right click? Or is their a plug-in that needs to be installed?
3
Jul 28 '19
I think its a part of the official "Python" extension
1
u/YRUAQT Jul 29 '19
Yep, selecting lines and pressing Shift+Enter. But also a lot of things can be done with extensions.
3
u/estysdesu Jul 29 '19
you just have to signify that a section is a code block with
#%%. Then the vscode python extension recognizes it and you can click run one block in Jupyter or the whole file or what not2
u/Fiskepudding Jul 29 '19
Yes, spyder is good too! And for more exploratory code, Jupyter notebook can help keep the snippets organized if you have to document your explorations
12
2
u/dakokonutboi Jul 28 '19
HOLY SMOKES THIS IS AMAZING ! Did you post it on GitHub?
9
u/HBRYU Jul 28 '19
It's 1:30 AM rn, gotta sleep lol. I'm gonna be posting a more finnished updated version tomorrow!
7
3
4
u/EverythingIsFlotsam Jul 29 '19
range(x) already gives 0..x-1. You probably didn't need to do
for i in range(len(img)-1)
1
6
u/_dnov Jul 28 '19
When will I reach this level? I don't know how to do anything 😭
5
u/lookforlight Jul 29 '19
Keep learning, start small, and build your way up to bigger projects. I'm sure if you asked OP, he would say that it took him a long time to get to the point where he could make this.
One thing I would suggest is looking at the full source code for this or a similar project, line by line, and figure out what each line is doing, and how the different functions interact.
3
4
u/i4mn30 Jul 29 '19
Just start from printing Hello World:
print("Hello World")Then try to modify the string printed. Always try to do some fun little modifications to already working code. Step by step you'll learn the various things in the language. Google stackoverflow questions that answer your doubts. Just keep adding mods step by step. Then as you get comfortable, have a goal, then break it into small mod steps. Then just conquer them as above. For eg., have a goal to read a file and print the top 5 most frequently used words. Now to break it into mods: you'll need to know how to read a file, how extract individual words, how to keep track of their frequency, and how to sort them and then get the top five. Each of these themselves require a learning of lot of Python basics such as i/o, loops, lists, dicts, in-built lib functions like sort, etc.
Make bigger goals. Divide them into smaller conquerable parts, then stitch 'em up.
Just remember this - if you can't get something done in X amount of time it doesn't mean you can't do it. You're just not experienced enough. Experience needs time. There was a time when that frequency problem I stated above would have taken me almost a day to get done. Now it's a basic 5 min problem. But that's because I have 5+ years of experience in Python. So don't give up (unless you absolutely just can't get yourself to like programming). Keep practicing.
2
u/_dnov Jul 29 '19 edited Jul 29 '19
I actually know how to do the things you described but I never actually broke it down to catalog what I actually know I sort of just did them without really understanding . Thanks for the tip. Appreciate it
2
u/hashmalum Jul 30 '19
Figure out something you want to do, and google each step until you get there. I've been messing around with the Spotify API with https://github.com/plamere/spotipy recently to try to practice.
2
u/_dnov Jul 30 '19
thanks hash. ive recently just been doing interview style questions on codewars. will try to get into more practical applications like using APIs and things of the sort
2
u/hashmalum Jul 30 '19
I’m sure that way will work too, but I know every time I’ve tried to sit down and do project Euler or something I always get bored since my interest in what I’m coding isn’t that great.
2
2
2
2
u/throwawayskinlessbro Jul 29 '19
Is this something you'd be willing to share? I just got into coding in general, and this is very interesting! Amazing job regardless!!
2
2
u/YeastBeast33 Jul 29 '19
Wow im new to coding still learning, seeing stuff like this makes me wanna learn more and more
2
2
2
u/farooq_fox Jul 28 '19
Pardon my ignorance, how is this better than copy and paste in paint ?
Can you please list some uses with this ?
14
u/DiamondxCrafting Jul 28 '19
It's not better, it's not made to transfer an image into paint, it's made so he can get better and try new things to get familiar.
2
3
1
1
1
1
1
1
1
1
1
0
78
u/mfitzp mfitzp.com Jul 28 '19 edited Jul 28 '19
Maybe I'm missing something here but what does it do? Does it draw the image using MS Paint? i.e. converting it into paths? Or does it do a raster copy, i.e. pixel by pixel from one image to another? (this would be a lot less hard).