Skip to content
Snippets Groups Projects
Commit 51987361 authored by ariotte's avatar ariotte
Browse files

fixed crash when launching LloydMax quantization

parent a2f25e74
No related branches found
No related tags found
No related merge requests found
......@@ -70,6 +70,20 @@ void Quantification::saveAs(std::string filename) {
}
}
int Quantification::valueOf(int value) const {
for(int i = 0; i < nbThresholds(); ++i) {
if(value < _threshold[i]) {
return _values[i];
}
}
return _values[nbThresholds()];
}
Quantification Quantification::linearQuant(int size) {
Quantification quant(size);
......@@ -210,13 +224,13 @@ Quantification Quantification::lloydMaxQuant(int size, const Image* image, unsig
//calcul pdf
for (int j=0; j<size-1;j++){
for (int j=0; j<size-2;j++){
for(int i= ((quant._threshold)[j]); i <= ((quant._threshold)[j+1]); i++){
som_lum += histogram[i]*i;
nb_points += histogram[i];
}
quant._values[j]= (int) quant._values[j]*(som_lum/nb_points) / (som_lum/nb_points);
quant._values[j]= (int) quant._values[j]*(som_lum/nb_points) / (som_lum/nb_points);
}//for (parcours du tableau de valeurs)
cpt--;
......
......@@ -31,14 +31,7 @@ public:
void saveAs(std::string filename);
inline int valueOf(int value) const {
for(int i = 0; i < nbThresholds(); ++i) {
if(value < _threshold[i]) {
return _values[i];
}
}
return _values[nbThresholds()];
}
int valueOf(int value) const ;
inline int nbValues() const {return size;}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment