Convert Binary Occupancy Grid to logical or numeric values

2 次查看(过去 30 天)
i want to perform the code "imcomplement" on Binary Occupancy Grid figure, the erroe message occurs was :
"Error using imcomplement Expected input to be one of these types: logical, numeric Instead its type was robotics.BinaryOccupancyGrid."
if i cant not to convert to this extention, may i perform the code "inflate" on logical or numeric values

采纳的回答

Cam Salzberger
Cam Salzberger 2019-3-13
Hello Mohammed,
You can use the occupancyMatrix method to extract the numeric values of the occupancy grid. Then you can manipulate the matrix how you want. For binary values, ~occGridMatrix would be the same as imcomplement.
As for going the other direction, inflate is similar to imdilate, though the exact algorithm differs.
-Cam
  3 个评论
Cam Salzberger
Cam Salzberger 2019-3-14
Ah, the occupancyMatrix method was only introduced in R2016b. You could use getOccupancy with the 'grid' argument, simply providing each cell as an input to get an array, then reshape it back into a matrix. Something like:
[I, J] = ndgrid(1:map.GridSize(1), 1:map.GridSize(2));
values = getOccupancy(map, [I(:) J(:)], 'grid');
valueGrid = reshape(values, size(I));
I'm not certain about the reshape being the exact inverse of the (:) indexing, but you can play around with it if necessary.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by