Doubling the size of an image

Reply

Join Date: Jul 2005
Posts: 55
Reputation: c_shaft05 is an unknown quantity at this point 
Solved Threads: 1
c_shaft05's Avatar
c_shaft05 c_shaft05 is offline Offline
Junior Poster in Training

Doubling the size of an image

 
0
  #1
Oct 10th, 2005
I'm working on some python programming and I need some help as to how to double the size of a picture using the image module.... any ideas?!
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,972
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 920
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Doubling the size of an image

 
0
  #2
Oct 11th, 2005
Is the picture you are loading smaller than what you want to display? If yes, the quality will suffer quite a bit! The program has to make up missing information.

Are you using the Python Image Library PIL for this?
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 55
Reputation: c_shaft05 is an unknown quantity at this point 
Solved Threads: 1
c_shaft05's Avatar
c_shaft05 c_shaft05 is offline Offline
Junior Poster in Training

Re: Doubling the size of an image

 
0
  #3
Oct 11th, 2005
I know the quality will be degraded, but I'm going for making it larger either way.... and yes I'm using the PIL.... and yes I am going from smaller to larger.....
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,972
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 920
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Doubling the size of an image

 
0
  #4
Oct 11th, 2005
I worked on this for a while and put the code into the Python snippet section:
http://www.daniweb.com/code/snippet396.html

Hope you find it constructive for your needs.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 55
Reputation: c_shaft05 is an unknown quantity at this point 
Solved Threads: 1
c_shaft05's Avatar
c_shaft05 c_shaft05 is offline Offline
Junior Poster in Training

Re: Doubling the size of an image

 
0
  #5
Oct 12th, 2005
Here is what I have done... some steps i did may not have been necessary, for example the extra color variables.... though now i need help with my zoom factor.... because this works for zooming in two times... but when higher numbers come about it skips pixels... i messed around with an extra for loop but its still the same... any other ideals?
  1. def enlarge(oImage,w,h,x,y,zoom):
  2. nImage= EmptyImage(w*zoom,h*zoom)
  3. for q in range(w):
  4. x = x +zoom
  5. y = 0
  6. for z in range(h):
  7. color = oImage.getPixel(q,z)
  8. red= color[0]
  9. green= color[1]
  10. blue= color[2]
  11. nImage.setPixel(x ,y ,(red,green,blue))
  12. nImage.setPixel(x+1,y +1,(red,green,blue))
  13. nImage.setPixel(x+1, y,(red,green,blue))
  14. nImage.setPixel(x, y+1,(red,green,blue))
  15. for lea in range(1,zoom):
  16. nImage.setPixel(x+lea,y+lea,(red,green,blue))
  17. nImage.setPixel(x, y+lea,(red,green,blue))
  18. nImage.setPixel(x+lea,y, (red, green,blue))
  19. y = y +zoom
  20. r = nImage
  21. winner = ImageWin("Big Picture", w*zoom, h*zoom)
  22. r.draw(winner)
  23. winner.getMouse()
  24. winner.close()
  25.  
  26.  
  27. def main():
  28. picname= raw_input("Enter Picture name with .jpg, .bmp, or ending: ")
  29. oImage= FileImage(picname)
  30. h= oImage.getHeight()
  31. w= oImage.getWidth()
  32. win = ImageWin("Original", w,h)
  33. oImage.draw(win)
  34. y = 0
  35. zoom = input("Number of times to zoom: ")
  36. x = -(zoom)
  37.  
  38. enlarge(oImage,w,h,x,y,zoom)
  39.  
  40. win.getMouse()
  41. win.close()
  42.  
  43.  
  44. main()
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 137
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: Doubling the size of an image

 
0
  #6
Oct 13th, 2005
Nice project c_shaft05 you do much thinking here!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 55
Reputation: c_shaft05 is an unknown quantity at this point 
Solved Threads: 1
c_shaft05's Avatar
c_shaft05 c_shaft05 is offline Offline
Junior Poster in Training

Re: Doubling the size of an image

 
0
  #7
Oct 13th, 2005
I need to refraise what i said... I need help being able to take a user input for the number of times to zoom in and put it into my program but I need help with the for loop in how to do it.... pixels are being skipped when i go in to higher numbers!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 137
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: Doubling the size of an image

 
0
  #8
Oct 16th, 2005
I remember in school they talked about DIB (device indepentant bitmaps) to be best for stretching/enlarging. Was C class for graph artists.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 55
Reputation: c_shaft05 is an unknown quantity at this point 
Solved Threads: 1
c_shaft05's Avatar
c_shaft05 c_shaft05 is offline Offline
Junior Poster in Training

Re: Doubling the size of an image

 
0
  #9
Oct 19th, 2005
Meh.... yea... I don't know what you are talking about ... but yea... I just need help looping it to the point where its not skipping Pixels......
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,972
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 920
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Doubling the size of an image

 
0
  #10
Oct 19th, 2005
There is something missing in your code. What do you import?
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC