extractor for mdiapp 1.00i
用法
32bppレイヤーをアクティブにして実行しましょう。
機能
輪郭抽出の一種のプロトタイプのようなものです。結果が32bppレイヤーとして追加されます。
コメント
まだ調整が必要そうです。これまたピクセル単位の処理になっているので、本体で何らかの解決があるとよさそうです。
-- 抽出 for mdiapp 1.00i -- xelf.extractor.lua (C)2006-09-17 XELF local abs, min, max = math.abs, math.min, math.max; local sx,sy = 1,1; local dx,dy = -2,-2; local w1, h1 = mdi_width() + sx-1, mdi_height() + sy-1; local r,g,b,a = 0.298912, 0.586611, 0.114478, 0; local threshold = 64; local intensity = 100 / (sx * sy); mdi_undo_all(); local i0 = mdi_img_layer(mdi_layer_active()); local i1 = mdi_img_layer(mdi_layer_add(32)); mdi_img32_resize(i1, w1, h1); for y=0,h1,sy do for x=0,w1,sx do local xs,xe = x-sx*1,x+sx*2-1; local ys,ye = y-sy*1,y+sy*2-1; local rc,gc,bc,ac = mdi_img32_pixelget(i0, (xs+xe)*0.5+dx, (ys+ye)*0.5+dy); local count = 0; for y0=ys,ye do for x0=xs,xe do local r0,g0,b0,a0 = mdi_img32_pixelget(i0, x0, y0); local d = abs(r0-rc)*r + abs(g0-gc)*g + abs(b0-bc)*b + abs(a0-ac)*a; if (d >= threshold) then count = count + 1; end end end local c = min(255, count * intensity); for y0=ys,ye do for x0=xs,xe do mdi_img32_pixelcopy(i1, x0,y0, 255,255,255,c); end end end end