Anonymous user
Grayscale image: Difference between revisions
→{{header|PureBasic}}: Corrected code to include ImageToColor() function
m (Added Sidef) |
(→{{header|PureBasic}}: Corrected code to include ImageToColor() function) |
||
Line 1,300:
=={{header|PureBasic}}==
<lang PureBasic>Procedure ImageGrayout(image)
Protected w, h, x, y, r, g, b, gray, color
w = ImageWidth(image)
h = ImageHeight(image)
Line 1,306 ⟶ 1,308:
For y = 0 To h - 1
color = Point(x, y)
r = Red(color
g = Green(color
b = Blue(color
gray = 0.2126*r + 0.7152*g + 0.0722*b
Plot(x, y, RGB(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))
Next
Next
StopDrawing()
EndProcedure</lang>
=={{header|Python}}==
|