Double inputs must have integer values in the range of ASSUMEDTYPE.
39 views (last 30 days)
Show older comments
My code is,
din=imread('test.jpg');
figure(1);
imshow(din);
din=im2double(din);
[m,n]=size(din);
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
d_new(i,j)=min([d_new(i,j);1+d_new(i-1,j);
1.41+d_new(i-1,j-1);1+d_new(i,j-1);1.41+d_new(i+1,j-1)]);
end
end
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));
0 Comments
Accepted Answer
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.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!