swift - 在iOS中将从图库中选择的图像转换为灰度
问题描述
我正在编写一个程序来将从照片库中选择的图像转换为 iOS 中的灰度,但是当我测试它时,imageView 只显示黑暗。我的代码有什么问题?
这是我的代码的一部分。而且我很确定我的 toGray 函数没有任何问题,我用它通过 Open CV 将图像转换为灰度。
func didSelectPhoto(_ image: UIImage?) {
if let image = image {
self.setupElementsVisibility(true)
let gray = OpenCVWrapper.toGray(image)
self.imageContainer.image = gray
} else {
self.setupElementsVisibility(true)
}
self.dismiss(animated: true, completion: nil)
}
解决方案
推荐阅读
- pycharm - PyCharm:是否可以自动完成这些关键字参数(**kwargs)?
- google-bigquery - 在 bigquery 中了解一个月的周数
- javascript - Laravel 5.3 Elixir Webpack - 不会将 Object.assign 转换为 EcmaScript 2015
- angular - 错误:文档未定义,构建角度通用应用程序
- android - 是否可以在 Google Map 中的标记的一小块区域中收听点击?
- reactjs - React Native 识别对象中的布尔值
- python - 将 Django 模型字段从 TextField 迁移到 ArrayField
- java - Siddhi HTTP NoSuchMethodError
- php - Making database results array into variables php
- android - 反应原生,检测视图屏幕恢复