diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/averagecolor/AverageColor.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/averagecolor/AverageColor.kt index ff63750f..d455ae01 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/averagecolor/AverageColor.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/averagecolor/AverageColor.kt @@ -130,6 +130,6 @@ class AverageColor : Analyser { /* Generate descriptor. */ val averageColor = RGBColorContainer(color[0] / rgb.size, color[1] / rgb.size, color[2] / rgb.size) - return FloatVectorDescriptor(UUID.randomUUID(), null, averageColor.toVector()) + return FloatVectorDescriptor(UUID.randomUUID(), null, averageColor.toVector(false)) } } diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/color/RGBColorContainer.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/color/RGBColorContainer.kt index 536f5bf7..baa12f7a 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/color/RGBColorContainer.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/color/RGBColorContainer.kt @@ -1,5 +1,6 @@ package org.vitrivr.engine.core.model.color +import kotlinx.serialization.json.internal.decodeStringToJsonTree import org.vitrivr.engine.core.model.types.Value import java.awt.color.ColorSpace import kotlin.math.max @@ -163,14 +164,14 @@ value class RGBColorContainer(private val rgb: FloatArray) { * * @return [List] of [Float]s */ - fun toList() = listOf(this.red, this.green, this.blue) + fun toList(rgba: Boolean = false) = if (rgba) listOf(this.red, this.green, this.blue, this.alpha) else listOf(this.red, this.green, this.blue) /** * Converts this [RGBColorContainer] a [Value.FloatVector] * * @return [Value.FloatVector] */ - fun toVector() = Value.FloatVector(this.rgb) + fun toVector(rgba: Boolean = false) = if (rgba) Value.FloatVector(this.rgb) else Value.FloatVector(this.rgb.copyOfRange(0, 3)) /** * Calculates distance to another [RGBColorContainer].