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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Create Dicom: problem with standard tags and default value
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PincoPallino

Italy
13 Posts

Posted - Feb 07 2026 :  13:32:35  Show Profile  Reply
Hi,
using version 14.0.1.
I read a group of images with TImageEnMIO with
IoParams.BitsPerSample := 14;
IoParams.SamplesPerPixel := 1;
Bitmap.PixelFormat := ie16g;
then I save in Dicom format.
The problem is that the code in iemio.pas from line 5114 overwrites the BitsPerSample in Dicom image even if (like very often) it already has a different value.
The right values for this information would be the BitsStored for internal Dicom context.

And then, in file iedicom.pas
from line 8746
if (ctx.Params.SamplesPerPixel = 1) and (ctx.Params.BitsPerSample = 16) then
begin
// Gray scale 16 bit
ctx.Params.DICOM_Tags.SetTagString($0028, $0004, IEDICOM_PHOTOMETINTERPRET_MONOCHROME_ZEROISBLACK); // Photometric interpretation
ctx.Params.DICOM_Tags.SetTagNumeric($0028, $0100, 16); // Bits allocated
ctx.Params.DICOM_Tags.SetTagNumeric($0028, $0101, 16); // Bits stored
ctx.Params.DICOM_Tags.SetTagNumeric($0028, $0102, 15); // High bit

The values for BitAllocated and BitsStored are fixed and I haven't found a way to change. Except editing the dicom file directly.
This is a problem with medical images because having a wrong value leads to displaying ugly images.

It would be very usefull at least a new property in TIOParams
property DICOM_BitsStored: Integer read fDICOM_BitsStored write fDICOM_BitsStored;
Best regards
PP

xequte

39450 Posts

Posted - Feb 08 2026 :  14:02:02  Show Profile  Reply
Hi

We have been doing a lot of work with PixelFormats in our current beta. Can you forward us some of your BPP14 images so we can test this?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PincoPallino

Italy
13 Posts

Posted - Feb 09 2026 :  04:02:20  Show Profile  Reply
I sent you (using SwissTransfer) a Dicom.
Go to Top of Page

xequte

39450 Posts

Posted - Feb 09 2026 :  15:31:01  Show Profile  Reply
Thanks, so at this time, ImageEn will always save ie16g images as SamplesPerPixel = 1 and BitsPerSample = 16. Are you seeing invalid images being created in this way?


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PincoPallino

Italy
13 Posts

Posted - Feb 10 2026 :  04:57:57  Show Profile  Reply
Hi Nigel,
the image is not invalid. It can be read by all software.
But saying that has 16 bit "used" when are only 14 or 12 create some problem in visualization.
It's an incorrect information!
Go to Top of Page

xequte

39450 Posts

Posted - Feb 11 2026 :  03:13:18  Show Profile  Reply
Hi Pinco

Can you forward me some samples where BitsPerSample it is internally recorded as 14?



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PincoPallino

Italy
13 Posts

Posted - Feb 11 2026 :  07:50:25  Show Profile  Reply
Hi Nigel,
the image I already sent you was recorded at 14 bit, the original was divided in some hundreds raw files that I loaded with TImageEnMIO than saved to Dicom and finally patched by hand the tags BitsStored and HighBit.
All (not many) images I've are near identical :-(
I will ask them to give me more material to work with.
PP
Go to Top of Page

xequte

39450 Posts

Posted - Feb 11 2026 :  21:15:50  Show Profile  Reply
Sorry Pinco, I was meaning a file created by a third party application, but it is OK, I have found one. Can you please email me to test a DICOM_BitsStored property.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PincoPallino

Italy
13 Posts

Posted - Feb 13 2026 :  02:29:18  Show Profile  Reply
Attached one image.

NB: File extension .dcm - this extension is not allowed
So change the extension!


attach/PincoPallino/202621322842_508_anon.DCM.zip
513.67 KB
Go to Top of Page

xequte

39450 Posts

Posted - Feb 13 2026 :  14:18:48  Show Profile  Reply
Thanks Pinco,

Please email me to test the beta.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PincoPallino

Italy
13 Posts

Posted - May 18 2026 :  05:51:09  Show Profile  Reply
Hi,
I see that in V 15.0 the tags BitsStored are HighBit are now correct.

What is still wrong is the default value of
$0028, $1050, '32768'); // Window center
$0028, $1051, '65535'); // Window Width

Where the correct default values has to be:
Window center := 1 shl (Adida.BitsStored -1);
Window Width := 1 shl Adida.BitsStored -1;

This in the case the user has not already set a value.

Best regards
PP
Go to Top of Page

xequte

39450 Posts

Posted - May 27 2026 :  02:17:18  Show Profile  Reply
Thanks Pinco, that is fixed in the latest beta, which you can email us for.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PincoPallino

Italy
13 Posts

Posted - Jun 05 2026 :  03:18:38  Show Profile  Reply
Hi,
just got another problem. Sorry for reporting only a drop a month but who test my software with a real dataset works as is...

The Param.DICOM_Range actually has 2 possible values and in both cases when saving a Dicom image the save procedure does something with bitmap or with tags.
This is problematic because all we know that Dicom is a "standard" so... is not enough standard!
I set some tags before saving that are being stripped by AdjustTags(). What that procedure does is very important but, of course, can not take all things in account.

The last concrete example: it strips tags
if ctx.Params.DICOM_Range = iedrAdjust then
begin
ctx.Params.DICOM_Tags.DeleteTag($0028, $1052, true); // remove Rescale intercept
ctx.Params.DICOM_Tags.DeleteTag($0028, $1053, true); // remove Rescale slope
end
But these tags are required by some applications.

I propose a new value for Params.DICOM_Range: iedrMaintain. With this value the saving code does little work on image, colors and tags and simply saves as is.
Best regards
PP
Go to Top of Page

xequte

39450 Posts

Posted - Jun 18 2026 :  14:51:51  Show Profile  Reply
Hi Pinco

Essentially that would be iedrSetBlackWhite but without setting the white and Black values:

http://www.imageen.com/help/TIEBitmap.BlackValue.html

I.e. iedrMaintain would be the same as using iedrSetBlackWhite, but resetting both BlackValue and WhiteValue to 0 to after loading.

Is that what you mean?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: