OpenCV-如何将vale添加到图像一部分的所有像素
OpenCV - How to add a vale to all the pixels in a part of an image?
我正在尝试为灰度图像的矩形部分添加一个常数值。
这就是我尝试过的:
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
cv::Mat src = imread("img.png", IMREAD_GRAYSCALE);
Mat temp;
temp = src(Range(10, 150), Range(10, 210));
temp.setTo(50);
imshow("src", src);
cvWaitKey(0);
return 0;
}
但是,这会使该区域全部变黑(Scalar(50)
(。我想将50
添加到该范围内的所有像素中。在不使用循环的情况下,这可能吗?
只需调用子矩阵的operator+=
:
temp += 50;
这里列出了矩阵表达式。其中之一是A+s
,其中A
是temp
子矩阵,s
是标量-50。
相关文章:
- 如何在不产生任何垃圾的情况下获得C中的像素
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 如何在24位SDL_Surface上设置像素的颜色
- 如何从SDL_Surface获取特定像素的颜色
- 如何将CMSampleBufferRef/CIImage/UIImage转换为像素,例如uint8_t[]
- 在C++中查找像素 RGB 数据的最快方法是什么?
- 是否可以从 OpenGL 缓冲区获取原始大小的像素?
- 选择基于另一个垫子的非零像素的cv::Mat的一部分?
- 如何使用 sdl2 快速绘制像素网格?
- 如何在C++中进行像素操作? - Linux
- 他们如何将红外锁定像素转换为镜头前方 1m 的正常平面上的位置
- 访问随机图像像素的快速方法,最多一次
- OpenCV 像素访问点与 at() - 不同的值
- 如何使用 freetype2 访问单色位图中的像素状态
- 尝试渲染像素坐标时,简单线条渲染失败
- 计算另一个图像像素满足条件的像素值的平均值
- 如何返回定义良好的内存部分?例如来自图像数据的像素的颜色值
- 在Qt-cpp中通过像素获取QString的子字符串
- 有效地计算像素到其对应核线的距离
- OpenCV-如何将vale添加到图像一部分的所有像素