How to make such construction return values form 0 to 1?
It give me only 1s
int maxVal;
int minVal;
int wh = w*h;
int values[1000];
for(x=0;x<w;x++){
for开发者_如何转开发(y=0;y<h;y++){
double RealColor = cvGetReal2D(source, y, x);
values[x*y + y] = RealColor;
}
}
minVal = *min_element(values,(values+wh));
maxVal = *max_element(values,(values+wh));
float dif = maxVal - minVal;
float fminVal;
fminVal = minVal;
for(x=0;x<w;x++){
for(y=0;y<h;y++){
float rc = cvGetReal2D(source, y, x);
float normRealColor =(rc - fminVal + 1) / dif;
file << normRealColor << " ";
}
file << endl;
}file << endl;
How to make it to return not only 1 or 0 but 0, 0.1 0.001 ... 1 HOW??? wall
The values
array is an array of int
, so it can only contain integers rather than floating-point numbers. Does changing it to float
or double
fix the problem? Also, your indexing expression x*y + y
is incorrect: it should be x*h + y
or w*y + x
.
精彩评论