How to write a function double :: Transform which doubles the size of the image in both horizontal and vertical way. How abou half size? Thank you.
assignment need help
Started by Stevie, Mar 26 2010 03:05 AM
4 replies to this topic
#1
Posted 26 March 2010 - 03:05 AM
|
|
|
#2
Posted 26 March 2010 - 04:46 PM
This was NOT a tutorial. Now then, what language do you need this in, and what reading have you done on the subject?
#3
Posted 26 March 2010 - 05:33 PM
I am doing Haskell Programming now. I know that picture is made up of pixels RGB and in order to double the size, i have to replace each pixels with four pixels. But i am not sure how to pit this into code.
#4
Posted 27 March 2010 - 03:48 AM
Sorry Stevie, I've been working all this week and I just haven't had much time to make a good response to your question, which I wanted you to actually generalize the function so that you didn't just double the size of the image, you were able to scale it or shrink it to any size (which would be preferable, and also a bit more complex). But anyway, it's actually pretty easy to double the size of a list, which is basically all you're trying to do anyway. Do this:
Oh, and moved to General Programming.
doubleSize [] = [] doubleSize (x:xs) = x : x : doubleSize xsThere you go, that should double the number of elements in the list in their according positions no matter what the list is (it need not be pixels). You can also do my suggestion of keeping to functions like foldl:
doubleSize = foldl1 (/x -> (++) [x, x])That's probably a little less efficient to be honest, but DTSTTCPW, right? Also you might want to make that strictly evaluated.
Oh, and moved to General Programming.
Wow I changed my sig!
#5
Posted 27 March 2010 - 04:47 AM
Thanks ZekeDragon... i will try to figure out how does this work.....


Sign In
Create Account

Back to top









