how to read 12bit raw data faster

This is my way to read 12bit raw image file.
data = fread(p,[768,1024],'ubit12=>uint32',4,'l');
But it takes very long time, is there any other way to speed up the processing time?
Thanks!

2 件のコメント

Walter Roberson
Walter Roberson 2012 年 2 月 6 日
Is the data really packed in groups of 12 consecutive bits? It is not impossible, but it would be somewhat unusual.
Sounder
Sounder 2012 年 2 月 7 日
one 12 bits pixel is stored in 2 bytes. It's combined with 4bits of random number and 12 bits of data. So this is the only ezsy way I know to implement, but it takes long time to read.

サインインしてコメントする。

 採用された回答

Jan
Jan 2012 年 2 月 7 日

1 投票

You can read all 16 bits and set the upper 4 bits to zero:
data = fread(p, [768,1024], 'uint16');
b = uint32(rem(data, 4096));
I assume you can use the format 'uint16=>uint32' directly - please test if this is faster and if rem works on UINT32 arrays.

1 件のコメント

Sounder
Sounder 2012 年 2 月 8 日
lol it works! 23.5x speedup, thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Import and Analysis についてさらに検索

質問済み:

2012 年 2 月 6 日

編集済み:

2013 年 10 月 4 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by