Skip to content

Commit

Permalink
Merge branch 'hotfix/average-color-vector-len'
Browse files Browse the repository at this point in the history
  • Loading branch information
net-cscience-raphael committed Sep 11, 2024
2 parents 8d89bba + bd642ef commit 82ca0f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ class AverageColor : Analyser<ImageContent, FloatVectorDescriptor> {

/* 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))
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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].
Expand Down

0 comments on commit 82ca0f9

Please sign in to comment.