std.image.base.common

base-map

added in 3.0

(base-map image)

returns the base-map of an image

(-> (awt/image {:size 2 1 :model :byte-gray :data (byte-array 10 20)}) (base-map)) => map?

color->standard-color

added in 3.0

(color->standard-color {:keys [size model], :as image})

converts a color image to the standard color image

(->> {:model (model/model :3-byte-bgr) :size 2 1 :data (byte-array 3 4 5 6 8 10)} (color->standard-color) :data display-standard-data) => {:alpha -1 -1 :red 5 10 :green 4 8 :blue 3 6}

convert

added in 3.0

(convert image)(convert image to-model)

converts from any image representation into a map representation

(-> {:model (model/model :ushort-gray) :size 2 1 :data (short-array 2560 5120)} (convert (model/model :3ch-byte-rgb)) :data (->> (mapv vec))) => [10 20 10 20 10 20]

convert-base

added in 3.0

(convert-base {:keys [data size], :as image} model)

converts from one image to another, via standard

(-> {:model (model/model :ushort-gray) :size 2 1 :data (short-array 2560 5120)} (convert-base (model/model :3ch-byte-rgb)) :data (->> (mapv vec))) => [10 20 10 20 10 20]

copy

added in 3.0

(copy {:keys [model data size], :as image})

returns a copy of the image

(-> (copy {:size 4 1 :model (model/model :ushort-555-rgb) :data (short-array 1 2 3 4)}) :data vec) => 1 2 3 4

create-channels

added in 3.0

(create-channels model length)

creates channels based on the image

(-> (create-channels (model/model :int-argb) 4) first vec) => 0 0 0 0

display-standard-data

added in 3.0

(display-standard-data data)

converts array into vector

(display-standard-data {:red (byte-array 1 2 3) :green (byte-array 4 5 6) :blue (byte-array 7 8 9)}) => {:red 1 2 3, :green 4 5 6, :blue 7 8 9}

empty

added in 3.0

(empty size model)

creates an empty image

