CreateScaledImage - Help

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
martinrame
Posts: 329
Joined: Mon, 2009-02-23, 19:57

CreateScaledImage - Help

#1 Post by martinrame » Sun, 2011-05-01, 18:10

Hi, when I want to scale an area of an image, I do something like this:

Code: Select all

scaledImage = imgHandler->getDicomImage()->createScaledImage(
    int(left), 
    int(top), 
    int(width), 
    int(height), 
    sWidth,
    0,
    0, 
    0,
    0
);
This gives me an image of width "sWidth" obtained from the area represented by left,top,width and height.

For example, if the image is 1760x1760, and I want to get an image of 500 pixels wide, I set sWidth to 500.

The problem is that the maximum value of "width" can be equal to the original image size, in my example 1760. But this way, I cannot get smaller images, for example, I would like to give a "width" of 1760*2 to get an image of half the size. But if I use this value in "width" parameter, the program crashes.

I would like, when the Width parameter is more than the original image size, get the image surrounded by a black border, letting me get images as small as I want.

Hope somebody can help me.

Per
Posts: 99
Joined: Mon, 2007-09-03, 10:53
Location: Trondheim, Norway
Contact:

#2 Post by Per » Mon, 2011-05-02, 08:07

Try setting the interpolate parameter to 1. In my experience, this uses a more stable algorithm.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#3 Post by Jörg Riesmeier » Mon, 2011-05-02, 08:50

Of course, a crash should never happen ...

To the original poster ("martinrame"):
  1. Which version of the DCMTK are you using? It is strongly recommended to use the current release (3.6.0) because it contains many bug fixes, also regarding the various scaling algorithms.
  2. What is the log output in verbose/debug (DCMTK 3.5.4) or trace (DCMTK 3.6.0) mode? Where does the crash happen? If it occurs within DCMTK, in which method / code line?
  3. You are currently using the combined clipping and scaling method, where the interpolated scaling is not yet fully implemented (see API documentation). I would suggest that you use the separate scaling and clipping methods instead.

martinrame
Posts: 329
Joined: Mon, 2009-02-23, 19:57

#4 Post by martinrame » Mon, 2011-05-02, 14:10

Jörg, I'm using 3.6.0 (2011-01-06) downloaded from the home dcmtk page.

I'll try againg splitting the clipping and scaling.

Thanks.

martinrame
Posts: 329
Joined: Mon, 2009-02-23, 19:57

#5 Post by martinrame » Tue, 2011-05-03, 12:45

Jörg, separating scaling and clipping worked ok!.

J. Riesmeier
DCMTK Developer
Posts: 2291
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#6 Post by J. Riesmeier » Tue, 2011-05-03, 14:42

So I guess that the crash happened in your code because you did not check whether the returned pointer is NULL, right?

martinrame
Posts: 329
Joined: Mon, 2009-02-23, 19:57

#7 Post by martinrame » Tue, 2011-05-03, 14:56

I don't know, because the crash was inside the CreateScaledImage method, and I couldn't debug that method.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest