• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

減色プログラム


Commit MetaInfo

Revision67e551fdb121c01fa39e8f7572d283f740f49a5a (tree)
Zeit2011-05-17 01:57:56
Autorberupon <berupon@gmai...>
Commiterberupon

Log Message

型をdoubleからfloatに変更できるところを変更。

Ändern Zusammenfassung

Diff

--- a/main.cpp
+++ b/main.cpp
@@ -23,15 +23,15 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2323 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2424 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2525 */
26-
27-
28-#include "stdafx.h"
29-
30-#include "Color4f.h"
31-#include "Array.h"
32-
33-typedef Array2D<Color4f> Image4f;
34-
26+
27+
28+#include "stdafx.h"
29+
30+#include "Color4f.h"
31+#include "Array.h"
32+
33+typedef Array2D<Color4f> Image4f;
34+
3535 #include <algorithm>
3636 #include <math.h>
3737 #include <stdio.h>
@@ -40,91 +40,91 @@ typedef Array2D<Color4f> Image4f;
4040 #include <deque>
4141 #include <limits>
4242 #include <iostream>
43-
44-#include "ReadImage/ReadImage.h"
45-#include "ReadImage/File.h"
46-
47-#include "quantize.h"
48-
49-// http://proglab.aki.gs/mediaproc/colors.html
50-
51-int _tmain(int argc, _TCHAR* argv[])
52-{
53- if (argc < 1+3 || argc > 1+5) {
54- puts("Usage: color_quantizer <source image.bmp> <output image.raw> <desired palette size> [dithering level] [filter size (1/3/5)]\n");
55- return -1;
56- }
57-
58- int num_colors = _ttoi(argv[3]);
43+
44+#include "ReadImage/ReadImage.h"
45+#include "ReadImage/File.h"
46+
47+#include "quantize.h"
48+
49+// http://proglab.aki.gs/mediaproc/colors.html
50+
51+int _tmain(int argc, _TCHAR* argv[])
52+{
53+ if (argc < 1+3 || argc > 1+5) {
54+ puts("Usage: color_quantizer <source image.bmp> <output image.raw> <desired palette size> [dithering level] [filter size (1/3/5)]\n");
55+ return -1;
56+ }
57+
58+ int num_colors = _ttoi(argv[3]);
5959 if (num_colors <= 1 || num_colors > 256) {
6060 printf("Number of colors must be at least 2 and no more than 256.\n");
6161 return -1;
6262 }
63-
64- srand(time(NULL));
65-
66- ImageInfo imageInfo;
67- FILE* f = _tfopen(argv[1], _T("rb"));
68- File file(f);
69- if (!ReadImageInfo(file, imageInfo)) {
70- puts("failed to open image\n");
71- return 0;
72- }
73- if (
74- imageInfo.bitsPerSample != 8
75- || (imageInfo.samplesPerPixel != 3 && imageInfo.samplesPerPixel != 4)
76- ) {
77- puts("unsupported image file format.\n");
78- return 0;
79- }
80- size_t lineBytes = imageInfo.samplesPerPixel * imageInfo.width;
81- if (lineBytes % 4) {
82- lineBytes += 4 - (lineBytes % 4);
83- }
84- std::vector<uint8_t> buff(lineBytes * imageInfo.height);
85- ReadImageData(file, &buff[0], lineBytes, 0);
86- fclose(f);
87- uint8_t* p = &buff[0];
88-
89- size_t width = imageInfo.width;
90- size_t height = imageInfo.height;
91- Image4f image(width, height);
92- Color4f* pLine = image.pBuff_;
93- uint8_t* pSrcLine = p;
94- for (size_t y=0; y<height; ++y) {
95- for (size_t x=0; x<width; ++x) {
96- float r = pSrcLine[x*3+0] / 255.0f;
97- float g = pSrcLine[x*3+1] / 255.0f;
98- float b = pSrcLine[x*3+2] / 255.0f;
99- pLine[x] = Color4f(r,g,b,0.0f);
100- }
101- pLine += width;
102- pSrcLine += lineBytes;
103- }
104- Color4f buff_filter1_weights[1*1];
105- Color4f buff_filter3_weights[3*3];
106- Color4f buff_filter5_weights[5*5];
107-
108- Image4f filter1_weights(1, 1, buff_filter1_weights);
109- Image4f filter3_weights(3, 3, buff_filter3_weights);
110- Image4f filter5_weights(5, 5, buff_filter5_weights);
111- std::vector<uint8_t> buff_quantized(width * height);
112- Array2D<uint8_t> quantized_image(width, height, &buff_quantized[0]);
113- Color4f palette[256];
114-
115- filter1_weights[0][0] = Color4f(1.0f, 1.0f, 1.0f, 0.0f);
116-
117- for (size_t i=0; i<num_colors; ++i) {
118- palette[i] = Color4f(
119- ((float)rand())/RAND_MAX,
120- ((float)rand())/RAND_MAX,
121- ((float)rand())/RAND_MAX,
122- 0.0f
123- );
124- }
125-
126- Array3D<double>* coarse_variables;
127- double dithering_level = 0.09*log((double)image.width_*image.height_) - 0.04*log((double)num_colors) + 0.001;
63+
64+ srand(time(NULL));
65+
66+ ImageInfo imageInfo;
67+ FILE* f = _tfopen(argv[1], _T("rb"));
68+ File file(f);
69+ if (!ReadImageInfo(file, imageInfo)) {
70+ puts("failed to open image\n");
71+ return 0;
72+ }
73+ if (
74+ imageInfo.bitsPerSample != 8
75+ || (imageInfo.samplesPerPixel != 3 && imageInfo.samplesPerPixel != 4)
76+ ) {
77+ puts("unsupported image file format.\n");
78+ return 0;
79+ }
80+ size_t lineBytes = imageInfo.samplesPerPixel * imageInfo.width;
81+ if (lineBytes % 4) {
82+ lineBytes += 4 - (lineBytes % 4);
83+ }
84+ std::vector<uint8_t> buff(lineBytes * imageInfo.height);
85+ ReadImageData(file, &buff[0], lineBytes, 0);
86+ fclose(f);
87+ uint8_t* p = &buff[0];
88+
89+ size_t width = imageInfo.width;
90+ size_t height = imageInfo.height;
91+ Image4f image(width, height);
92+ Color4f* pLine = image.pBuff_;
93+ uint8_t* pSrcLine = p;
94+ for (size_t y=0; y<height; ++y) {
95+ for (size_t x=0; x<width; ++x) {
96+ float r = pSrcLine[x*3+0] / 255.0f;
97+ float g = pSrcLine[x*3+1] / 255.0f;
98+ float b = pSrcLine[x*3+2] / 255.0f;
99+ pLine[x] = Color4f(r,g,b,0.0f);
100+ }
101+ pLine += width;
102+ pSrcLine += lineBytes;
103+ }
104+ Color4f buff_filter1_weights[1*1];
105+ Color4f buff_filter3_weights[3*3];
106+ Color4f buff_filter5_weights[5*5];
107+
108+ Image4f filter1_weights(1, 1, buff_filter1_weights);
109+ Image4f filter3_weights(3, 3, buff_filter3_weights);
110+ Image4f filter5_weights(5, 5, buff_filter5_weights);
111+ std::vector<uint8_t> buff_quantized(width * height);
112+ Array2D<uint8_t> quantized_image(width, height, &buff_quantized[0]);
113+ Color4f palette[256];
114+
115+ filter1_weights[0][0] = Color4f(1.0f, 1.0f, 1.0f, 0.0f);
116+
117+ for (size_t i=0; i<num_colors; ++i) {
118+ palette[i] = Color4f(
119+ ((float)rand())/RAND_MAX,
120+ ((float)rand())/RAND_MAX,
121+ ((float)rand())/RAND_MAX,
122+ 0.0f
123+ );
124+ }
125+
126+ Array3D<float>* coarse_variables;
127+ float dithering_level = 0.09*log((float)image.width_*image.height_) - 0.04*log((float)num_colors) + 0.001;
128128 if (argc > 1+3) {
129129 dithering_level = _ttof(argv[4]);
130130 if (dithering_level <= 0.0) {
@@ -141,11 +141,11 @@ int _tmain(int argc, _TCHAR* argv[])
141141 }
142142 }
143143
144- double stddev = dithering_level;
145- double sum = 0.0;
144+ float stddev = dithering_level;
145+ float sum = 0.0;
146146 for (int i=0; i<3; i++) {
147147 for (int j=0; j<3; j++) {
148- double w = exp(-sqrt((double)((i-1)*(i-1) + (j-1)*(j-1)))/(stddev*stddev));
148+ float w = exp(-sqrt((float)((i-1)*(i-1) + (j-1)*(j-1)))/(stddev*stddev));
149149 filter3_weights[i][j] = Color4f(w,w,w,0);
150150 sum += 3 * w;
151151 }
@@ -161,7 +161,7 @@ int _tmain(int argc, _TCHAR* argv[])
161161 sum = 0.0;
162162 for (int i=0; i<5; i++) {
163163 for (int j=0; j<5; j++) {
164- double w = exp(-sqrt((double)((i-2)*(i-2) + (j-2)*(j-2)))/(stddev*stddev));
164+ float w = exp(-sqrt((float)((i-2)*(i-2) + (j-2)*(j-2)))/(stddev*stddev));
165165 filter5_weights[i][j] = Color4f(w,w,w,0);
166166 sum += 3 * w;
167167 }
@@ -183,8 +183,8 @@ int _tmain(int argc, _TCHAR* argv[])
183183 NULL,
184184 &filter5_weights
185185 };
186- spatial_color_quant(image, *filters[filter_size], quantized_image, palette, num_colors, coarse_variables, 1.0, 0.001, 3, 1);
187-
186+ spatial_color_quant(image, *filters[filter_size], quantized_image, palette, num_colors, coarse_variables, 1.0, 0.001, 3, 1);
187+
188188 {
189189 FILE* out = _tfopen(argv[2], _T("wb"));
190190 if (out == NULL) {
@@ -194,15 +194,17 @@ int _tmain(int argc, _TCHAR* argv[])
194194 unsigned char c[3] = {0,0,0};
195195 for (int y=0; y<height; y++) {
196196 for (int x=0; x<width; x++) {
197- c[2] = (unsigned char)(255*palette[quantized_image[y][x]][0]);
198- c[1] = (unsigned char)(255*palette[quantized_image[y][x]][1]);
199- c[0] = (unsigned char)(255*palette[quantized_image[y][x]][2]);
197+ const uint8_t idx = quantized_image[y][x];
198+ Color4f col = palette[idx];
199+ c[2] = (unsigned char)(255*col[0]);
200+ c[1] = (unsigned char)(255*col[1]);
201+ c[0] = (unsigned char)(255*col[2]);
200202 fwrite(c, 3, 1, out);
201203 }
202204 }
203205 fclose(out);
204206 }
205-
206- return 0;
207-}
208-
207+
208+ return 0;
209+}
210+
--- a/quantize.cpp
+++ b/quantize.cpp
@@ -1,5 +1,5 @@
1-#include "stdafx.h"
2-
1+#include "stdafx.h"
2+
33 #include <algorithm>
44 #include <math.h>
55 #include <stdio.h>
@@ -8,14 +8,14 @@
88 #include <deque>
99 #include <limits>
1010 #include <iostream>
11-
12-using namespace std;
13-
14-#include "Array.h"
15-#include "Color4f.h"
16-
17-typedef Array2D<Color4f> Image4f;
18-
11+
12+using namespace std;
13+
14+#include "Array.h"
15+#include "Color4f.h"
16+
17+typedef Array2D<Color4f> Image4f;
18+
1919 int compute_max_coarse_level(int width, int height)
2020 {
2121 // We want the coarsest layer to have at most MAX_PIXELS pixels
@@ -29,23 +29,23 @@ int compute_max_coarse_level(int width, int height)
2929 return result;
3030 }
3131
32-void fill_random(Array3D<double>& a)
32+void fill_random(Array3D<float>& a)
3333 {
3434 for (int i=0; i<a.width_; i++) {
3535 for (int j=0; j<a.height_; j++) {
3636 for (int k=0; k<a.depth_; k++) {
37- a[k][j][i] = ((double)rand())/RAND_MAX;
37+ a[k][j][i] = ((float)rand())/RAND_MAX;
3838 }
3939 }
4040 }
41-}
42-
43-double get_initial_temperature()
41+}
42+
43+float get_initial_temperature()
4444 {
4545 return 2.0; // TODO: Figure out what to make this
4646 }
4747
48-double get_final_temperature()
48+float get_final_temperature()
4949 {
5050 return 0.02; // TODO: Figure out what to make this
5151 }
@@ -81,7 +81,7 @@ void init_image(Image4f& image)
8181 {
8282 std::fill(image.pBuff_, image.pBuff_+image.width_*image.height_, Color4f(0.0f,0.0f,0.0f,0.0f));
8383 }
84-
84+
8585 void compute_b_array(
8686 const Image4f& filter_weights,
8787 Image4f& b
@@ -157,7 +157,7 @@ void sum_coarsen(
157157 {
158158 for (int y=0; y<coarse.height_; y++) {
159159 for (int x=0; x<coarse.width_; x++) {
160- double divisor = 1.0;
160+ float divisor = 1.0;
161161 Color4f val = fine[y*2][x*2];
162162 if (x*2 + 1 < fine.width_) {
163163 divisor += 1; val += fine[y*2][x*2 + 1];
@@ -195,7 +195,7 @@ vector<float> extract_vector_layer_1d(const Color4f* s, size_t sz, int k)
195195 }
196196
197197 int best_match_color(
198- const Array3D<double>& vars,
198+ const Array3D<float>& vars,
199199 int i_x,
200200 int i_y,
201201 const Color4f* palette,
@@ -203,7 +203,7 @@ int best_match_color(
203203 )
204204 {
205205 int max_v = 0;
206- double max_weight = vars[0][i_y][i_x];
206+ float max_weight = vars[0][i_y][i_x];
207207 for (size_t v=1; v<num_colors; ++v) {
208208 if (vars[v][i_y][i_x] > max_weight) {
209209 max_v = v;
@@ -213,7 +213,7 @@ int best_match_color(
213213 return max_v;
214214 }
215215
216-void zoom_double(const Array3D<double>& small, Array3D<double>& big)
216+void zoom(const Array3D<float>& small, Array3D<float>& big)
217217 {
218218 // Simple scaling of the weights array based on mixing the four
219219 // pixels falling under each fine pixel, weighted by area.
@@ -221,19 +221,19 @@ void zoom_double(const Array3D<double>& small, Array3D<double>& big)
221221 // is 1.2 fine pixels wide and high.
222222 for (int y=0; y<big.height_/2*2; y++) {
223223 for (int x=0; x<big.width_/2*2; x++) {
224- double left = max(0.0, (x-0.1)/2.0), right = min(small.width_-0.001, (x+1.1)/2.0);
225- double top = max(0.0, (y-0.1)/2.0), bottom = min(small.height_-0.001, (y+1.1)/2.0);
224+ float left = max(0.0, (x-0.1)/2.0), right = min(small.width_-0.001, (x+1.1)/2.0);
225+ float top = max(0.0, (y-0.1)/2.0), bottom = min(small.height_-0.001, (y+1.1)/2.0);
226226 int x_left = (int)floor(left), x_right = (int)floor(right);
227227 int y_top = (int)floor(top), y_bottom = (int)floor(bottom);
228- double area = (right-left)*(bottom-top);
229- double top_left_weight = (ceil(left) - left)*(ceil(top) - top)/area;
230- double top_right_weight = (right - floor(right))*(ceil(top) - top)/area;
231- double bottom_left_weight = (ceil(left) - left)*(bottom - floor(bottom))/area;
232- double bottom_right_weight = (right - floor(right))*(bottom - floor(bottom))/area;
233- double top_weight = (right-left)*(ceil(top) - top)/area;
234- double bottom_weight = (right-left)*(bottom - floor(bottom))/area;
235- double left_weight = (bottom-top)*(ceil(left) - left)/area;
236- double right_weight = (bottom-top)*(right - floor(right))/area;
228+ float area = (right-left)*(bottom-top);
229+ float top_left_weight = (ceil(left) - left)*(ceil(top) - top)/area;
230+ float top_right_weight = (right - floor(right))*(ceil(top) - top)/area;
231+ float bottom_left_weight = (ceil(left) - left)*(bottom - floor(bottom))/area;
232+ float bottom_right_weight = (right - floor(right))*(bottom - floor(bottom))/area;
233+ float top_weight = (right-left)*(ceil(top) - top)/area;
234+ float bottom_weight = (right-left)*(bottom - floor(bottom))/area;
235+ float left_weight = (bottom-top)*(ceil(left) - left)/area;
236+ float right_weight = (bottom-top)*(right - floor(right))/area;
237237 for (int z=0; z<big.depth_; z++) {
238238 if (x_left == x_right && y_top == y_bottom) {
239239 big[z][y][x] = small[z][y_top][x_left];
@@ -256,7 +256,7 @@ void zoom_double(const Array3D<double>& small, Array3D<double>& big)
256256
257257 void compute_initial_s(
258258 Image4f& s,
259- const Array3D<double>& coarse_variables,
259+ const Array3D<float>& coarse_variables,
260260 const Image4f& b
261261 )
262262 {
@@ -282,7 +282,7 @@ void compute_initial_s(
282282 Color4f b_ij = b_value(b,i_x,i_y,j_x,j_y);
283283 for (int v=0; v<palette_size; v++) {
284284 for (int alpha=v; alpha<palette_size; alpha++) {
285- double mult = coarse_variables[v][i_y][i_x] * coarse_variables[alpha][j_y][j_x];
285+ float mult = coarse_variables[v][i_y][i_x] * coarse_variables[alpha][j_y][j_x];
286286 s[alpha][v][0] += mult * b_ij[0];
287287 s[alpha][v][1] += mult * b_ij[1];
288288 s[alpha][v][2] += mult * b_ij[2];
@@ -299,12 +299,12 @@ void compute_initial_s(
299299
300300 void update_s(
301301 Image4f& s,
302- const Array3D<double>& coarse_variables,
302+ const Array3D<float>& coarse_variables,
303303 const Image4f& b,
304304 int j_x,
305305 int j_y,
306306 int alpha,
307- double delta
307+ float delta
308308 )
309309 {
310310 int palette_size = s.width_;
@@ -318,13 +318,13 @@ void update_s(
318318 Color4f delta_b_ij = delta*b_value(b,i_x,i_y,j_x,j_y);
319319 if (i_x == j_x && i_y == j_y) continue;
320320 for (int v=0; v <= alpha; v++) {
321- double mult = coarse_variables[v][i_y][i_x];
321+ float mult = coarse_variables[v][i_y][i_x];
322322 s[alpha][v][0] += mult * delta_b_ij[0];
323323 s[alpha][v][1] += mult * delta_b_ij[1];
324324 s[alpha][v][2] += mult * delta_b_ij[2];
325325 }
326326 for (int v=alpha; v<palette_size; v++) {
327- double mult = coarse_variables[v][i_y][i_x];
327+ float mult = coarse_variables[v][i_y][i_x];
328328 s[v][alpha][0] += mult * delta_b_ij[0];
329329 s[v][alpha][1] += mult * delta_b_ij[1];
330330 s[v][alpha][2] += mult * delta_b_ij[2];
@@ -336,7 +336,7 @@ void update_s(
336336
337337 void refine_palette(
338338 Image4f& s,
339- const Array3D<double>& coarse_variables,
339+ const Array3D<float>& coarse_variables,
340340 const Image4f& a,
341341 Color4f* palette,
342342 size_t num_colors
@@ -354,7 +354,7 @@ void refine_palette(
354354 Color4f sum(0,0,0,0);
355355 for (int i_y=0; i_y<coarse_variables.height_; i_y++) {
356356 for (int i_x=0; i_x<coarse_variables.width_; i_x++) {
357- double cv = coarse_variables[v][i_y][i_x];
357+ float cv = coarse_variables[v][i_y][i_x];
358358 Color4f av = a[i_y][i_x];
359359 Color4f result = cv * av;
360360 sum += result;
@@ -368,7 +368,7 @@ void refine_palette(
368368 vector<float> R_k = extract_vector_layer_1d(&r[0], num_colors, k);
369369 vector<float> palette_channel = -1.0f*((2.0f*S_k).matrix_inverse())*R_k;
370370 for (unsigned int v=0; v<num_colors; v++) {
371- double val = palette_channel[v];
371+ float val = palette_channel[v];
372372 if (val < 0) val = 0;
373373 if (val > 1) val = 1;
374374 palette[v][k] = val;
@@ -384,7 +384,7 @@ void refine_palette(
384384
385385 void compute_initial_j_palette_sum(
386386 Image4f& j_palette_sum,
387- const Array3D<double>& coarse_variables,
387+ const Array3D<float>& coarse_variables,
388388 const Color4f* palette,
389389 size_t num_colors
390390 )
@@ -405,23 +405,23 @@ void spatial_color_quant(
405405 Image4f& filter_weights,
406406 Array2D<uint8_t>& quantized_image,
407407 Color4f* palette, size_t num_colors,
408- Array3D<double>*& p_coarse_variables,
409- double initial_temperature,
410- double final_temperature,
408+ Array3D<float>*& p_coarse_variables,
409+ float initial_temperature,
410+ float final_temperature,
411411 int temps_per_level,
412412 int repeats_per_temp
413413 )
414-{
414+{
415415 int max_coarse_level = //1;
416416 compute_max_coarse_level(image.width_, image.height_);
417417 size_t width2 = image.width_ >> max_coarse_level;
418418 size_t height2 = image.height_ >> max_coarse_level;
419- p_coarse_variables = new Array3D<double>(width2, height2, num_colors);
419+ p_coarse_variables = new Array3D<float>(width2, height2, num_colors);
420420 // For syntactic convenience
421- Array3D<double>& coarse_variables = *p_coarse_variables;
421+ Array3D<float>& coarse_variables = *p_coarse_variables;
422422 fill_random(coarse_variables);
423423
424- double temperature = initial_temperature;
424+ float temperature = initial_temperature;
425425
426426 // Compute a_i, b_{ij} according to (11)
427427 int extended_neighborhood_width = filter_weights.width_*2 - 1;
@@ -463,12 +463,12 @@ void spatial_color_quant(
463463 Image4f& ai = *p_ai;
464464 sum_coarsen(*a_vec.back(), ai);
465465 a_vec.push_back(p_ai);
466- }
467-
466+ }
467+
468468 // Multiscale annealing
469469 coarse_level = max_coarse_level;
470470 const int iters_per_level = temps_per_level;
471- double temperature_multiplier = pow(final_temperature/initial_temperature, 1.0/(max(3, max_coarse_level*iters_per_level)));
471+ float temperature_multiplier = pow(final_temperature/initial_temperature, 1.0f/(max(3, max_coarse_level*iters_per_level)));
472472 #if TRACE
473473 cout << "Temperature multiplier: " << temperature_multiplier << endl;
474474 #endif
@@ -481,7 +481,7 @@ void spatial_color_quant(
481481 compute_initial_j_palette_sum(*j_palette_sum, coarse_variables, palette, num_colors);
482482 while (coarse_level >= 0 || temperature > final_temperature) {
483483 // Need to reseat this reference in case we changed p_coarse_variables
484- Array3D<double>& coarse_variables = *p_coarse_variables;
484+ Array3D<float>& coarse_variables = *p_coarse_variables;
485485 Image4f& a = *a_vec[coarse_level];
486486 Image4f& b = *b_vec[coarse_level];
487487 Color4f middle_b = b_value(b,0,0,0,0);
@@ -553,7 +553,7 @@ void spatial_color_quant(
553553 // Prevent the matrix S from becoming singular
554554 if (new_val <= 0) new_val = 1e-10;
555555 if (new_val >= 1) new_val = 1 - 1e-10;
556- double delta_m_iv = new_val - coarse_variables[v][i_y][i_x];
556+ float delta_m_iv = new_val - coarse_variables[v][i_y][i_x];
557557 coarse_variables[v][i_y][i_x] = new_val;
558558 j_pal[0] += delta_m_iv*palette[v][0];
559559 j_pal[1] += delta_m_iv*palette[v][1];
@@ -612,11 +612,11 @@ void spatial_color_quant(
612612 {
613613 coarse_level--;
614614 if (coarse_level < 0) break;
615- Array3D<double>* p_new_coarse_variables = new Array3D<double>(
615+ Array3D<float>* p_new_coarse_variables = new Array3D<float>(
616616 image.width_ >> coarse_level,
617617 image.height_ >> coarse_level,
618618 num_colors);
619- zoom_double(coarse_variables, *p_new_coarse_variables);
619+ zoom(coarse_variables, *p_new_coarse_variables);
620620 delete p_coarse_variables;
621621 p_coarse_variables = p_new_coarse_variables;
622622 iters_at_current_level = 0;
@@ -636,19 +636,19 @@ void spatial_color_quant(
636636 // This is normally not used, but is handy sometimes for debugging
637637 while (coarse_level > 0) {
638638 coarse_level--;
639- Array3D<double>* p_new_coarse_variables = new Array3D<double>(
639+ Array3D<float>* p_new_coarse_variables = new Array3D<float>(
640640 image.width_ >> coarse_level,
641641 image.height_ >> coarse_level,
642642 num_colors
643643 );
644- zoom_double(*p_coarse_variables, *p_new_coarse_variables);
644+ zoom(*p_coarse_variables, *p_new_coarse_variables);
645645 delete p_coarse_variables;
646646 p_coarse_variables = p_new_coarse_variables;
647647 }
648648
649649 {
650650 // Need to reseat this reference in case we changed p_coarse_variables
651- Array3D<double>& coarse_variables = *p_coarse_variables;
651+ Array3D<float>& coarse_variables = *p_coarse_variables;
652652
653653 for (int i_x = 0; i_x < image.width_; i_x++) {
654654 for (int i_y = 0; i_y < image.height_; i_y++) {
@@ -666,6 +666,6 @@ void spatial_color_quant(
666666 #endif
667667 }
668668 }
669-
670-}
671-
669+
670+}
671+
--- a/quantize.h
+++ b/quantize.h
@@ -5,9 +5,9 @@ void spatial_color_quant(
55 Image4f& filter_weights,
66 Array2D<uint8_t>& quantized_image,
77 Color4f* palette, size_t num_colors,
8- Array3D<double>*& p_coarse_variables,
9- double initial_temperature,
10- double final_temperature,
8+ Array3D<float>*& p_coarse_variables,
9+ float initial_temperature,
10+ float final_temperature,
1111 int temps_per_level,
1212 int repeats_per_temp
1313 );