0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

動画ファイルの.cineのnumpyへのとりこみ

Last updated at Posted at 2025-01-03

まえがき

高速度カメラPhantomシリーズの付属の撮影ソフトウエアPCCでのデフォルト拡張子.cineを、pythonnumpy配列へ入れる方法をメモしておく。
とはいっても、モジュールをつかうだけ。

なおnumpy配列へ入れることで、opencvscikit-imageなどのモジュールが使いやすくなる。

使用モジュール

pims
https://github.com/soft-matter/pims

読み込みの実例

import numpy as np
import pims

f = pims.open("filename.cine")

これだけである。
厳密には、numpy配列に入ったわけではないものの、このまま同等として扱える(はず)

たとえば、

type(f)
<class 'pims.cine.Cine'>

f.dtype
dtype('uint16')

f.shape
(874, 720, 1280)

となっている。
さらに

f

<Frames>
Source: 10000fps.cine
Length: 874 frames
Frame Shape: (1280, 720)
Pixel Datatype: uint16

などと、メタデータも入っている。

どうしてもnumpyの純正がいいなら

f2 = np.copy(f)

type(f2)
<class 'numpy.ndarray'>

とでもすればいい。

scikit-imageをつかっての実例

import numpy as np
import pims
from skimage.io import imsave

f = pims.open("filename.cine")

for i in range(0,f.shape[0]): 
  imsave("folderpath/"+str(str(i).zfill(5))+".tif",f[i])

などとすれば、scikit-imageimsave()を使って、連番の.tifを保存することとなる。
なお、zfill(5)は、0埋め5桁の名前で保存しろ、といういみ。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?