Reputation: 2342
I am trying to generate C code with the MATLAB Coder. The input to the function is an image that has been processed by imread
within MATLAB. Since the output should be an m x n x 3 array from imread
, I am not sure why this error is being shown. The assertions at the start of the function are shown below. Following that is the rgb2gray
which is the source of the error.
%#codegen
assert(isa(IM, 'uint8'));
assert(size(IM, 1) < 100);
assert(size(IM, 2) < 100);
assert(size(IM, 3) == 3);
I_temp = rgb2gray(IM);
The error report I seem to be getting is shown below:
The outputs and inputs to the function are given below:
function [actual_lep_x, actual_lep_y, actual_rep_x, actual_rep_y, actual_lmp_x, actual_lmp_y, actual_rmp_x, actual_rmp_y, actual_lnp_x, actual_lnp_y, np_x, np_y] = Points( IM )
I can send over the .m file if anyone needs to compile it.
Help will be much appreciated!
Upvotes: 0
Views: 4722
Reputation: 9075
If your code is exactly same as what you have shown in the image, then the error is obvious. IM
seems to a filename, since on the line above, you have done I_ttemp=imread(IM)
(which is commented for an unknown reason). Now, since rgb2gray
did not receive an m x n x 3
array, other argument it excepts is a colormap which has dimensions m x 3
. However, you give a filename, which is of the form 1 x m
. Thus the error.
You should write:
I_temp=imread(IM);
if size(I_temp,3)==3
I_temp=rgb2gray(I_temp);
end
%do processing on I_temp.
Upvotes: 3