グレイスケールのNTSC系加重平均法
| img newImage | img := (ImageReader fromFile: '/path/to/your/image/file') image. newImage := img copyEmpty. img pixelsDo: [:x :y | | pxColor ntscGray newPxColor | pxColor := img valueAtPoint: x@y. ntscGray := pxColor red * 0.298912 + pxColor green * 0.586611 + pxColor blue * 0.11448. newPxColor := (ColorValue red: ntscGray green: ntscGray blue: ntscGray). newImage atPoint: x@y put: (img palette indexOfPaintNearest: newPxColor). ]. img inspect. newImage inspect
こっちの方が色が暗くなるのはなにか問題があるのだろうか...