org.apache.clojure-mxnet.image

Image API of Clojure package.

apply-border

(apply-border input top bottom left right {:keys [fill-type value values output], :or {fill-type nil, value nil, values nil, output nil}, :as opts})(apply-border input top bottom left right)
Pad image border with OpenCV.
`input`: `NDArray` - source image in NDArray
`top`: int - Top margin
`bottom`: int - Bottom margin
`left`: int - Left margin
`right`: int - Right margin
`fill-type`: nil or Filling type - Default BORDER_CONSTANT
`value`: nil or double - Deprecated, use `values` instead
`values`: Fill with value(RGB or gray), up to 4 channels
`output`: nil or `NDArray`
returns: `NDArray`

Ex:
  (apply-border img-nd 1 1 1 1)
  (apply-border img-nd 3 3 0 0)

COLOR

decode

(decode input-stream {:keys [color to-rgb output], :or {color :color, to-rgb true, output nil}, :as opts})(decode input-stream)
Decodes an image from an input stream with OpenCV.
  `input-stream`: `InputStream` - Contains the binary encoded image
  `color`: keyword in `#{:color :grayscale}` - Convert decoded image to
           grayscale or color
  `to-rgb`: boolean - Whether to convert decoded image to mxnet's default RGB
          format (instead of opencv's default BGR)
  `output`: nil or `NDArray`
  returns: `NDArray` with dtype uint8

Ex:
  (decode input-stream)
  (decode input-stream {:color :color})
  (decode input-stream {:color :grayscale :output nd})

decode-image

deprecated

(decode-image input-stream {:keys [color-flag to-rgb output], :or {color-flag COLOR, to-rgb true, output nil}, :as opts})(decode-image input-stream)
DEPRECATED: use `decode` instead.

 Decodes an image from an input stream with OpenCV
  `input-stream`: `InputStream` - Contains the binary encoded image
  `color-flag`: 0 or 1 - Convert decoded image to grayscale (0) or color (1)
  `to-rgb`: boolean - Whether to convert decoded image to mxnet's default RGB
          format (instead of opencv's default BGR)
  `output`: nil or `NDArray`
  returns: `NDArray` with dtype uint8

Ex:
  (decode-image input-stream)
  (decode-image input-stream {:color-flag 1})
  (decode-image input-stream {:color-flag 0 :output nd})

draw-bounding-box!

(draw-bounding-box! buffered-image coordinates)(draw-bounding-box! buffered-image coordinates {:keys [names stroke font-size-mult transparency], :or {stroke 3, font-size-mult 1.0, transparency 1.0}, :as opts})
Draw bounding boxes on `buffered-image` and Mutate the input image.
`buffered-image`: BufferedImage
`coordinates`: collection of {:xmin int :xmax int :ymin int :ymax int}
`font-size-mult`: positive float - Font size multiplier
`names`: collection of strings - List of names for the bounding boxes
`stroke`: positive integer - thickness of the bounding box
`transparency`: float in (0.0, 1.0) - Transparency of the bounding box
returns: Modified `buffered-image`
Ex:
  (draw-bounding-box! img [{:x-min 0 :x-max 100 :y-min 0 :y-max 100}])
  (draw-bounding-box! [{:x-min 190 :x-max 850 :y-min 50 :y-max 450}
                       {:x-min 200 :x-max 350 :y-min 440 :y-max 530}]
                      {:stroke 2
                       :names ["pug" "cookie"]
                       :transparency 0.8
                       :font-size-mult 2.0})

fixed-crop

(fixed-crop input x0 y0 w h)
Return a fixed crop of the image.
`input`: `NDArray` - Source image in NDArray
`x0`: int - Starting x point
`y0`: int - Starting y point
`w`: int - Width of the image
`h`: int - Height of the image
returns: cropped `NDArray`

Ex:
  (fixed-crop nd-img 0 0 28 28)
  (fixed-crop nd-img 10 0 100 300)

GRAYSCALE

ndarray->image

(ndarray->image input)
Convert a NDArray image in RGB format to a real image.
`input`: `NDArray` - Source image in NDArray
returns: `BufferedImage`

read

(read filename {:keys [color to-rgb output], :or {color :color, to-rgb nil, output nil}, :as opts})(read filename)
Reads an image file and returns an ndarray with OpenCV. It returns image in
RGB by default instead of OpenCV's default BGR.
 `filename`: string - Name of the image file to be loaded
 `color`: keyword in `#{:color :grayscale}` - Convert decoded image to
          grayscale or color
 `to-rgb`: boolean - Whether to convert decoded image to mxnet's default RGB
         format (instead of opencv's default BGR)
 `output`: nil or `NDArray`
 returns: `NDArray` with dtype uint8

Ex:
  (read "cat.jpg")
  (read "cat.jpg" {:color :grayscale})
  (read "cat.jpg" {:color :color :output nd})

read-image

deprecated

(read-image filename {:keys [color-flag to-rgb output], :or {color-flag nil, to-rgb nil, output nil}, :as opts})(read-image filename)
DEPRECATED: use `read` instead.

Reads an image file and returns an ndarray with OpenCV. It returns image in
RGB by default instead of OpenCV's default BGR.
 `filename`: string - Name of the image file to be loaded
 `color-flag`: 0 or 1 - Convert decoded image to grayscale (0) or color (1)
 `to-rgb`: boolean - Whether to convert decoded image to mxnet's default RGB
         format (instead of opencv's default BGR)
 `output`: nil or `NDArray`
 returns: `NDArray` with dtype uint8

Ex:
  (read-image "cat.jpg")
  (read-image "cat.jpg" {:color-flag 0})
  (read-image "cat.jpg" {:color-flag 1 :output nd})

resize

(resize input w h {:keys [interpolation output], :or {interpolation nil, output nil}, :as opts})(resize input w h)
Resizes the image array to (width, height)
`input`: `NDArray` - source image in NDArray
`w`: int - Width of resized image
`h`: int - Height of resized image
`interpolation`: Interpolation method. Default is INTER_LINEAR
`ouput`: nil or `NDArray`
returns: `NDArray`

Ex:
  (resize nd-img 300 300)
  (resize nd-img 28 28 {:output nd})

resize-image

deprecated

(resize-image input w h {:keys [interpolation output], :or {interpolation nil, output nil}, :as opts})(resize-image input w h)
DEPRECATED: use `resize` instead.

Resizes the image array to (width, height)
`input`: `NDArray` - source image in NDArray
`w`: int - Width of resized image
`h`: int - Height of resized image
`interpolation`: Interpolation method. Default is INTER_LINEAR
`ouput`: nil or `NDArray`
returns: `NDArray`

Ex:
  (resize-image nd-img 300 300)
  (resize-image nd-img 28 28 {:output nd})

rgb-array?

(rgb-array? input)
Returns whether the ndarray is in the RGB format
`input`: `NDArray` - Source image in NDArray
returns: boolean

to-image

deprecated

(to-image input)
DEPRECATED: user `ndarray->image` instead.

Convert a NDArray image in RGB format to a real image.
`input`: `NDArray` - Source image in NDArray
returns: `BufferedImage`