Jump to content

Grayscale image: Difference between revisions

m
→‎{{header|Sidef}}: minor code simplifications
m (added whitespace before the TOC (table of contents), added a ;Task: (bold) header, added other whitespace to the task's preamble, used a "times" (x) glyph instead of dot multiply glyph.)
m (→‎{{header|Sidef}}: minor code simplifications)
Line 1,517:
var (width, height) = (img.width, img.height)
var gimg = %s'Image::Imlib2'.new(width, height)
0.tofor y,x in (width^height -~X 1^width).each { |x|
0.tovar (heightr, -g, 1b).each {= img.query_pixel(x, |y|)
var gray = var int(0.2126*r, + 0.7152*g, b)+ = img0.query_pixel(x, y0722*b)
gimg.set_color(gray, vargray, gray, = int(0.2126*r + 0.7152*g + 0.0722*b255)
gimg.set_colordraw_point(gray, gray, grayx, 255y)
gimg.draw_point(x, y)
}
}
return gimg
}
 
var (input='input.png', output='output.png') = @ARGV...
var image = %s'Image::Imlib2'.load(input)
var gscale = tograyscale(image)
2,747

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.