'dec2bin' produce error when converting rounded float number
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I tried to load an image, scale and output the binary code of each pixel. 'dec2bin' requires integer smaller than 2^52, so I rounded each floating element and then did the conversion, however the error keeps jumping out saying: ----------------------------------------------
*??? Error using ==> dec2bin at 33
D must be a non-negative integer smaller than 2^52.
Error in ==> image_ge_v2 at 12
v = dec2bin(iresize_r(i),9);*
----------------------------------------------
It is for sure that the elements in the matrix are smaller than 256.
Here's the segment of my code:
----------------------------------------------
icolour = imread('iig_v22.jpg');
icolour_s = imresize(icolour,[200 200]);
igray = rgb2gray(icolour_s);
igray = double(igray);
A = fopen('image.txt','wt');
iresize = imresize(igray,[60 60]);
iresize_r = round(iresize);
for i = 1:numel(iresize_r)
v = dec2bin(iresize_r(i),9);
end
------------------------------------------------
Please give me some hint!
Thanks a lot
0 Kommentare
Antworten (2)
Sean de Wolski
am 22 Jul. 2011
icolour = imread('peppers.png');
icolour_s = imresize(icolour,[200 200]);
igray = rgb2gray(icolour_s);
igray = double(igray);
iresize = imresize(igray,[60 60]);
iresize_r = round(iresize);
for i = 1:numel(iresize_r)
v = dec2bin(iresize_r(i),9);
end
I get no error doing this with a stock image.
Fangjun Jiang
am 22 Jul. 2011
We don't have your data so probably won't re-produce your error. You could check the value of i when the error happened and then check the value of iresize_r(i).
Once your problem is solved, you can use dec2bin(iresize_r,9) without the for-loop.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Precision finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!