/// <summary>
/// 将图像缩小N倍
/// </summary>
/// <param name="source">原图数据</param>
/// <param name="height">原图高度</param>
/// <param name="width">原图宽度</param>
/// <param name="scale">缩小倍数</param>
/// <returns></returns>
public static ushort[] ImgNarrow(ushort[] source, int height, int width,int scale)
{
if (Convert.ToBoolean(height % scale) || Convert.ToBoolean(width % scale))
{
throw new Exception("高宽必须为" + scale + "的倍数");
}
ushort[] dest = new ushort[height * width / (scale * scale)];
int n = ;
for (int y = ; y < height; y = y + scale)
{
for (int x = ; x < width; x = x + scale)
{
int index = y * width + x;
int sum = ;
for (int i = ; i < scale; i++)
{
for (int j = ; j < scale; j++)
{
sum += source[index + i * width + j];
}
}
dest[n] = Convert.ToUInt16(sum / (scale * scale));
n++;
}
}
return dest;
}

原图是灰度数据,最终的目的是将图像缩小了N倍,然后取周围N*N个点的灰度平均值作为新图像的值,目前这个实现复杂度有点高,有更优解请评论回复

最新文章

  1. deepsooncms在Ubuntu 14.04上部署教程
  2. C语言 独木舟问题
  3. tp5 model 的数据自动完成
  4. AdminLTE 2 开源模版
  5. bootstrap-datetimepicker.js 设置开始时间的Bug。
  6. [Java面试八]Hibernate总结以及在面试中的一些问题.
  7. Windows配置mycat
  8. iOS - Mac OS X 终端设置
  9. openstackM版本常见问题汇总
  10. Socket.IO 1.0 正式发布,快速可靠的实时引擎
  11. Windows下使用命令行设置ip地址的DNS服务器
  12. linux 安装apahce的configure: error: APR not found. Please read the documentation解决办法
  13. Android百度地图开发03之地图控制 + 定位
  14. Spring事务传播特性的浅析——事务方法嵌套调用的迷茫
  15. Ubuntu 源
  16. 查找附近网点geohash算法及实现 (Java版本号)
  17. spring jdbc 源码
  18. oracle 数据库中的序列
  19. 【洛谷P1090 合并果子】
  20. 论文笔记【三】A Deep Dive into Word Sense Disambiguation with LSTM

热门文章

  1. postman抓包工具与kap项目部署(新猿旺学习总结)
  2. 1.4:SubShader
  3. APScheduler
  4. MySQL 增删改查
  5. Spring Boot 数据库连接池 HikariCP
  6. Maven解决包冲突
  7. Eclipse使用Maven,创建项目出现:Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resour
  8. matlab 入门
  9. 树莓派3代刷ubuntu mate在命令行下配置wifi不能连接的一个诡异的bug的解决
  10. webgl学习