Path: news.mathworks.com!not-for-mail
From: "Sadik " <sadik.hava@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Medical image processing (dicom to *.hdr, *.img)
Date: Tue, 9 Aug 2011 07:53:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <j1qp14$i46$1@newscl01ah.mathworks.com>
References: <j1o8qt$812$1@newscl01ah.mathworks.com> <j1q8is$37q$1@newscl01ah.mathworks.com> <j1qm5a$a99$1@newscl01ah.mathworks.com>
Reply-To: "Sadik " <sadik.hava@gmail.com>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1312876388 18566 172.30.248.35 (9 Aug 2011 07:53:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 9 Aug 2011 07:53:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: news.mathworks.com comp.soft-sys.matlab:739311

If you change it, it won't work. :D

Look at this block of code in the function:

switch hdr.image_dimension.datatype
   case 1,
      hdr.image_dimension.bitpix = 1; precision = 'ubit1';
   case 2,
      hdr.image_dimension.bitpix = 8; precision = 'uint8';
   case 4,
      hdr.image_dimension.bitpix = 16; precision = 'int16';
   case 8,
      hdr.image_dimension.bitpix = 32; precision = 'int32';
   case 16,
      hdr.image_dimension.bitpix = 32; precision = 'float32';
   case 64,
      hdr.image_dimension.bitpix = 64; precision = 'float64';
end;

It says, if it is int16 for example, that is, when you read your dicom image, if it is 16-bit, you need to use 4 as input for the data_type [The input just before the last input]. But I see that you are using 'img'.

Best.