From: Elie Matta on
hey all,

Is there any other way to convert char to double other than str2num that is too slow?
I have a graylevel image that i want to convert to a binary sequence.

load woman;
imdec = reshape(X,256*256,1);
imbin= dec2bin(imdec,8);
msg = reshape(imbin',256*256*8,1);

but msg is char if i use
msg2=str2num(msg);
it takes too long
and if i use
msg2=str2double(msg)
it gives me a 1x1 double inf

is there any other way ??
thanks in advance.

Elie
From: dpb on
Elie Matta wrote:
> hey all,
>
> Is there any other way to convert char to double other than str2num that
> is too slow?
> I have a graylevel image that i want to convert to a binary sequence.
>
> load woman;
> imdec = reshape(X,256*256,1);
> imbin= dec2bin(imdec,8);
> msg = reshape(imbin',256*256*8,1);
>
> but msg is char if i use msg2=str2num(msg); it takes too long and if i use
> msg2=str2double(msg)
> it gives me a 1x1 double inf
> is there any other way ??
....
OK, I'm not much into image processing so you confused me (easily done,
undoubtedly)...

First, what is X (double, uintN, ...)?

What is the form of binary sequence wanted to be and what's the
definition of who's 0/1?

--
From: someone on
"Elie Matta" <matta.elie(a)hotmail.com> wrote in message <hp4jcq$23b$1(a)fred.mathworks.com>...
> hey all,
>
> Is there any other way to convert char to double other than str2num that is too slow?
> I have a graylevel image that i want to convert to a binary sequence.
>
> load woman;
> imdec = reshape(X,256*256,1);
> imbin= dec2bin(imdec,8);
> msg = reshape(imbin',256*256*8,1);
>
> but msg is char if i use
> msg2=str2num(msg);
> it takes too long
> and if i use
> msg2=str2double(msg)
> it gives me a 1x1 double inf
>
> is there any other way ??
> thanks in advance.
>
> Elie

doc str2double

% The help says str2num uses eval.
% str2double doesn't. (So, should be faster.)
From: Ashish Uthama on
On Fri, 02 Apr 2010 08:11:22 -0300, Elie Matta <matta.elie(a)hotmail.com>
wrote:

> hey all,
>
> Is there any other way to convert char to double other than str2num that
> is too slow?
> I have a graylevel image that i want to convert to a binary sequence.
>
> load woman;
> imdec = reshape(X,256*256,1);
> imbin= dec2bin(imdec,8);
> msg = reshape(imbin',256*256*8,1);
>
> but msg is char if i use msg2=str2num(msg); it takes too long and if i
> use
> msg2=str2double(msg)
> it gives me a 1x1 double inf is there any other way ??
> thanks in advance.
>
> Elie



%It looks like you want to get bit slices of the image
%If so, try this:
Xg=ind2gray(X,map); %looks grayscale anyway
%Convert to uint8
Xg =uint8(round(Xg*255));
%LSB bit slice
%lsbSlice = bitand(Xg,1);
%msbSlice = bitand(Xg,256);

slice=zeros([size(Xg) 8]);
for bit=1:8
slice(:,:,bit) = bitand(Xg , (bitshift(1,bit)));
imagesc(slice(:,:,bit));
title(['Bit slice: ' num2str(bit)]);
pause(1)
end

%Else, let us know in some more detail what your end goal is
From: Ashish Uthama on
On Fri, 02 Apr 2010 16:35:14 -0300, Ashish Uthama
<first.last(a)mathworks.com> wrote:

> On Fri, 02 Apr 2010 08:11:22 -0300, Elie Matta <matta.elie(a)hotmail.com>
> wrote:
>
>> hey all,
>>
>> Is there any other way to convert char to double other than str2num
>> that is too slow?
>> I have a graylevel image that i want to convert to a binary sequence.
>>
>> load woman;
>> imdec = reshape(X,256*256,1);
>> imbin= dec2bin(imdec,8);
>> msg = reshape(imbin',256*256*8,1);
>>
>> but msg is char if i use msg2=str2num(msg); it takes too long and if i
>> use
>> msg2=str2double(msg)
>> it gives me a 1x1 double inf is there any other way ??
>> thanks in advance.
>>
>> Elie
>
>
>
> %It looks like you want to get bit slices of the image
> %If so, try this:
> Xg=ind2gray(X,map); %looks grayscale anyway
> %Convert to uint8
> Xg =uint8(round(Xg*255));
> %LSB bit slice
> %lsbSlice = bitand(Xg,1);
> %msbSlice = bitand(Xg,256);
>
> slice=zeros([size(Xg) 8]);
> for bit=1:8
> slice(:,:,bit) = bitand(Xg , (bitshift(1,bit)));
> imagesc(slice(:,:,bit));
> title(['Bit slice: ' num2str(bit)]);
> pause(1)
> end
>
> %Else, let us know in some more detail what your end goal is

Correction bitshifting should go from 0 to 7


%It looks like you want to get bit slices of the image
%If so, try this:
Xg=ind2gray(X,map); %looks grayscale anyway
%Convert to uint8
Xg =uint8(round(Xg*255));

slice=zeros([size(Xg) 8]);
for bit=1:8
slice(:,:,bit) = bitand(Xg , (bitshift(1,bit-1)));
imagesc(slice(:,:,bit));
title(['Bit slice: ' num2str(bit)]);
pause(1)
end
 |  Next  |  Last
Pages: 1 2
Prev: differences between Wavelet Families
Next: Java problem