Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Grayscale-image/Tcl/grayscale-image.tcl
Normal file
13
Task/Grayscale-image/Tcl/grayscale-image.tcl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package require Tk
|
||||
|
||||
proc grayscale image {
|
||||
set w [image width $image]
|
||||
set h [image height $image]
|
||||
for {set x 0} {$x<$w} {incr x} {
|
||||
for {set y 0} {$y<$h} {incr y} {
|
||||
lassign [$image get $x $y] r g b
|
||||
set l [expr {int(0.2126*$r + 0.7152*$g + 0.0722*$b)}]
|
||||
$image put [format "#%02x%02x%02x" $l $l $l] -to $x $y
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue