Convert Binary Occupancy Grid to logical or numeric values

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일

1 개 추천

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

mohammed alany
mohammed alany 2019년 3월 14일
편집: mohammed alany 2019년 3월 14일
thanks for your replay,
but i am using matlab 2015a and your suggestion dosn't work.
what i want now, how i can make imcomplement. to Binary Occupancy Grid figure like the picture belo
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.
Many thanks dear, great answer

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2015a

질문:

2019년 3월 12일

댓글:

2019년 3월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by