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!

Sunday, 7 October 2012

Start the World with DrRacket

It has been more than two weeks since I first time open DrRacket. As a non-computer person, it was my first experience of picture programming.  At first, I was not familiar with the programming language. It was a little bit difficult to remember all  the symbols. For example:
              when you input a text code, ( ) are required: (flip-horizontal image)
              when you input a number code, ( )are not required. Just simply input the number you chose

For the first few times, it is not easy to remember these symbols.

Also, it is required to remember all the languages used to produce values. If one of the words of the code is wrong, the values produced will be different or the DrRacket will not be able to identify the instruction. After a few tries, I finally got most of the basic codes for expressing, combining and transforming values. Anyway, it was a fun experience.