cocoa-xu / evision

Evision: An OpenCV-Erlang/Elixir binding
https://evision.app
Apache License 2.0
322 stars 22 forks source link

An error occurs with applyColorMap #255

Closed RyoWakabayashi closed 1 week ago

RyoWakabayashi commented 2 weeks ago

When running the applyColorMap function in evision 0.2.3, the following error occurs:

{:error,
 "OpenCV(4.10.0) /work/3rd_party/opencv/opencv-4.10.0/modules/imgproc/src/colormap.cpp:842: error: (-215:Assertion failed) cv::LUT only supports tables of size 256. in function 'applyColorMap'\n"}
cocoa-xu commented 2 weeks ago

Hi @RyoWakabayashi, thanks for reporting this issue. Is it possible for you to share some minimal code to reproduce this error?

cocoa-xu commented 2 weeks ago

Hi @RyoWakabayashi, once #256 is merged you can follow the example below to specify the colormap.

iex> img = Evision.imread("test/testdata/dog.jpg")
%Evision.Mat{
  channels: 3,
  dims: 2,
  type: {:u, 8},
  raw_type: 16,
  shape: {576, 768, 3},
  ref: #Reference<0.3798908985.2397700162.237747>
}
iex> Evision.applyColorMap(src: img, colormap: Evision.Constant.cv_COLORMAP_AUTUMN)
%Evision.Mat{
  channels: 3,
  dims: 2,
  type: {:u, 8},
  raw_type: 16,
  shape: {576, 768, 3},
  ref: #Reference<0.3798908985.2397700154.237107>
}
RyoWakabayashi commented 1 week ago

@cocoa-xu

Thank you. It worked correctly.

mt_fuji_dem_color = Evision.applyColorMap(src: mt_fuji_dem_u8, colormap: Evision.Constant.cv_COLORMAP_JET())

Evision.resize(mt_fuji_dem_color, {640, 640})

mt_fuji_jet