LEADTOOLS Support
Medical
Medical SDK Questions
Is there any faster way to change every pixel's color of a RasterImage
#1
Posted
:
Friday, May 1, 2020 2:15:22 AM(UTC)
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).
,
#2
Posted
:
Friday, May 1, 2020 4:26:18 PM(UTC)
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.
#3
Posted
:
Monday, May 4, 2020 9:48:33 PM(UTC)
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)
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.htmlCode: 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.
#5
Posted
:
Friday, May 8, 2020 8:45:12 PM(UTC)
Groups: Registered
Posts: 21
Your code works well, thanks!
LEADTOOLS Support
Medical
Medical SDK Questions
Is there any faster way to change every pixel's color of a RasterImage
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.