Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any open source DICOM Viewer (medical images) SDK ? 1

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
542
MU
Hi All,

Anyone knows any open source DICOM image (medical images) viewer SDK? Even if it's a DotNet library, I can use it. I will write a wrapper/bridge for that.

Thanks in advance,
Rajesh
 
I can't give you a definitive answer, but a quick search for DICOM image viewer throws up several possibilities. They mostly seem to be stand-alone viewers rather than components that you can integrate into your app. However, there also seem to be several that are integrated with HTML5 / Javascript, which you should have no difficulty in displaying from within a VFP app.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
ggreen61,

I am looking for a SDK (not standalone software) that I can use to integrate DICOM viewing feature in vfp application.

Rajesh
 
tom,

ImageMagick is promising! I will try that.

In fact, I have heard about this but couldn't recall it in time :)

Thank you very much tom,
Rajesh
 
Hi Mike,

Thank you for your time and suggestions. Yes, I was going through listings.
Now, it seems, ImageMagick suggested by tom is very promising. As per their page, DICOM is supported.

Rajesh
 
I wonder how to use the feature that's shown in ArrayTest.vbs, which passes an array by reference used as output parameter.

I tried COMARRAY(), but that didn't help

The script itself works, when you open up cmd.com, change to the ImageMagickObject\Tests directory and then do
C:\Windows\syswow64\wscript ArrayTest.vbs

The OLE registration is okay, I can do thiss without error, too:
Code:
loImage = CreateObject("ImageMagickObject.MagickImage.1")
COMARRAY(loImage,10)
Local Array myarray[3000000]
msgs = loImage.Convert("null:","-profile","8BIMTEXT:iptctext.txt",myarray)
? msgs
? Alen(myarray)
? myarray[1]

msgs is 1,1,NULL, the array doesn't change at all.

I think one problem in comparison with executing the vbs script is, that the ImageMagicObject isn't working in the Tests directory and when I C into it in the VFP code, that doesn't change the current directory for the ImageMagicObject. So I also tried with the fullpath to the ipctext.txt and that fails, too.

It's not even the most important part of the sample code, as it only loads some iptc definitions, which then are added to a jpeg file that is unchanged otherwise.

In general ImageMagick would return a blob of the image in an array, and VFP might be able to display that as PictureVal. I also tried to use a string instead of array, but the call doesn't like that at all.

What can be done is something like a file conversion by loImage.Convert(cImageSourceFile,cImageDestinationFile), for example
Code:
loImage = CreateObject("ImageMagickObject.MagickImage.1")
loImage.convert("bill_meets_gorilla_screen.jpg","bill_meets_gorilla_screen.png")

Which also means the ImageMagicObject looks into the Tests folder that contains the bill_meets_gorilla_screen.jpg.

I see has some basic samples to do other things, but what about the array feature? Tom, did you ever work with that?

What I am after is being able to load a format VFP doesn't support, like webp or DICOM and load it into an array in png format that an image control can display, without writing a png file first.

Chriss
 
Hi Chriss,

I wrote tom that ImageMagick is promising but not yet tried myself.
Anyway, I hope your study and notes are going to help me a lot in correct direction when I do that.
Thank you,
Rajesh
 
Hello,

@Chris
Sorry, I never used the array feature.

We have a general convert procedure which uses imagemagick and other tools which create a file.
(we prefer files for reports and for a general filetostr->encrypt->store in sql function)

@Rajesh
You may also look here for a fast try :

Regards
tom
 
I see, so it's convert for the win.

The sample seemed like almost a solution, because it doesn't just read in a file as is, but creates an array representing the raw data of another format, like jpeg or png. Even if you could get an array it'd still not work as a blob of the DCIM converted to a format VFP can display, you likely would need to concatenate all array elements into a binary string to have that raw data for display and though that all is RAM operations, it could take longer as a byte-by-byte loop than using convert to create a file and loading that.

Edit: actually the vbs sample codde does aim to not convert a file and just embed some meta data. Besides that writing a file should put it into write cache and so readingit from the converted file may target the cahced RAM anyway. I just wonder whether the Imagemagick OLE object convert method runs asynchronous. I guess unfortunately not. And if it would, reading the file during it's creation would depend on at least the completion of writing into the write buffer of Windows File system caching.

As I use a RAM disk, that would solve that, I just use RAM disks it during development, though.

Chriss
 
Hello Chris,

we do a wait4file() after conversions

Code:
Function Wait4file(cFilename, ntimeout)
  Local nanz ,lok , ldone, ntimeout, nStart, nfhand
  If Vartype(ntimeout)<>"N"
    ntimeout=30 && Max waittime
  Endif
  nStart  =Seconds()
  lok     =.T.
  ldone   =.F.
  Do While ldone = .F.
    If Adir(acdummy,cFilename)=0
      Sleep(500)
      * DOEVENTS
    Else
      nfhand=Fopen(cFilename,12)
      If nfhand>0
        =Fclose(nfhand)
        ldone=.T.
      Else
        Sleep(500) && see api_declares
      Endif
    Endif
    If Seconds()-nStart > ntimeout
      lok   = .F.
      ldone = .T.
    Endif
  Enddo
  Return lok
Endfunc

regards
tom
 
Ah, thanks Tom. That implicates the convert call can actually run asynchronously.

I can't observe that case. I gave it a try by doing
Code:
loIM = CreateObject("ImageMagickObject.MagickImage.1")
cNewfile = ADDBS(GETENV("TEMP"))+SYS(2015)+".png"
? SECONDS()
loIM.convert(...,cNewfile) 
? SECONDS()
? ADIR(laDummy,cNewfile)
? FOPEN(cNewfile,12)

Which always takes the conversion time and gets 1 from ADIR() and a file handle from fopen. So whether this can works asynchronously might depend on settings of the ImageMagickObject.MagickImageobject or Windows.

I think if you intend to run parallel you could do that with ParallelFox, which could do a batch of file conversions starting a series of parallel processes and then wait for the files to be finalized with ADIR and Fopen. But it might not be worth the hassle for the case of single images, it would even make the single image case slower unless you would further complicate the outset by establishing an EXE you start as side process for image conversion and invoke it as needed by interprocess communication. Or do multithreading.

Chriss
 
Tom,

Code:
You may also look here for a fast try :
[URL unfurl="true"]https://imagemagick.org/script/convert.php[/URL]

I will check this. Thanks

Tom/Chriss,

Going through your studies, it appears the conversion (I have not yet tested anything with ImageMagick, a bit occupied now!) would take some time and if I run that process from my VFP application, the VFP might go hang (for obvious reasons, yeah)? Need to check how I should handle that situation.

Will go through texts by all of you thoroughly before my trials and will get back here when I start working on this.

Rajesh
 
No, it won't take much time. Just hard drives are still the slowest component in software, So reading the DICOM image from har drive, converting it to a blob in memory would be ideal, but there is no need to do thhis in a parallel thread or process.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top