ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Convert DICOM file into bmp/jpg file
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

woolfik

Poland
13 Posts

Posted - Mar 30 2015 :  15:59:59  Show Profile  Reply
Hello I found on forum this topic:
http://www.imageen.com/ieforum/topic.asp?TOPIC_ID=1548&SearchTerms=DICOM,convert,to,bmp

where is convert bmp to dicom.

I have DICOM file (in attach) and like to convert to bmp/jpg or png. I try to do it like in demo:

procedure TMainForm.btnSaveClick(Sender: TObject);
var
  i : integer;
begin
  SaveImageEnDialog1.AutoSetFilterFileType := -1;
  SaveImageEnDialog1.Filename := '';
  if SaveImageEnDialog1.Execute then
  begin
    // set output pixel format to 24 bit
    ImageEnMView1.MIO.Params[0].SamplesPerPixel := 3;
    ImageEnMView1.MIO.Params[0].BitsPerSample := 8;
    ImageEnMView1.MIO.DuplicateCompressionInfo;
    for i := 0 to ImageEnMView1.ImageCount - 1 do
    begin
      ImageEnMView1.GetTIEBitmap(i).PixelFormat := ie24RGB;
      ImageEnMView1.ReleaseBitmap(i);
    end;
    ImageEnMView1.MIO.SaveToFile( SaveImageEnDialog1.FileName );
  end;
end;


but it does not working.

Can someone help?

attach/woolfik/201533015594_IMG00002.ZIP

xequte

38507 Posts

Posted - Mar 31 2015 :  11:30:03  Show Profile  Reply
Hi

In what way is it not working?

Have you loaded the Dicom file into the TImageEnMView?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

woolfik

Poland
13 Posts

Posted - Mar 31 2015 :  12:27:27  Show Profile  Reply
Yes I have loaded dicom but jpg file wasn't created.
Go to Top of Page

xequte

38507 Posts

Posted - Mar 31 2015 :  12:32:27  Show Profile  Reply
Hi

OK, I see you are calling:

ImageEnMView1.MIO.SaveToFile( SaveImageEnDialog1.FileName );

Which is only for saving multi-frame images in a TImageEnMView (GIF, TIFF, Dicom, etc).

You need to save each frame of the image:

  for i := 0 to ImageEnMView1.ImageCount - 1 do
  begin
    ImageEnMView1.GetTIEBitmap(i).Write( ChangeFileExt( SaveImageEnDialog1.FileName, '_' + IntToStr( i + 1 ) + ExtractFileExt( SaveImageEnDialog1.FileName )));
    ImageEnMView1.ReleaseBitmap(i);
  end;



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

woolfik

Poland
13 Posts

Posted - Mar 31 2015 :  14:25:01  Show Profile  Reply
I modify my code to this:

function DicomToJpg(filename: string): string;
var
  i : integer;
  imgEn: TImageEnMView;
begin
  imgEn := TImageEnMView.Create(nil);
  try
    result := ChangeFileExt(filename,'.jpg');
    imgEn.MIO.LoadFromFileDICOM(filename);
    imgEn.MIO.Params[0].SamplesPerPixel := 3;
    imgEn.MIO.Params[0].BitsPerSample := 8;
    imgEn.MIO.DuplicateCompressionInfo;
    for i := 0 to imgEn.ImageCount - 1 do
    begin
      imgEn.GetTIEBitmap(i).Write(ChangeFileExt(filename,'_'+IntToStr(i+1)+
        ExtractFileExt(filename)));
      imgEn.ReleaseBitmap(i);
    end;
    imgEn.MIO.SaveToFile(result);
  finally
    FreeAndNil(imgEn);
  end;
end;


And even download version 6.0 of ImageEN but stil file does not exists.

Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 31 2015 :  14:56:54  Show Profile  Reply
Suggestion:
for i := 0 to imgEn.ImageCount - 1 do
    begin
      if not imgEn.GetTIEBitmap(i).Write(ChangeFileExt(filename,'_'+IntToStr(i+1)+
        ExtractFileExt(filename))) then
      ShowMessage('Error saving ' + filename);   
      imgEn.ReleaseBitmap(i);
    end;
    imgEn.MIO.SaveToFile(result); //Delete this line


Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

woolfik

Poland
13 Posts

Posted - Mar 31 2015 :  15:18:07  Show Profile  Reply
Ok I know where problem is. My dicom file has no extention so this code:

function DicomToJpg(filename: string): string;
var
  i : integer;
  imgEn: TImageEnMView;
  fName: string;
begin
  imgEn := TImageEnMView.Create(nil);
  try
    fname := ChangeFileExt(filename,'.jpg');
    imgEn.MIO.LoadFromFileDICOM(filename);
    imgEn.MIO.Params[0].SamplesPerPixel := 3;
    imgEn.MIO.Params[0].BitsPerSample := 8;
    imgEn.MIO.DuplicateCompressionInfo;
    for i := 0 to imgEn.ImageCount - 1 do
    begin
      imgEn.GetTIEBitmap(i).Write(fname);
      imgEn.ReleaseBitmap(i);
    end;
    imgEn.MIO.SaveToFile(fName);
    Result := fName;
  finally
    FreeAndNil(imgEn);
  end;
end;


Works perfectly thx guys.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: