踊れないダメ人間

本人は面白いと思ってるらしい

Archive for 11月 2010

勤労感謝の日

leave a comment »

今年は「勤労できること」に感謝する日だった。

やっと昨日から働きに出るようになったんだYO。

クビにならないようにしないと。

Written by aoikagami

2010年11月23日 at 7:59 午後

カテゴリー: どうでもいい話

夢の話

leave a comment »

「ひた隠す」の「ひた」は「日田」から来ていて、
幕末に日田藩の人間が志士を匿ったことから来てるんだよ。
という夢を見た。

起きてから、日田は天領だったことに気が付いたorz

Written by aoikagami

2010年11月23日 at 7:55 午後

カテゴリー: どうでもいい話

F#をいじってみた

leave a comment »

2ちゃんねるで関数型言語のスレ見てたらなんか触ってみたくなったんで、
Visual StudioにくっついてるF#にしようと思い本を買ってきた。
3種類くらい本があったけど、とりあえずとっつきやすそうな本にしようと思って
F#入門という本にした。
で、読んでみたけど...

何が何やら、さっぱりわからんorz

とりあえず、ウインドウを作成するプログラムが書いてあるところを探して、
それのコピペから始めることにした。
まあ、単にウインドウ作成してもつまんないので、画像をいじって表示する
処理を追加してみた。
できたプログラムがこれ↓

//F# の詳細 (http://fsharp.net)

open System
open System.Windows.Forms
open System.Drawing
open Microsoft.FSharp.Control
open Microsoft.FSharp.Control.CommonExtensions

Application.EnableVisualStyles()

// 画像ファイルを開いてバイナリデータを取り出す
let pic1 = new System.Drawing.Bitmap("..\\..\\MiniIkamusume.png")
let bitmap1 = pic1.LockBits(new Rectangle(0,0,pic1.Width,pic1.Height),
                            Imaging.ImageLockMode.ReadOnly,
                            Imaging.PixelFormat.Format24bppRgb)
let mutable ptr1 = bitmap1.Scan0

let elementNum = pic1.Width * pic1.Height
let bytes = elementNum * 3
let rgbValues:byte[] = Array.create bytes 0uy

System.Runtime.InteropServices.Marshal.Copy(ptr1,rgbValues,0,bytes)

/// ウェーブレット変換
let Pn : float[] = [| 0.482962913; 0.836516304; 0.224143868;-0.129409523|]
let Qn : float[] = [|-0.129409523;-0.224143868; 0.836516304;-0.482962913|]
let d : int = 4

let halfWidth : int = pic1.Width / 2
let halfHeight : int = pic1.Height / 2

let mutable rgbTemp : float[] = Array.create bytes 0.0
let mutable rgbOutput : byte[] = Array.create bytes 0uy

let mutable tmp_rgb : float[] =  [|0.0;0.0;0.0|]
let mutable curTable : float[] = null
let mutable curPos : int = 0
let mutable i : int = 0
let mutable j : int = 0

/// 横
for y:int in 0 .. pic1.Height - 1 do
    for x:int in 0 .. pic1.Width - 1 do

        tmp_rgb <- [|0.0;0.0;0.0|]

        if x < halfWidth then
            i <- x
            curTable <- Pn
        else
            i <- x - halfWidth
            curTable <- Qn

        for n:int in 0 .. d - 1 do
            j <- ( n + 2 * i ) % pic1.Width
            curPos <- (y * pic1.Width + j) * 3

            tmp_rgb <- [|
                tmp_rgb.[0] + curTable.[n] * float rgbValues.[curPos + 0];
                tmp_rgb.[1] + curTable.[n] * float rgbValues.[curPos + 1];
                tmp_rgb.[2] + curTable.[n] * float rgbValues.[curPos + 2]
                |]
        done

        curPos <- (y * pic1.Width + x)*3

        rgbTemp.[curPos + 0] <- tmp_rgb.[0]
        rgbTemp.[curPos + 1] <- tmp_rgb.[1]
        rgbTemp.[curPos + 2] <- tmp_rgb.[2]
    done
done

/// 縦
for x : int in 0 .. pic1.Width - 1 do
    for y : int in 0 .. pic1.Height - 1 do

        tmp_rgb <- [|0.0;0.0;0.0|]

        if y < halfHeight then
            i <- y
            curTable <- Pn
        else
            i <- y - halfHeight
            curTable <- Qn

        for n:int in 0 .. d - 1 do
            j <- ( n + 2 * i ) % pic1.Height
            curPos <- ( j * pic1.Width + x ) * 3

            tmp_rgb <- [|
                tmp_rgb.[0] + curTable.[n] * rgbTemp.[curPos + 0];
                tmp_rgb.[1] + curTable.[n] * rgbTemp.[curPos + 1];
                tmp_rgb.[2] + curTable.[n] * rgbTemp.[curPos + 2]
            |]

        done
        
        curPos <- (y * pic1.Width + x)*3

        rgbOutput.[curPos+0] <- byte tmp_rgb.[0]
        rgbOutput.[curPos+1] <- byte tmp_rgb.[1]
        rgbOutput.[curPos+2] <- byte tmp_rgb.[2]

    done
done

// 変換後のデータを設定
System.Runtime.InteropServices.Marshal.Copy(rgbOutput,0,ptr1,bytes)
pic1.UnlockBits(bitmap1)

/// フォームの作成
let form = new Form(Text="Test",Visible=true,Size=pic1.Size)
form.Paint.Add(fun e ->(e.Graphics.DrawImage(pic1,new Point(0,0))) )

[<STAThread>]
do Application.Run(form)

お約束の2次元ウェーブレット変換(^^;

前に作ったプログラム(DirectComputeのhlsl)を横目に見ながら書いたんで

「これぞ関数型プログラミング」って感じにはなってないとは思う

あと、並列処理まで入れたかったけど、さすがに始めて1日だとちょっと難しかった。

 


#(ナンバー)と♯(シャープ)の区別つけなくてもいいのかな...

Written by aoikagami

2010年11月10日 at 12:30 午前

財布落とした

leave a comment »

駅でpasmoを財布から出そうとしたら、財布がない。
かばんやポケットの中を探してみたが、見つからない。

もしかして、落とした?

ハロワに行ったときに暑かったので上着を脱いでかばんにしまった時に
落としてしまったのかと思い、ハロワに電話したが、なかったとの答え。

ちょっと、やばくない...?

どうしようかと考えていたら、何やら左手に違和感が...

袖の中に入ってたよ!!!

あー焦った

Written by aoikagami

2010年11月10日 at 12:14 午前

カテゴリー: どうでもいい話

昼寝してると

leave a comment »

「友達んこ」があるなら「お仲間んこ」もありじゃね?

という夢を見た。

もういい年したオッサンなんだけどな...

Written by aoikagami

2010年11月5日 at 1:10 午前

カテゴリー: どうでもいい話

誕生日

leave a comment »

無駄に年だけ重ねてる...

 

親から電話があって「何歳になった?」と聞かれたので「(本名)さんじゅうななさい」と答えたら笑ってた。

Written by aoikagami

2010年11月3日 at 9:16 午後

カテゴリー: どうでもいい話