Gammakorrektur mit PowC++

Programme in C++. Entwicklerforum
Anonymous
 Gammakorrektur mit Pow

Post by Anonymous »

Ich würde die Gammakorrektur für ein Bild verwenden.
Also muss ich die Intensität jedes Pixels meines Quellbilds mit einem G = 0,6 erhöhen.
Ich habe ein Problem, weil das Zielbild völlig falsch ist.
Vielleicht habe ich ein Casting-Problem, wenn ich Pixel aus dem Quellbild nehme.
Hier mein Code:

Code: Select all

#include 
#include 
#include 
#include 

using namespace cv;
using namespace std;

int main() {

Mat src = imread("spine1.jpeg");

Mat dst = Mat(src.rows, src.cols, CV_8UC1);
cvtColor(src, src, CV_8UC1);
dst = Scalar(0);

for (int x = 0; x < src.rows; x++) {
for (int y = 0; y < src.cols; y++) {
int pixelValue = (int)src.at(x, y);

dst.at(x, y) = pow(pixelValue, 0.6);

}
}

namedWindow("Input", CV_WINDOW_AUTOSIZE);
namedWindow("Output", CV_WINDOW_AUTOSIZE);

imshow("Input", src);
imshow("Output", dst);

waitKey(0);
return 0;
}
Bearbeiten: cvtColor(src, src, CV_8UC1); ändern in cvtColor(src, src, COLOR_BGR2GRAY);

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post