Double inputs must have integer values in the range of ASSUMEDTYPE.

75 views (last 30 days)
My code is,
y_pts = numel(din(1,:));%number of columns
x_pts = numel(din(:,1));%number of rows
t_pts = numel(din);%total number of elements
%copy of matrix with object value 0 and rest value 1000
c_din = 1000.*int16(bitcmp(din,1));
d_new = zeros(x_pts+2,y_pts+2);
d_new(2:x_pts+1,2:y_pts+1)= c_din;%creating boundry object
%performing forward processing
for j=2:1:y_pts+1
for i=2:1:x_pts+1
I am getting an error as,
Error using bitcmp Double inputs must have integer values in the range of ASSUMEDTYPE.
Error in distance1 (line 16) c_din = 1000.*int16(bitcmp(din,1));

Accepted Answer

Geoff Hayes
Geoff Hayes on 27 Oct 2014
Vetri - what is your intent behind using bitcmp in the following
c_din = 1000.*int16(bitcmp(din,1));
Based on your comment, it seems that you want to convert all pixels (of your presumably grayscale image) to be either 0 or 1000. If this is true, why use the bit-wise complement to achieve this?
Based on the notes from bitcmp, if the input array/matrix is of data type double, then the default ASSUMEDTYPE is uint64. The error message seems to be telling you that your double inputs must have integer value in the range of uint64. But since you have called im2double on your test.jpg, then all double inputs are in the interval [0,1], and so the error makes sense.
If you have the Image Processing Toolbox, then it seems that you could easily convert your grayscale image to binary (using im2bw) and then multiply that by 1000 as
c_din = 1000*im2bw(din);
Or, given that the pixel values in din are in the interval [0,1] you could do
c_din = 1000*round(din);
to obtain similar results.

More Answers (0)


Find more on Numeric Types in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by