One way would be to alter the saturation.
In C++:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
using namespace std;
int main(void)
{
Mat frame = imread("rainbow.jpg");
if (frame.empty())
{
cout << "Could not read image file." << endl;
return 1;
}
Mat hsv;
cvtColor(frame, hsv, CV_BGR2HSV);
for (int j = 0; j < frame.rows; j++)
for (int i = 0; i < frame.cols; i++)
hsv.at<Vec3b>(j, i)[1] = 255;
cvtColor(hsv, frame, CV_HSV2BGR);
imshow("frame", frame);
waitKey(0);
return 0;
}
In Python:
import cv2
import numpy
frame = cv2.imread('rainbow.jpg')
if frame is None:
print('Error loading image')
exit()
rows = frame.shape[0]
cols = frame.shape[1]
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV);
for i in range(0, cols):
for j in range(0, rows):
hsv[j, i][1] = 255;
frame = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR);
cv2.imshow("Frame", frame)
cv2.waitKey(0)