2013-04-10 22:43:41 -07:00
|
|
|
Procedure ImageGrayout(image)
|
2016-12-05 22:15:40 +01:00
|
|
|
Protected w, h, x, y, r, g, b, gray, color
|
|
|
|
|
|
2013-04-10 22:43:41 -07:00
|
|
|
w = ImageWidth(image)
|
|
|
|
|
h = ImageHeight(image)
|
|
|
|
|
StartDrawing(ImageOutput(image))
|
|
|
|
|
For x = 0 To w - 1
|
|
|
|
|
For y = 0 To h - 1
|
|
|
|
|
color = Point(x, y)
|
2016-12-05 22:15:40 +01:00
|
|
|
r = Red(color)
|
|
|
|
|
g = Green(color)
|
|
|
|
|
b = Blue(color)
|
2013-04-10 22:43:41 -07:00
|
|
|
gray = 0.2126*r + 0.7152*g + 0.0722*b
|
2016-12-05 22:15:40 +01:00
|
|
|
Plot(x, y, RGB(gray, gray, gray)
|
|
|
|
|
Next
|
|
|
|
|
Next
|
|
|
|
|
StopDrawing()
|
|
|
|
|
EndProcedure
|
|
|
|
|
|
|
|
|
|
Procedure ImageToColor(image)
|
|
|
|
|
Protected w, h, x, y, v, gray
|
|
|
|
|
|
|
|
|
|
w = ImageWidth(image)
|
|
|
|
|
h = ImageHeight(image)
|
|
|
|
|
StartDrawing(ImageOutput(image))
|
|
|
|
|
For x = 0 To w - 1
|
|
|
|
|
For y = 0 To h - 1
|
|
|
|
|
gray = Point(x, y)
|
|
|
|
|
v = Red(gray) ;for gray, each of the color's components is the same
|
|
|
|
|
;color = RGB(0.2126*v, 0.7152*v, 0.0722*v)
|
|
|
|
|
Plot(x, y, RGB(v, v, v))
|
2013-04-10 22:43:41 -07:00
|
|
|
Next
|
|
|
|
|
Next
|
|
|
|
|
StopDrawing()
|
|
|
|
|
EndProcedure
|