LoginSignup
0
0

More than 5 years have passed since last update.

OpenCVSharpで48bit画像の保存

Last updated at Posted at 2018-09-05

OpenCVSharp3にて48bit(16bit/Color) TIF画像をいじった時に躓いたので覚書です。
VB.netですが。。。

もっといい方法があるかもしれません。

'TIFを開く
Dim src As Mat = Cv2.ImRead("TEST.TIF", ImreadModes.Unchanged)

~何らかの処理~

'MatをBitmapSourceへ変換
Dim bs As System.Windows.Media.Imaging.BitmapSource = Extensions.BitmapSourceConverter.ToBitmapSource(src)

'保存用のStreamを生成
Dim stream As New IO.FileStream("OutPut.TIF", IO.FileMode.OpenOrCreate)

'TIFのエンコーダー
Dim encoder As New System.Windows.Media.Imaging.TiffBitmapEncoder
encoder.Compression = System.Windows.Media.Imaging.TiffCompressOption.None
encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(bs))

'保存
encoder.Save(stream)

'Streamを閉じる
stream.Close()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0