Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, May 1, 2020 2:15:22 AM(UTC)
devinzhu

Groups: Registered
Posts: 21


I'm using Leadtools Medical SDK v20 to develop a medical viewer, and I want to develop a custom RasterCommand which change the image to negative image(like InvertCommand). and I tried to get the pixel data one by one and set it back like following code:
Quote:
public override RasterImageChangedFlags Run(RasterImage image)
{
for (int i=0; i< image.Height; i++)
{
for(int j=0; j<image.Width; j++)
{
RasterColor color = image.GetPixelColor(i, j);
image.SetPixelColor(new RasterColor(255-color.R, 255-color.G,255-color.B));
}
}
}

It works well, but for a image with 888*1399, it will cost about 20 seconds. Is there more effient way to implement this?
BTW: the InvertCommand of the Medical SDK provide this functionality, but it failed to work on some specified images(like dcm files in attached zip, after execute InvertCommand on this file, it will become a totally black image).
File Attachment(s):
11474.zip (239kb) downloaded 22 time(s).
,
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Friday, May 1, 2020 4:26:18 PM(UTC)

Nick  
Nick

Groups: Registered, Tech Support, Administrators
Posts: 163

Was thanked: 9 time(s) in 9 post(s)

Note since these are DICOM images there exists pixel information within them outside the visible range, with the upper boundaries being all completely white, which the InvertCommand functions as expected with images of this type.

Note saving to a different format eliminates this non-visible data and as such the InvertCommand would function as expected. Could you clarify your work flow and your use case?
Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#3 Posted : Monday, May 4, 2020 9:48:33 PM(UTC)
devinzhu

Groups: Registered
Posts: 21


Hello, thanks for responding, I want to implement InvertCommand just like other DICOM Viewer. change the orginal image(It's one of the image in my attached zip of original post):
[img=http://www.youtj.cn/wordpress/orginal-2]orginal image[/img]
to
[img=http://www.youtj.cn/wordpress/invert_expected]inverted image[/img]
But I found the InvertCommand of LeadTools SDK does not work like this, so I want to know is there any other way to implement this functionality?
 
#4 Posted : Tuesday, May 5, 2020 3:07:31 PM(UTC)

Nick  
Nick

Groups: Registered, Tech Support, Administrators
Posts: 163

Was thanked: 9 time(s) in 9 post(s)

Consider converting the image to Grayscale preemptively. This reduces the maximum value and disables the LUT such that the InvertCommand functions as expected.

https://www.leadtools.co...ng-grayscalecommand.html

Code:
         RasterCodecs codecs = new RasterCodecs();
         RasterImage image = codecs.Load(input);

         GrayscaleCommand gc = new GrayscaleCommand(16);
         gc.Run(image);

         InvertCommand ic = new InvertCommand();
         ic.Run(image);

Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#5 Posted : Friday, May 8, 2020 8:45:12 PM(UTC)
devinzhu

Groups: Registered
Posts: 21


Your code works well, thanks!
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.084 seconds.