PMXBOT Log file Viewer

Help | Karma | Search:

#pil logs for Thursday the 12th of December, 2013

(Back to #pil overview) (Back to channel listing) (Animate logs)
[00:14:26] <svenstaro> can you do pypi upload?
[02:28:28] <jazwec> sorry i was away for a few hours but now i finally resolved that problem with installation (by using pillow). so, please, is there any site with code examples for things like circles, chessboard and so on.. ive no idea how could i do it...
[02:49:01] <jazwec> i just want to see some examples to get the basic understanding of how it works and how should the code look like
[04:15:14] <jazwec> nah, im going to sleep...gonna try it here tomorrow.. good night guys
[11:39:04] <jazwec> morning.. please, im trying to merge 3 grayscale images into one. either directly or first toRGB and then convert it to grayscale... could anybody give me a tip, please?
[11:41:01] <jazwec> if i try to merge them into RGB it gives me "mode mismatch" and if i try to merge them as L it says "wrong number of bands"
[16:43:37] <wiredfool1> jazwec: post the code as a gist or pastebin and I'll look
[16:55:27] <jazwec> wiredfool1 its pointless now.. i switched a few messages with my teacher and he says i shouldnt use ImageMath. instead, he just wants us to check i pixel by pixel and try to somehow put it together
[16:57:27] <jazwec> wiredfool1 but..is there a way how can i do something like color every pixel in range?
[17:02:59] <wiredfool1> like, as a lookup table?
[17:03:10] <wiredfool1> or as a rectangle?
[17:08:48] <jazwec> wiredfool1 im trying to draw a chessboard... this if my code so far: http://bpaste.net/show/Nu4jFHrBOGbF44tkCOjL/
[17:09:37] <jazwec> a friend of mine told me to color everything from "co" to (x+1)*field and (y+1)*field
[17:09:58] <jazwec> my result currently looks like this: http://i.nyx.cz/files/00/00/11/04/1104658_c506c9ef92fe34c98c1a.png?name=sachovnica.png
[17:10:06] <wiredfool1> ok, 2 problems right off the bat
[17:10:20] <wiredfool1> you're setting your pixel in co
[17:10:32] <wiredfool1> you're passing c into image.putpixel
[17:10:41] <wiredfool1> which is not defined here
[17:11:04] <wiredfool1> also, co is already a tuple, so you would be passing ((x,y))
[17:12:00] <wiredfool1> also, width vs size
[17:12:53] <jazwec> oh sure, i forgot to change it.. width = size
[17:13:00] <wiredfool1> also. you're effectively putting one pixel in the corner of each square
[17:13:16] <wiredfool1> you can either use image.paste to paste in a rectangle
[17:13:31] <wiredfool1> or you need to draw all the pixels of the square
[17:13:45] <wiredfool1> (though, if field is 1 and width =8, you're closer)
[17:14:31] <jazwec> im starting to get lost
[17:14:34] <wiredfool1> ah
[17:15:19] <wiredfool1> so, for a concrete example: size = 16, field=2?
[17:15:58] <wiredfool1> what are the first few pixels that this (slightly) corrected code would turn white?
[17:16:46] <wiredfool1> http://bpaste.net/show/TWZ5a9JklMh7maOYDnhP/
[17:18:31] <jazwec> 0,0 and 0,2?
[17:18:47] <wiredfool1> yep
[17:19:11] <wiredfool1> I can see two problems with that
[17:20:30] <wiredfool1> (can you?)
[17:21:41] <jazwec> not really...
[17:21:57] <wiredfool1> ok, so if the square size is 2, what color should 0,1 be?
[17:22:09] <wiredfool1> and what color should 0,2 be?
[17:22:43] <jazwec> 0,1 should be white and 0,2 should be black
[17:22:53] <wiredfool1> right.
[17:24:08] <wiredfool1> so there should be some f(x,y) that would return white/black
[17:24:18] <wiredfool1> in the correct pattern
[17:24:43] <jazwec> yes
[17:25:03] <jazwec> but how can i alternate it after each line?
[17:26:01] <wiredfool1> well. f(0,0) == white, f(0,1) == black, f(0,2) == white, f(1,0) == black, f(1,1) == white
[17:26:55] <wiredfool1> what if that were rewritten to f(x+y) == black/white?
[17:27:21] <wiredfool1> does that help?
[17:28:01] <jazwec> not really.. something like if y is an odd number it should be black? or something like that
[17:28:51] <wiredfool1> yep
[17:29:30] <wiredfool1> so, if x+y is odd, then black
[17:36:06] <jazwec> so ive did it like this but the result is still bad: http://bpaste.net/show/vOHebjoWlH18ftAOTtsa/
[17:36:57] <wiredfool1> ok, so now, what are the first couple black pixels?
[17:37:40] <wiredfool1> (for field=2)
[17:39:04] <jazwec> 0,0 and 0,1
[17:39:35] <wiredfool1> and after that?
[17:39:39] <jazwec> but why is 0,4 black aswell?
[17:41:09] <wiredfool1> ok, different question: does this code do the correct thing for the corner pixel of each 2x2 square?
[17:42:15] <wiredfool1> or equivalently, does it work properly with field==1?
[17:43:04] <jazwec> it does..thats beautiful
[17:43:50] <wiredfool1> ok, so now, all you need to do is color each square rather than the corner
[17:44:45] <jazwec> i dont understand
[17:45:23] <wiredfool1> so what you have is a viable checkerboard where the squares are 1x1
[17:45:49] <wiredfool1> did you want one where the individual squares could be bigger?
[17:47:00] <jazwec> well the thing is we should be able to set the size of the board and field manually
[17:48:16] <jazwec> and until now i thought it would be ok but now ive tried it and its just a black board with very few white pixels on it
[17:50:04] <jazwec> http://bpaste.net/show/qFqeGKrlAXXeuxsf5XHW/
[17:50:41] <jazwec> well they both work if squares are 1x1..but doesnt work any other way
[17:51:03] <wiredfool1> right. so putpixel puts one pixel
[17:51:24] <wiredfool1> you can either do that a bunch of times per square
[17:51:37] <wiredfool1> or you can paste something in at that point
[17:51:56] <jazwec> i would rather do it bunch of times per square..
[17:52:16] <jazwec> do i need to use a third for cycle? or can i just set it in putpixel somewhere
[17:53:12] <jazwec> ill be damned
[17:54:39] <wiredfool1> putpixel is one pixel
[17:54:53] <wiredfool1> what do you think you need to do?
[17:55:14] <jazwec> add an "s" ?
[17:55:45] <wiredfool1> sorry, no, there's no putpixels
[17:55:54] <jazwec> i thought so
[17:57:20] <jazwec> for z in range(field): putpixel ?
[17:58:28] <jazwec> no that didnt do it
[17:58:35] <wiredfool1> what did it do?
[17:59:02] <jazwec> nothing
[17:59:35] <wiredfool1> what pixels are you putting
[18:00:08] <jazwec> still the same
[18:00:26] <jazwec> http://bpaste.net/show/bcqOUxa3wTlOsrXKCsRp/
[18:01:01] <wiredfool1> trace that through, and see what pixels you're putting
[18:17:04] <jazwec> im putting co = (x*field, y*field)
[18:17:25] <jazwec> should i do something like 0,x*field?
[18:18:07] <jazwec> im sorry im keeping you this busy...but i really appreciate your help...thank you
[18:19:46] <jazwec> i dont even know if it has sense to do it.. i have to send it to my teacher in five hours..and this isnt by far the hardest part...
[18:19:56] <jazwec> in the end it should look like this: http://fi.muni.cz/~xdrabek1/ib111/sachovnice.png
[18:21:54] <wiredfool1> well, what changes each time you call putpixel?
[18:22:40] <jazwec> x and y
[18:25:23] <jazwec> or, y does
[18:25:43] <wiredfool1> so, what is the effect of z?
[18:26:23] <jazwec> y will be the same
[18:28:49] <wiredfool1> is there any effect on z?
[18:28:54] <wiredfool1> from z?
[18:31:03] <jazwec> i thought it would make a line of pixels...i even tried adding y += 1
[18:35:02] <wiredfool1> but co is constant in the inner loop
[18:36:03] <wiredfool1> looknig at that target image, you may be better off looping over the whole image and putting all the intelligence of what color to write in one f(x,y | geometry constants)
[18:36:53] <jazwec> what do you mean?
[18:37:23] <jazwec> i thought i would just draw that bloody chessboard and then draw some inverted circles on it
[18:38:00] <jazwec> in the end it should be one function with three parameters (size of board, size of field, size of circle)
[18:42:54] <wiredfool1> the inverted circles are going to be interesting.
[18:43:11] <jazwec> im sure they will
[18:43:35] <wiredfool1> And way more complex doing it in stages than just figuring out one function that would take the required geometry and returning a black/white decision
[18:44:02] <wiredfool1> using mod, div, square and stuff
[18:44:18] <wiredfool1> but that's probably the crux fo your homework
[18:44:25] <jazwec> thats the thing...
[18:44:32] <wiredfool1> it is homework, and not a test
[18:44:35] <wiredfool1> right?
[18:44:40] <jazwec> yes
[18:45:29] <jazwec> he wants us to do everything as basic as it can be...we are all beginners
[18:46:37] <jazwec> but it often turns out to be the hard way
[18:47:05] <wiredfool1> yeah
[18:47:19] <wiredfool1> so you have a f(x,y) that will give you a checkerboard
[18:47:32] <jazwec> i dont, yet
[18:47:44] <wiredfool1> x+y)%2
[18:47:58] <wiredfool1> you do.
[18:48:18] <wiredfool1> what if you wanted to scale that function so that it was n times bigger?
[18:49:03] <wiredfool1> also, what sort of function would you use to give the circle pattern?
[18:50:07] <jazwec> ((x-a)/2)**2+((y-b)/2)**2<= r**2 :
[18:50:37] <wiredfool1> good. and repeating?
[18:51:00] <wiredfool1> well, almost, I think there's misplaced paren there
[18:51:58] <jazwec> well repeating should be done by multiplying r
[18:52:22] <jazwec> but that would draw over the first circle, wouldnt it?
[18:52:52] <wiredfool1> you're looking for alternating colors
[18:53:45] <jazwec> couldnt i just set something like "if pixel is white make it black" and vice versa?
[18:54:10] <wiredfool1> Maybe in imagemath, but that's an overall image thing
[18:54:21] <wiredfool1> thre might be an xor function
[18:54:34] <wiredfool1> what if you used / and mod?
[18:57:46] <jazwec> i honestly dont know
[18:57:57] <jazwec> how could i use it? for what?
[18:58:36] <wiredfool1> so, what doe the function (x^2 + y^2) / r^2 look like?
[18:58:56] <jazwec> like a circle in the middle of my image
[18:59:03] <jazwec> or a sphere, better said
[18:59:47] <wiredfool1> not exactly.
[19:00:01] <wiredfool1> where is that function 1? where is it 2?
[19:00:47] <wiredfool1> (assuming that it's actually translated to the center properly
[19:03:38] <jazwec> what do you mean where is it 1 and 2?
[19:04:44] <wiredfool1> where is f(x,y,r): (x^2 + y^2) / r^2 == 1, where is it 2?
[19:08:18] <jazwec> im really sorry, but i dont understand it
[19:15:00] <wiredfool1> So, a lot of what's going on here is alternating colors.
[19:15:16] <wiredfool1> which winds up being f(some atuff) %2
[19:15:49] <wiredfool1> that function is normalized distance from a point
[19:15:55] <wiredfool1> normalized to radius
[19:17:32] <jazwec> yes
[19:18:08] <wiredfool1> I count 5 circles in the sample
[19:20:21] <jazwec> yes
[19:30:01] <jazwec> so a good thing is.. a friend of mine will send me his project..which i could not replicate, but maybe it will give me some perspective of how it works
[19:34:21] <jazwec> could not = mustnt
[19:35:28] <wiredfool1> yeah
[19:35:44] <wiredfool1> I'm trying to lead you to a solution
[19:44:33] <jazwec> i know im still thinking
[19:45:02] <jazwec> and his code works nice but i still dont get it
[19:46:00] <jazwec> http://bpaste.net/show/g7y86zoAREjk7ICQC5MO/
[19:48:59] <wiredfool1> ok
[19:49:28] <wiredfool1> what is line 6 doing?
[19:50:02] <wiredfool1> and how is it different than your line 7
[19:51:30] <jazwec> put pixel when x+y are even number
[19:51:47] <wiredfool1> well, it's more complicated than that
[19:51:54] <wiredfool1> that's what yours is doing
[19:52:43] <wiredfool1> actually, his is more complicated than it needs to be
[19:57:10] <jazwec> hmm
[19:59:16] <wiredfool1> (x%2 +y%2) == (x+y)%2
[20:02:15] <jazwec> yes i was trying something like this, but it only makes some sort of grid, not a chessboard
[20:04:26] <wiredfool1> so, he's looping over the whole image
[20:04:34] <wiredfool1> and he's doing something different in line 6
[20:10:39] <jazwec> i tried to do it like this http://bpaste.net/show/N87OVbJwDhVjINWhXazU/ i dont know if its a step back..but it doesnt work
[20:10:49] <jazwec> grid with some strange line even
[20:12:23] <wiredfool1> yeah, no.
[20:20:04] <jazwec> damn im lost..
[20:21:44] <jazwec> why cant i do just (x + y) % 2 == 0
[20:22:44] <jazwec> hm
[20:22:50] <jazwec> so now it is a grid...
[20:23:10] <jazwec> but with pixels, not squares
[20:25:30] <jazwec> couldnt i count my X and Y as squares made of 20 pixels for example?
[20:31:59] <wiredfool1> so, do you see the division in his line 6?
[20:32:04] <wiredfool1> what do you think that is doing?
[20:32:59] <wiredfool1> and sorry, there was a typo: (x%2 +y%2)%2 === (x+y)%2
[20:33:01] <jazwec> im trying to find out
[20:33:31] <wiredfool1> it looks like he's dividng the pixel location by the square size. why might he be doing that?
[20:37:31] <jazwec> thats what i dont understand
[20:39:09] <wiredfool1> so, you're multiplying an index by the size of the square to get a pixel. He's dividing a pixel by the size of the square to get...
[20:42:03] <jazwec> to get an index..but what is index now?
[20:42:18] <jazwec> shouldnt that be the x and y?
[20:42:41] <wiredfool1> it's the logical square location
[20:43:04] <jazwec> so that would be my "co"?
[20:43:05] <wiredfool1> it's the same thing that you're checking if it should be black or white
[20:43:21] <wiredfool1> no, co is in pixels
[20:43:37] <wiredfool1> it's _your_ x and y
[20:43:46] <jazwec> god im a terible student
[20:43:48] <wiredfool1> you're iterating over squares, he's iterating over pixels
[20:44:52] <wiredfool1> so, to back this out, If you're looking in pixels, and the square size is 1, then the f(x,y) is
[20:44:58] <wiredfool1> (x+y)%2
[20:45:08] <wiredfool1> How does that change if the square size is 10?
[20:58:56] <jazwec> (x*10 + y*10) % 2 ?
[20:59:34] <wiredfool1> is (x*10) % 2 ever 1?
[21:02:32] <jazwec> no, it isnt
[21:05:52] <wiredfool1> so. that leads us back to division
[21:10:24] <jazwec> so x/10?
[21:11:06] <wiredfool1> yeah
[21:11:19] <wiredfool1> tho in py3, you'd want x//10 to ensure integer division
[21:11:38] <wiredfool1> what would (x/10 +y/10)%2 do
[21:11:38] <jazwec> im using 2.7
[21:12:07] <wiredfool1> just saying. floating point division will trip you up at some point
[21:18:19] <jazwec> 0
[21:20:03] <jazwec> haha! ive made an optical illusion
[21:22:00] <jazwec> but ive made that chessboard finally, but i have exactly same code as my classmate
[21:34:24] <jazwec> i think i will leave you alone for today.. you have been great, thank you for all your help
[21:34:33] <wiredfool1> you're welcome
[21:36:17] <jazwec> my teacher sent us an email where he explained some things and told us we can send him the homework on saturday...i think i will manage somehow
[21:38:09] <jazwec> but one more time, thank you..its a pity i cant return the favor...have a good night, or day, or whatever is where you are from
[21:40:38] <wiredfool1> thanks. early afternoon
[21:47:50] <jazwec> im starting to think i chose a bad college ;]
[21:48:49] <jazwec> this is my first year studying computers, because they kicked me from lawschool and i somehow thought this would be a good idea because lots of my friends are here
[21:57:23] <jazwec> ok, good night folks
[21:57:31] <jazwec> its been a long day
[23:04:49] <aclark> poor jazwec
[23:08:55] <wiredfool1> yep.