Liking cljdoc? Tell your friends :D

hara.image.base.common


base-mapclj

(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?

returns the base-map of an image

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

color->standard-colorclj

(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]}

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]}
raw docstring

convertclj

(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]]

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]]
raw docstring

convert-baseclj

(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]]

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]]
raw docstring

copyclj

(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]

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]
raw docstring

create-channelsclj

(create-channels model length)

creates channels based on the image

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

creates channels based on the image

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

display-standard-dataclj

(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]}

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]}
raw docstring

emptyclj

(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))})

creates an empty image

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

gray->standard-grayclj

(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]

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]
raw docstring

mask-valueclj

(mask-value v start mask)

gets a value out according to the mask applied

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

gets a value out according to the mask applied

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

retrieve-allclj

(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]}

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]}

raw docstring

retrieve-singleclj

(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]

returns the byte representation of a 

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

raw docstring

set-allclj

(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]]]

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]]]
raw docstring

set-singleclj

(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]

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]
raw docstring

set-single-valclj

(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]

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]
raw docstring

shift-valueclj

(shift-value v scale)

shifts the value according to the scaling

(shift-value 4 2) => 16

(shift-value 4 -2) => 1

shifts the value according to the scaling

(shift-value 4 2)
=> 16

(shift-value 4 -2)
=> 1
raw docstring

sliceclj

(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]

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]
raw docstring

standard-color->standard-grayclj

(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]

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]
raw docstring

standard-color-data->standard-grayclj

(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]

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]
raw docstring

standard-gray->standard-colorclj

(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]}

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]}
raw docstring

standard-type->standard-typeclj

(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]}

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]}
raw docstring

standard-type->typeclj

(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]]

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]]
raw docstring

subimageclj

(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]}

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]}
raw docstring

type->standard-typeclj

(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]

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]

raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close