Wednesday, 24 October 2012

Color the image with DrRacket

Before seeing the function of changing colour function of the DrRacket, I thought that I can only alter the colours of an image by using applications like Photoshop. Now, I find out that I can become the expert, I can be the Photoshop since I can program the picture in DrRacket.

Here is the example, the professor gave us:

; swap-red-blue : image -> image
; Swap the red and blue intensities of c
(check-expect (swap-red-blue (make-color 5 10 15 20))
              (make-color 15 10 5 20))
;
(define (swap-red-blue c)
  (make-color
   (color-blue c)
   (color-green c)
   (color-red c)
   (color-alpha c)))


By copying this model, it is very easy for me to switch the colour or change one colour to another colour. I find that this is more easier to change the image than doing so in Photoshop. Really Cool!

No comments:

Post a Comment