(empty 100 100(model/model :int-argb)) => (contains {:size {:width 100, :height 100} :model map? :data #(-> % count (= 10000))})

gray->standard-gray

added in 3.0

(gray->standard-gray {:keys [size], :as image})

converts a gray image to the standard gray image

(->> {:model (model/model :ushort-gray) :size 2 1 :data (short-array 256 (* 8 256))} (gray->standard-gray) :data :raw vec) => 1 8

mask-value

added in 3.0

(mask-value v start mask)

gets a value out according to the mask applied

(mask-value 20 ;; 010100 2 ;; ||| 7 ;; 111 ) ;; ||| => 5 ;; 101

retrieve-all

added in 3.0

(retrieve-all {:keys [model data], :as image} length)

returns the color properties of the image:

(->> (retrieve-all {:type :3ch-byte-rgb :model (model/model :3ch-byte-rgb) :data [(byte-array 3 4) (byte-array 4 8) (byte-array 5 10)]} 2) display-standard-data) => {:red 3 4, :green 4 8, :blue 5 10}

retrieve-single

added in 3.0

(retrieve-single from to name model length)

returns the byte representation of a

(vec (retrieve-single (short-array 4024 8024) (byte-array 2) :raw (model/model :ushort-gray) 2)) => 15 31

set-all

added in 3.0

(set-all from-channels to-channels to-model length)

sets all channels according to the given model

(-> (set-all [(byte-array 255 255) (byte-array 10 40) (byte-array 20 50) (byte-array 30 60)] (byte-array 4) (short-array 2) {:type :color :label :custom :meta {:type Byte/TYPE, :span 2} {:type Short/TYPE, :span 1} :channel {:count 2 :fn identity :inv identity} :data {:alpha {:type Byte/TYPE :channel 0 :index 0} :red {:type Byte/TYPE :channel 0 :index 1}, :green {:type Byte/TYPE :channel 1 :index 0 :access 8 8}, :blue {:type Byte/TYPE :channel 1 :index 0 :access 0 8}}} 2) ((fn barr iarr [(vec barr) (util/>> iarr 8 8)]))) => [-1 10 -1 40 [20 30 50 60]]

set-single

added in 3.0

(set-single from-channels to-channel to-channel-model table length)

sets a single channel given model and table

(-> (set-single [(byte-array 10 20)] (short-array 2) (-> (model/model :ushort-gray) (get-in :meta 0)) {0 {0 nil}} 2) vec) => 2560 5120

set-single-val

added in 3.0

(set-single-val data entries from-size to-size)

helper function to calculate single value from channel inputs

(-> (set-single-val 1 2 3 4 {0 0 8 1 8 8 2 16 8 3 24 8} 8 32) (util/>> 8 8 8 8)) => 4 3 2 1

shift-value

added in 3.0

(shift-value v scale)

shifts the value according to the scaling

(shift-value 4 2) => 16

(shift-value 4 -2) => 1

slice

added in 3.0

(slice {:keys [size model data], :as image} name)

given a key gets a slice of an image, putting it in a new one

(-> (slice {:size 2 1 :model (model/model :3ch-byte-rgb) :data [(byte-array 3 4) (byte-array 4 8) (byte-array 5 10)]} :red) :data vec) => 3 4

standard-color->standard-gray

added in 3.0

(standard-color->standard-gray {:keys [size data], :as image})

converts data of standard-argb image standard-gray

(-> {:model :standard-argb :size 2 1 :data {:alpha (byte-array -1 -1) :red (byte-array 1 2) :green (byte-array 3 4) :blue (byte-array 5 6)}} standard-color->standard-gray :data :raw vec) => 3 4

standard-color-data->standard-gray

added in 3.0

(standard-color-data->standard-gray {:keys [alpha red green blue]} to-bytes length)

converts data of standard-argb to standard-gray

(vec (standard-color-data->standard-gray {:alpha (byte-array -1 -1) :red (byte-array 1 2) :green (byte-array 3 4) :blue (byte-array 5 6)} (byte-array 2) 2)) => 3 4

standard-gray->standard-color

added in 3.0

(standard-gray->standard-color {:keys [size data], :as image})

converts data of standard-gray image to standard-argb

(-> {:model :standard-gray :size 2 1 :data {:raw (byte-array 3 4)}} standard-gray->standard-color :data display-standard-data) => {:alpha -1 -1, :red 3 4, :green 3 4, :blue 3 4}

standard-type->standard-type

added in 3.0

(standard-type->standard-type {:keys [model], :as image} type)

converts between standard types

(-> {:model (model/model :standard-argb) :size 2 1 :data {:alpha (byte-array -1 -1) :red (byte-array 1 2) :green (byte-array 3 4) :blue (byte-array 5 6)}} ;; Does not change (standard-type->standard-type :color) ;; Converts to gray (standard-type->standard-type :gray) :data display-standard-data) => {:raw 3 4}

standard-type->type

added in 3.0

(standard-type->type {:keys [data size], :as standard} model)

converts a standard-image to another of the same type (color->color), (gray->gray)

(-> {:model (model/model :standard-gray) :size 2 1 :data {:raw (byte-array 10 20)}} (standard-gray->standard-color) (standard-type->type (model/model :ushort-555-rgb)) :data (util/>> 5 5 5)) => [1 1 1 2 2 2]

subimage

added in 3.0

(subimage {:keys [model data size], :as image} x y w h)

returns a subimage of an original image

(-> (subimage {:model (model/model :standard-argb) :size 2 2 :data {:alpha (byte-array 255 255 255 255) :red (byte-array 10 20 30 40) :green (byte-array 50 60 70 80) :blue (byte-array 90 100 110 120)}} 0 0 1 2) :data display-standard-data) => {:alpha -1 -1, :red 10 30, :green 50 70, :blue 90 110}

type->standard-type

added in 3.0

(type->standard-type {:keys [model], :as image})

converts a color image to the standard color image

(->> {:model (model/model :ushort-gray) :size 2 1 :data (short-array 256 (* 8 256))} (type->standard-type) :data :raw vec) => 1 8