Closed hyousefGopher closed 4 years ago
The 3D case isn't relevant, because even your 2D case is incompatible.
The "jagged array" Vec<Vec<_>>
layout is fundamentally incompatible with this crate. It's also pretty inefficient, and imgref
exists to avoid it, not to support it.
ImgRef
requires all rows to be laid out in memory consecutively with a predictable spacing (stride), in a single Vec
. But Vec<Vec<_>>
puts rows anywhere in memory, in any order the inner Vec
s want.
You must get rid of the innermost Vec
by merging all rows into one Vec
.
In 2D case change Vec<Vec<i32>>
to Vec<i32>
. In the 3D case, change Vec<Vec<Vec<i32>>>
to Vec<Vec<i32>>
.
For 3D images it'll be Vec<ImgVec<i32>>
.
Did not get your point, if the data I've is in the form of:
[
[
[151 134 128]
[148 131 126]
]
[
[149 130 127]
[151 134 128]
]
]
Do I need to make them as:
[
[151 134 128]
[148 131 126]
[149 130 127]
[151 134 128]
]
Or as:
[151 134 128 148 131 126 149 130 127 151 134 128]
You must make that one image == one Vec
.
You can't have Vec
per row. All rows of one image must be concatenated together in one Vec
.
I've the content of an image extracted in a 3D array, with the dimensions of:
(480, 640, 3)
, which can be built in Rust with one of the below ways, how can I convert this array into image?Image raw data:
Or as:
I started with below code, but not sure where to go next:
With content: