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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Convert DICOM file into bmp/jpg file

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
woolfik Posted - Mar 30 2015 : 15:59:59
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
6   L A T E S T    R E P L I E S    (Newest First)
woolfik Posted - Mar 31 2015 : 15:18:07
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.
w2m Posted - Mar 31 2015 : 14:56:54
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
woolfik Posted - Mar 31 2015 : 14:25:01
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.

xequte Posted - Mar 31 2015 : 12:32:27
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
woolfik Posted - Mar 31 2015 : 12:27:27
Yes I have loaded dicom but jpg file wasn't created.
xequte Posted - Mar 31 2015 : 11:30:03
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