作者erspicu (.)
看板C_Sharp
标题[心得] 影像处理各种存取方式
时间Sun Dec 11 00:13:58 2016
https://github.com/erspicu/AccessDemo
https://github.com/erspicu/AccessDemo/blob/master/AccessDemo/Program.cs
对处理影像来说,最基本最基本的的课题有两个
1.存取pixel的资料
2.存取pixel内各rgb各自部分的内容
处理完毕後,存回
对针最基本的资料读取与储存
测试了各种不同的策略
当然除了写法差异外 其实跟硬体环境和runtime都有所关系
怎样适合 请自行评估
下面是我的结果 有最佳化 非debug模式
在x86执行的话 以ulong的模式存取资料 就没优势了
相反的x64的话 用ulong存取资料 刚好是cpu一次读取的长度
使用ulong一次读两颗pixel 在x64时代其实是比较有效率的
不过长宽必须是2的倍数
x64 64bit mode
Version: 4.0.30319.42000
[测试资料搬移速度]
Copy by bytes
cost : 4701
fps : 106
Copy by uint
cost : 1873
fps : 266
Copy by ulong
cost : 1442
fps : 346
[测试RGB各项存取处理搬移速度]
deal by bytes
cost : 4655
fps : 107
deal by uint way 1 (combine by bitwise)
cost : 4222
fps : 118
deal by uint way 2 (combine by byte loc)
cost : 3219
fps : 155
deal by ulong way 1 (combine by bitwise)
cost : 2758
fps : 181
deal by ulong way 2 (combine by byte loc)
cost : 2302
fps : 217
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 61.70.88.120
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_Sharp/M.1481386444.A.3A0.html
※ 编辑: erspicu (61.70.88.120), 12/11/2016 00:31:55
1F:推 jizang: 推 12/11 11:37
2F:推 name2name2: 推 12/15 22:49
3F:推 atrix: 推 09/05 19:30