OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
查看: 3062|回复: 0

Android 图像 进行伽马 转化问题

[复制链接]
发表于 2019-5-23 12:05:35 | 显示全部楼层 |阅读模式
在网络上找了很久,得知伽马转化的原理 大致就是有一个函数,进行然后里面有一个伽马因子,然后去改变每个像素的值。

于是我写了下面的代码
  1.     /**
  2.      * 伽码矫正
  3.      */
  4.     private Bitmap gammaCorrectFilter(Bitmap bitmap){
  5.         Mat src = new Mat();
  6.         Utils.bitmapToMat(bitmap,src);
  7.         float fPrecompensation = 1F / 2.2F;
  8.         //构建一个伽码数组表
  9.         int[] g_GammaLUT = new int[256];
  10.         float f = 0F;
  11.         for(int i = 0; i < 256; i++){
  12.             f = (i + 0.5F) / 256;
  13.             f = (int) Math.pow(f,fPrecompensation);
  14.             g_GammaLUT[i] = (int) f;
  15.         }
  16.         int[] tempInt = new int[src.channels()];
  17.         for(int i = 0; i < src.rows(); i++){
  18.             for(int j = 0; j < src.cols(); j++){
  19.                 src.get(i,j,tempInt);
  20.                 for(int x = 0; x < tempInt.length; x++){
  21.                     tempInt[x] = g_GammaLUT[tempInt[x]];
  22.                 }
  23.                 src.put(i,j,tempInt);
  24.             }
  25.         }
  26.         Utils.matToBitmap(src,bitmap);
  27.         return bitmap;
  28.     }
复制代码
图片形式的代码:


然后这里出现了一个问题,就是Mat对象在get的时候,需要是“CV_32S”类型。
而我如何把Mat的type转成CV_32S类型呢?
说到底,Mat的类型转化,我不知道如何转化,麻烦各位大神了。


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-4-18 12:42 , Processed in 0.008139 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表