Grayscale image: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 1,187: | Line 1,187: | ||
Original: [[File:Ppm-perl6.png]] Grey Scale: [[File:Pgm-g2-perl6.png]] |
Original: [[File:Ppm-perl6.png]] Grey Scale: [[File:Pgm-g2-perl6.png]] |
||
=={{header|Phix}}== |
|||
{{Trans|Euphoria}} |
|||
Requires read_ppm() from [[Bitmap/Read_a_PPM_file#Phix|Read_a_PPM_file]], see [[Bitmap/Write_a_PPM_file#Phix|Write_a_PPM_file]] for actual use. |
|||
Included as demo\rosetta\Bitmap_Greyscale.exw |
|||
<lang Phix>function to_gray(sequence image) |
|||
sequence color |
|||
for i=1 to length(image) do |
|||
for j=1 to length(image[i]) do |
|||
-- unpack color triple |
|||
color = sq_div(sq_and_bits(image[i][j], {#FF0000,#FF00,#FF}), |
|||
{#010000,#0100,#01}) |
|||
image[i][j] = floor(0.2126*color[1] + 0.7152*color[2] + 0.0722*color[3])*#010101 |
|||
end for |
|||
end for |
|||
return image |
|||
end function |
|||
sequence img = read_ppm("Lena.ppm") |
|||
img = to_gray(img)</lang> |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |