Reading DICOM for first time users

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
JoelThan89
Posts: 4
Joined: 2018-04-11T10:01:39-07:00
Authentication code: 1152

Reading DICOM for first time users

Post by JoelThan89 »

Hi, I'm a first time user of ImageMagick. I've read only several threads that it is possible to read dicom files and defineSet() must be used.

How should I fill in defineSet? It says the type, key, flag.

so should it be? My issue is what should xx, yy, zz values should be?

Image image;
image.defineSet(xx,yy,zz);
Image.read("test.dcm);
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Reading DICOM for first time users

Post by snibgo »

snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Reading DICOM for first time users

Post by fmw42 »

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown



Are you using the command line or API? If the latter which one?
JoelThan89
Posts: 4
Joined: 2018-04-11T10:01:39-07:00
Authentication code: 1152

Re: Reading DICOM for first time users

Post by JoelThan89 »

Hi,

My IM version is ImageMagick-7.0.7-Q16. I'm implementing Magick++ in Visual Studio 2017 (C++). The code i've been trying to execute is below; However i've read threads that defineSet(). Appreciate any help for novices like me. Thanks.

Code: Select all

#include <Magick++.h>
using namespace std;
using namespace Magick;
int main(int argc,char **argv)
{
    // Read image file from disk
    Image image( "DCM0000.dcm" );
    return 0;
}
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Reading DICOM for first time users

Post by snibgo »

JoelThan89 wrote:However i've read threads that defineSet().
Where have you read this?

After reading the image, have you tried writing it to another format, eg PNG?
snibgo's IM pages: im.snibgo.com
JoelThan89
Posts: 4
Joined: 2018-04-11T10:01:39-07:00
Authentication code: 1152

Re: Reading DICOM for first time users

Post by JoelThan89 »

When trying to read i've got an error.
code

Code: Select all

#include <Magick++.h> 
#include <iostream> 

using namespace std;
using namespace Magick;

int main(int argc, char **argv)
{
	// Initialise ImageMagick library
	InitializeMagick(*argv);
		Image image("DCM0000.dcm");
	return 0;
}
error

Code: Select all

Unhandled exception at 0x000007FEFD2CA06D in Project6.exe: Microsoft C++ exception: Magick::ErrorCorruptImage at memory location 0x00000000001BF070.
I think the problem is memory related?

The defineSet() mentioned was from an old post below
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Reading DICOM for first time users

Post by snibgo »

I suggest you catch exceptions within your program. Otherwise, we can only guess what the problem is. There are loads of examples in the source distribution -- see "try" and "catch".

I can read a DCM file with no problems in a Magick++ program, with no defines.
snibgo's IM pages: im.snibgo.com
JoelThan89
Posts: 4
Joined: 2018-04-11T10:01:39-07:00
Authentication code: 1152

Re: Reading DICOM for first time users

Post by JoelThan89 »

Hi everyone, i've just realised my dicom file is corrupted and now works with another dicom file. Thanks for the help everyone
Post Reply