I am using Images.jl
in Julia
. I am trying to convert an image into a graph-like data structure (v,w,c) where
v is a node
w is a neighbor and
c is a cost function
I want to give an expensive cost to those neighbors which have not the same color. However, when I load an image each pixel has the following Type RGBA{U8}(1.0,1.0,1.0,1.0)
, is there any way to convert this into a number like Int64 or Float?
Following @daycaster's suggestion, colordiff
from Colors.jl can be used.
colordiff
takes two colors as arguments. To use it, you should extract the color part of the pixel with color
i.e. colordiff(color(v),color(w))
where v
would be RGBA{U8(0.384,0.0,0.0,1.0)
value.