From: JohnMC on 20 Jul 2010 15:49 Dicom read gives output as uint16, but when I did this , why did I still get uint16 not double ? x = dicomread(IM); x = double(IM) - 1024; x is still uint16.
From: JohnMC on 20 Jul 2010 15:53 "JohnMC " <nirmathink(a)gmail.com> wrote in message <i24tut$7is$1(a)fred.mathworks.com>... > Dicom read gives output as uint16, but when I did this , why did I still get uint16 not double ? > > x = dicomread(IM); > x = double(IM) - 1024; > > x is still uint16. my original code is : for i = 1: 10 x(:,:,i) = dicomread(IM); x(:,:,i) = double(x(:,:,i))-1024; end I found if i don't use array, I will get double type : x = dicomread(IM); x = double(x) - 1024; Dose this mean the type change " double " dose not work for multi-dimensional matrix ?
From: Walter Roberson on 20 Jul 2010 15:53 JohnMC wrote: > Dicom read gives output as uint16, but when I did this , why did I still > get uint16 not double ? > x = dicomread(IM); > x = double(IM) - 1024; > x is still uint16. It seems unlikely that this is your actual code, as you overwrite the dicomread value read in and replace it with an expression based upon the internal representation of the _name_ of the file.
From: Walter Roberson on 20 Jul 2010 16:02 JohnMC wrote: > my original code is : > for i = 1: 10 > x(:,:,i) = dicomread(IM); > x(:,:,i) = double(x(:,:,i))-1024; > end > > I found if i don't use array, I will get double type : x = dicomread(IM); > x = double(x) - 1024; > Dose this mean the type change " double " dose not work for > multi-dimensional matrix ? No, it means you did not pre-allocate the array x, and it therefore took its type from the first thing you assigned to it, a uint16 array. Once it has become uint16 then each time you assign something to an indexed portion of the array, the value you assign will be converted into the existing type (uint16). If you know the size of the image in advance then you should preallocate your x array to hold that data. If you do not know the size of the image in advance then you should use cell arrays. numimg = 10; x = cell(numimg,1); for i = 1 : numimg x{i} = double(dicomread(IM)) - 1024; end
|
Pages: 1 Prev: Add new line on static text Next: Simulink - Non-overlapping data |