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 : Thursday, July 23, 2009 8:10:06 PM(UTC)
boris_qbf

Groups: Registered
Posts: 7


Hi there I have a problem with StatisticsInformationCommand

When I invoke Run method passing 12Bit grayscale image I am getting Invalid Parameters Passed exception.

My code looks like this:

StatisticsInformationCommand command = new StatisticsInformationCommand {Start = 0, End = 4095};
command.Run(image);

textBoxMean.Text = command.Mean.ToString("N2");
textBoxStandardDeviation.Text = command.StandardDeviation.ToString("N2");

If i change End property to 255 instead of 4095 it works - but I need to calculate stats on the whole range of pixel values - from 0 to 2^12 -1

Environment:
Leadtools 16.5 Medical and Medical Net licensees purchased

.Net C#

I've checked that the document support is unlocked as suggested in another post to this forum (by calling RasterSupport.IsLocked(RasterSupportType.Document)) - it made no difference.

Please tell me what am I doing wrong.

Thank you
Boris
 

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, July 24, 2009 6:21:15 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 766


If the image is 12bpp, 0-4095 is the correct range.  Are you certain that the RasterImage.BitsPerPixel property is actually 12 when it gets run through the command?  Add a breakpoint or messagebox to verify it.

What's the file version of Leadtools.dll that you're using?  If it's older than 16.5.0.3 then you don't have the latest version.  Currently, our installer has the latest version so you can just download the main installer from our website again and get the latest DLLs from that.

If the problem persists in the latest build, please send a small sample project (NOT your entire application) that isolates this problem so I can try to reproduce it here.  I will also need a sample image from you that causes the problem.

NOTE: If you are attaching a project or file to the forums...
1.) Zip the file(s) up.
2.) Make sure it is less than 5 MB.  If it is larger, please send an email to support@leadtools.com and we'll send you FTP instructions.
3.) Remove ANY AND ALL unlock codes and LEADTOOLS DLLs.
4.) Do not click the preview button, the attachment will not show up when you post it.

If you do not wish to post your file(s) on the forum since they are publically viewable, please send an email to support@leadtools.com and make sure that you include a link to this forum post.
 
#3 Posted : Sunday, July 26, 2009 5:44:57 PM(UTC)
boris_qbf

Groups: Registered
Posts: 7


Hi Greg

BitsPerPixel is actually 16 - it is a 16bpp grayscale image, not 12 bit. I have checked the version - leadtools.dll is 16.5.0.3 so I will be sending you a small app to look at. As the image file is quite large I can't post it to the forum

Thank you
Boris
 
#4 Posted : Wednesday, July 29, 2009 1:04:19 AM(UTC)
boris_qbf

Groups: Registered
Posts: 7


Thank you for pointing to UseLookupTable property of the RasterImage being set to true.
The small application I sent to you is "a small application", in reality the image I need the stats for is coming from a MedicalViewer. The image would always have UseLookupTable set to true as the LUT is used for Window Width/Centre adjustments. So setting UseLookupTable to false is not an option for me. In regards to using GrayscaleCommand - I can take it as a workaround but in order to do it I would need to clone the image as I don't want the original image to be modified just for the purpose of obtaining stats (semantically gathering statistic is a read-only operation). I believe it would be much cleaner if StatisticsInformationCommand encapsulates all functionality required for processing RasterImages with or without LUT
I ended up with a code like this:
using (RasterImage img = _image.Clone())
{
try
{
GrayscaleCommand gray = new GrayscaleCommand(img.BitsPerPixel); //Apply LUT
gray.Run(img);
StatisticsInformationCommand command = new StatisticsInformationCommand
{
Start = 0,
End = (2 << _image.BitsPerPixel - 1) - 1,
Channel = RasterColorChannel.Master
};
//Get statistical image information.
command.Run(img);
textBoxMean.Text = command.Mean.ToString("f2");
// other stats
}
catch (Exception ex)
{
// ... some error handling
}
}

Any chance that this issue would be fixed?

Thanks again
Boris
 
#5 Posted : Wednesday, July 29, 2009 4:54:29 AM(UTC)

Basel  
Guest

Groups: Guests
Posts: 3,034

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

Boris,
When there's a LUT in the image, its pixel values are mapped from 16 bits (65535 levels) to 256 intensity levels, even though the internal pixel intensities are true 16-bit.

This means applying the Grayscale(16) command to a copy of the image is the correct way to obtain statistical information for the real grayscale data.

 
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-2020, Yet Another Forum.NET
This page was generated in 0.181 seconds.