How to recify this error in daughman's rubber sheet model matlab code? : Error using * MTIMES (*) is not fully supported for integer classes.

3 views (last 30 days)
It runs perfectly on the example image but shows the following error for other images :
Error using *
MTIMES (*) is not fully supported for integer classes. At least one argument must be scalar.
Error in rubberSheetNormalisation (line 82)
x1 = ones(size(angles))*xi;

Accepted Answer

DGM
DGM on 15 Jan 2024
Edited: DGM on 15 Jan 2024
Well, I have no idea how you're calling this function, but the parameters you're passing are integer-class, when they shouldn't be. Specifically , yPosIris is an integer-class numeric vector. Yes, that's the Y-component that causes an error in setting up X-coordinate vectors. Don't ask me why.
The documentation is variously wrong and misleading.
The image does not need to be class 'double'. When using the default interpolation option (true), the image must be uint8 class. When using the non-default setting for interpolation, the image may be any class, so long as it's properly-scaled for its class. In other words, don't just call double() on the image.
% assuming myimage is properly-scaled for its class
double(myimage) % this is an improperly-scaled image
im2double(myimage) % this is a properly-scaled image
Again, casting to double is either wrong or unnecessary, so this shouldn't even matter.
I doubt that any of the parameters are expected to be integer-class. They're supposed to be integers, but not integer-class. In other words
% say this is a number you want to pass to the function
myCoordinate = 123.45; % this is not an integer. It is of floating-point class
% use round(),ceil(),floor(),etc
A = round(myCoordinate) % now it's an integer, and the class is the same
% don't cast it as an integer
B = uint16(myCoordinate) % now it's an integer, but now it's integer-class and will cause an error
If these parameters are coming out of metadata, a header file, or other data file in an integer-class, then cast them to a float class as necessary (e.g. using double() or changing the method by which they're imported)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!