Normally in Matlab colors, RGB intensity values are displayed with three element vectors, precision UIT 8 (range 0 - 255) or double
This is an analogy, but when specifying the color value from a matrix, it is easy to start a bug type, for the second (because the value is quietly converted, but the new category will not increase again) . Just spend many hours searching these bugs, I would like to make sure that it never re-starts.
How can matlab show a warning when a type conversion occurs?
Ideally this will happen only when the conversion between double
and uint8
. It should also be difficult to disable (i.e. when the workspace is not reset when loading, or when the matlub crashes).
A possible solution is to define your uint8
function uint8
is inserted and warns that some values have been truncated.
You should put this function in that folder where it shifts the biltin uint8
funciton. For example, your User Folder is a good option, because it usually appears first in path
. Or, as noted by Sam Roberts, if you want to call this function convert from double
to uint8
(But not in any other way to uint8
), by entering it, a folder named @ double
in your path.
function y = uint8 (x) y = builtin ('uint8', x); If any (x (:)> 255) ||
Warning ('Metap: Cost Transaction', 'Cost Charted During Conversion to UIT 8') Any (X (:) <0) Warning You can call it Warning (can be turned on or off with 'on', 'MATLAB: CastTransconization')
and Warning ('Closed', 'MATLAB: CastTruncation')
(for suggestions Thanks to Citizen Einsen).
No comments:
Post a Comment