Getting Blackscreen when i run my program
I am running the code but whenever i run it give me the black screen as output rather than some good results which i want
cv::Mat img1 = cv::imread("E:\\raw_3.jpg");
cv::Mat img2 = cv::Mat (img1.size(),img1.type());
std::vector<cv::Mat> colors_1;
cv::split(img2, colors_1);
colors_1[0] = 173;
colors_1[1] = 221;
colors_1[2] = 246;
cv::merge(colors_1,img2);
Mat result(img1.size(), CV_8UC3);
for(int i = 0; i < img1.size().height; ++i){
for(int j = 0; j < img1.size().width; ++j){
for (int c=0 ; c<img1.channels();c++){
uchar target = img1.at<uchar>(i, 3*j+c)/255. ;
uchar blend = img2.at<uchar>(i, 3*j+c)/255. ;
if(target > 0.5){
result.at<uchar>(i, 3*j+c) = cv::saturate_cast<uchar>((1 - (1-target) * (1-2*(blend-0.5))))/255.;
}
else{
result.at<uchar>(i, 3*j+c) = cv::saturate_cast<uchar>(target * (2*blend))/255.;
}
}
}
You are getting black window because
cv::saturate_cast<uchar>((1 - (1-target) * (1-2*(blend-0.5))))/255.;
andcv::saturate_cast<uchar>(target * (2*blend))/255.;
might be giving zero , just print value of those and confirm it.Yes its range is from 0-1 but what would be the solution i tried it with float too
i also tried it using
((1 - (1-target) * (1-2*(blend-0.5))))*255.