0
votes

When reading an image, the inputs considered for polyfit are different types. one is "uint8" while the other is "double" (their size is the same, <1x384>) Could you please give me a hint that how I can solve it?

its errors are shown below while I haven't used TIMES in polyfit:

Error using * MTIMES is not fully supported for integer classes. At least one input must be scalar. To compute elementwise TIMES, use TIMES (.*) instead.

Error in polyfit p = R(Q'*y); % Same as p = V\y;

How Can I convert it to unit8? (in other case, its result is not adequate for my script)

1
This question requires clarification. Post more details regarding error messages and code. - Buck Thorn
You can convert between data types, for instance with double or unit8. - Buck Thorn
Might want to take a look at this: stackoverflow.com/questions/17924743/… - Buck Thorn
Sorry, that was uint8 - Buck Thorn
Why can't you use double? I would convert to double before processing, and if necessary (and possible) convert a result to uint8 - Buck Thorn

1 Answers

0
votes

To convert a type double to uint8 you can do the following:

b = [1:10]; % <-- type double
a = uint8(b); % <-- convert to uint8

whos a 
  Name      Size                    Bytes  Class

  a         1x1                         1  uint8 array

Grand total is 1 element using 1 bytes

To do the reverse:

a = uint8([1:10]); % <-- convert to uint8
b = double(a); % <-- type double

whos b
  Name      Size                    Bytes  Class

  b         1x10                       80  double array

Grand total is 10 elements using 80 bytes

Type uint8 variables are unsigned integers (>=0).

Some operations don't work with them, such as A\b.

Before attempting your operations with the input images, convert them to double as follows:

im_double = double(im_uint8);

where im_uint8 is the original image.