Images Dicom

110 views
Skip to first unread message

Pedro Argolo Piedade

unread,
Feb 19, 2018, 2:15:36 PM2/19/18
to nano...@googlegroups.com, Nano., Carlos Queiroz
Hi Nano, how are you my friend?

I need help!

I am reading a RT image .dcm file and converting in JPG with the pixeler code

($dicom  = Nanodicom::factory($filename, 'pixeler');)

I have a Xray aquired with Fuji CR system and i have the dicom image.

I need to convert this image also to jpg, and is not working.

Can you the a look?

The erro  is:
Notice: A non well formed numeric value encountered in C:\xampp\htdocs\DC2\lib\tools\pixeler.php on line 595

Notice: A non well formed numeric value encountered in C:\xampp\htdocs\DC2\lib\tools\pixeler.php on line 599

Notice: A non well formed numeric value encountered in C:\xampp\htdocs\DC2\lib\tools\pixeler.php on line 876

after 30 second stops

Imagem inline 1

Both images side by sides.

The modality is CR

Imagem inline 2

Thanks

​​​​
--
Pedro Argôlo Piedade
Físico Médico - Radioterapia São Sebastião
www.radioterapiass.com.br
+55-048-91672105
pedroar...@gmail.com
skype: pedroargolopie
whatsapp: +554891672105

Nano.

unread,
Feb 20, 2018, 3:06:29 AM2/20/18
to Pedro Argolo Piedade, nano...@googlegroups.com, Carlos Queiroz
Hi Pedro,

From the files provided I was able to convert the DRR to jpeg fine (took 2 seconds to generate). When doing the CR image with the default memory setting (in my case 128MB) I got an error as "Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 14080 bytes) in Nanodicom/tools/pixeler.php on line 825". When I increased the limit to 200MB the image came correctly (as attached), but it took a long time: 1min20secs.

I am using a Macbook since I don't have access to a Windows machine.

This is code I used (pretty much from here: https://github.com/nanodocumet/Nanodicom/blob/master/example.php#L352)

Beware that Nanodicom has been optimized for parsing and traversing of the elements of a DICOM file, however, for image rendering it is not the best option (imaging libraries in PHP are memory eaters in my experience). You are better off trying other tools, i.e.. dcmtk or dcm4che

<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
ini_set('memory_limit','200M');

require 'nanodicom.php';

$dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR.'pedro'.DIRECTORY_SEPARATOR;

$files = array();
if ($handle = opendir($dir)) {
    while (false !== ($file = readdir($handle))) 
{
        if ($file != "." && $file != ".." && is_file($dir.$file)) 
{
$files[] = $file;
}
}
    closedir($handle);
}

foreach ($files as $file)
{
$filename = $dir.$file;
// 20) Gets the images from the dicom object if they exist. This example is for gd
try
{
echo "20) Gets the images from the dicom object if they exist. This example is for gd\n";
echo $filename . PHP_EOL;
$dicom  = Nanodicom::factory($filename, 'pixeler');
if ( ! file_exists($filename.'.0.jpg'))
{
$images = $dicom->get_images();
// If using another library, for example, imagemagick, the following should be done:
// $images = $dicom->set_driver('imagick')->get_images();

if ($images !== FALSE)
{
foreach ($images as $index => $image)
{
// Defaults to jpg
$dicom->write_image($image, $dir.$file.'.'.$index);
// To write another format, pass the format in second parameter.
// This will write a png image instead
// $dicom->write_image($image, $dir.$file.'.'.$index, 'png');
}
}
else
{
echo "There are no DICOM images or transfer syntax not supported yet.\n";
}
$images = NULL;
}
else
{
echo "Image already exists\n";
}
unset($dicom);
}
catch (Nanodicom_Exception $e)
{
echo 'File failed. '.$e->getMessage()."\n";
}
}

Thanks,

Nano.

PROWESS_CR.dcm.0.jpg
PROWESS_DRR_ANT.DCM.0.jpg

Pedro Argolo Piedade

unread,
Feb 20, 2018, 11:21:35 AM2/20/18
to Nano., nano...@googlegroups.com, Carlos Queiroz
Hi Nano, thanks for the adivese. I wiil try other tools.

I still not getting the image. I have changed the PHP.ini file to increase the time in the server.

Do you made any changed in the PHP.ini file?

Thanks My friend!

Pedro P

Nano.

unread,
Feb 20, 2018, 1:32:47 PM2/20/18
to Pedro Argolo Piedade, nano...@googlegroups.com, Carlos Queiroz
Hi Pedro,

No, I changed the setting value in the script, it is the 4th line: ini_set('memory_limit','200M');

Let me know what you find.

Take care buddy. Cheers,

Nano.

Pedro Argolo Piedade

unread,
Feb 20, 2018, 1:37:35 PM2/20/18
to Nano., nano...@googlegroups.com, Carlos Queiroz
Thanks mate!
Reply all
Reply to author
Forward
0 new messages