colorModel help

Ok so I am trying to figure out how to work with images and color…so

img.ColorModel()

gives an output like:

[{a1 b1 c1 d1} {a2 b2 c2 d2}… ]

Now, I’m trying to figure out what I can do with this. How can I find out the data structure type. Also, how do I find the number of such 4-element groups?

It looks like an array, but definitely not an array…because I cant seem to put {a b c d} into an array…

Any ideas?

What do you mean by this? Do you mean what the image file format is (BMP vs. PNG, JPEG, etc.) or which implementation of color.Model you’re getting from image.Image.ColorModel (e.g. RGBAModel vs. CMYKModel vs. Gray16Model, etc.)? In either case, what is it you’re trying to do that makes this matter?

Can you show the code you’re using to get those 4-element groups?

Hi, so I was just tinkering with each function available and trying to do things on the image. The code is not much. The four element groups is the output of imgData.ColorModel().
What I am trying to do:

  1. extract the color model into arrays or something and tweak each value
  2. make an empty image rectangle of bound = length of color model, and paste the color model onto the empty image
    (thereby making a color palette) :man_shrugging:

package main

import (
“fmt”
“image”
_ “image/jpeg”
_ “image/png”
“log”
“os”
)

func main() {
file, err := os.Open(“cat.png”)
if err != nil {
log.Println(err)
}
imgData, imgType, err := image.Decode(file)
if err != nil {
log.Println(err)
}
//myImg := image.NewRGBA(image.Rect(0, 0, 1, 1))
fmt.Println(imgData.ColorModel())
fmt.Println(imgData.At(0, 0))
fmt.Println(imgType)
}

oh and by data type, I meant I tried indexing the model like imgData.ColorModel()[1] , but it’s not allowed…