forked from hkc/cc-stuff
Allocate the correct amount of intermediate centroid data
This commit is contained in:
parent
c5af524dac
commit
c91f4d79bd
|
@ -675,11 +675,12 @@ struct palette *custom_palette_from(const struct palette *orig) {
|
|||
|
||||
struct k_means_state k_means_init(const struct image *image, struct palette *starting_palette) {
|
||||
size_t item_count = image->w * image->h;
|
||||
uint8_t cluster_count = starting_palette->count;
|
||||
struct k_means_state state = {
|
||||
.items = image,
|
||||
.clusters = starting_palette,
|
||||
.predicted_cluster = calloc(image->w, image->h),
|
||||
.centroid_intermediate = calloc(item_count, sizeof(struct k_means_centroid_intermediate)),
|
||||
.centroid_intermediate = calloc(cluster_count, sizeof(struct k_means_centroid_intermediate)),
|
||||
.item_count = item_count,
|
||||
};
|
||||
return state;
|
||||
|
|
Loading…
Reference in New Issue