MATLAB Answers

TJHeld
0

Simulation Map Generator issues

Asked by TJHeld
on 4 Sep 2019
Latest activity Answered by TJHeld
on 4 Sep 2019
Has anyone managed to successfully run the Simulation Map Generator app in the Mobile Robotics Training Toolbox? I loaded a png file (tried a jpg, that didn't work either), and the track size. When I select "Map Options/Line Follower", I get the error messages listed below in the main Matlab window. I get the same messages when I switch from Automatic to Manual Threshold mode.
Error using rgb2gray>parse_inputs (line 80)
MAP must be a m x 3 array.
Error in rgb2gray (line 52)
isRGB = parse_inputs(X);
Error in simMapGenerator/thresholdMap (line 47)
imgGray = rgb2gray(imgRaw);
Error in simMapGenerator/thresholdOptionsSelect (line 394)
app.thresholdMap;
Error using matlab.ui.control.internal.model.AbstractMutualExclusiveComponent/set.Value (line 166)
Error while evaluating ButtonGroup SelectionChangedFcn.

  0 Comments

Sign in to comment.

2 Answers

Answer by Sebastian Castro on 4 Sep 2019
 Accepted Answer

The error you linked is a common one that happens when you input a grayscale (M x N) image instead of a color (M x N x 3) image.
Seems like the toolbox assumes all images passed in as color images and tries to use the rgb2gray function regardless of whether the image is already grayscale!
So you have 2 options:
  • Short-term fix: Save your images as color images and try again
  • Long-term fix: Add logic to the app to handle this.
To fix the code with the long-term fix, here are the steps:
  1. Open the app ( edit simMapGenerator.mlapp )
  2. Go to the "Code View" section
  3. In line 47, you will see the code imgGray = rgb2gray(imgRaw); Change it to this:
if size(imgRaw,3) == 1
imgGray = imgRaw;
else
imgGray = rgb2gray(imgRaw);
end
Hope that helps!
- Sebastian

  0 Comments

Sign in to comment.


Answer by TJHeld
on 4 Sep 2019

...and, I answered my own question. I was exporting my image from a pdf through Adobe Acrobat. It was automatically determining the colorspace as grayscale, which apparently the map generator can't handle. Once I forced Acrobat to use an RGB colorspace, the problem was solved.

  0 Comments

Sign in to comment.