This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Thursday, June 21, 2007 7:53:03 AM(UTC)
Groups: Registered
Posts: 21
Hello,
I'm using .NET am my previous posts. How do you obtain a pixel value? I would like to do so to calculate the Hounsfeld Unit (HU). I'm probably missing an obvious Member in the documentation...
Thanks,
Will
#2
Posted
:
Thursday, June 21, 2007 7:24:50 PM(UTC)
Groups: Registered
Posts: 21
Hey Everyone,
Ignore this post - I believe I found it in the RasterImage class. I figured it was in a Dicom one and thats why I didn't find it.
Thanks,
Will
#3
Posted
:
Friday, June 22, 2007 7:43:56 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 764
You are correct. You should use either the RasterImage.GetPixelColor method which returns a RasterColor or the RasterImage.GetPixelData which returns either a byte array or updates a pointer you pass to it.
#4
Posted
:
Monday, June 25, 2007 7:42:45 AM(UTC)
Groups: Registered
Posts: 21
Greg,
Thanks for your continual support. I have noticed I seem to be getting some strange values for the pixel data. Do you have any examples available of using it in claculation of the Hounsfield Unit (CT Number)? I'm probably missing something simple.
Thanks,
Will
#5
Posted
:
Tuesday, June 26, 2007 4:50:44 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 764
What do you mean by "strange values"? Please explain in greater detail so I can understand the problem more clearly.
#6
Posted
:
Tuesday, June 26, 2007 6:52:31 AM(UTC)
Groups: Registered
Posts: 21
Hi Greg,
I am getting numbers that change drastically pixel to pixel. For instance, the pixel value will go from -100 to 250 to 27, etc. I have tested this in other programs I know work and it is not the case.
Here is my code: (label1 is just a text label where i display the value on mouse over)
byte[] data = original.GetPixelData(e.X, e.Y);
label1.Text = "" + BitConverter.ToInt16(data, 0);
If you have any thoughts let me know. Thanks aas always for your prompt help!
Will
#7
Posted
:
Wednesday, June 27, 2007 4:26:59 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 764
There are a couple of factors that could be affecting this.
If your image is grayscale, remember that each pixel value is an index into the LUT. Also recall that only values between the LowBit and HighBit properties are valid so you may need to do some logical bit masking first.
Some DICOM images can also be signed or unsigned. If your image is unsigned, then you will probably want to convert your 2 dimensional byte array to a UInt16 rather than an Int16.
If your image is color, I would use the UInt16 since the high bit is the Alpha, and the remaining 15 bits are divided evenly between RGB (or BGR depending on the order).
For more information, take a look at the remarks section of the help file article regarding the GetPixelData Method.
#8
Posted
:
Wednesday, June 27, 2007 8:30:29 AM(UTC)
Groups: Registered
Posts: 21
Hi Greg,
Thanks again for your reponse.
I am working at this point with a signed 16bit grayscale DICOM image, hence why I used a signed Int16. HighBit is 15, low is 0.
Is there any example of how to get the appropriate value for Hounsfield unit? I did review the remarks section, and it did have additional information, but not that helped me really. I hate to bother you in asking for an example, but my company will be purchasing/licensing some DICOM library and it is by far my favorite, and I'd like to use it but I must be able to derive Hounsfield units properly.
Thanks,
Will
#9
Posted
:
Thursday, June 28, 2007 5:23:46 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 764
Most likely, you're having a problem with your LUTs. I can't say exactly where it lies, but conversion to HUs is outisde the scope of LEADTOOLS, we simply provide an interface to the DICOM file. There might be a couple things you need to do with the LUT before you call GetPixelData or GetPixelColor to give you a proper value for getting the HU. I would check the DICOM specifications for information on how and when to use the LUTs to convert to HUs.
#10
Posted
:
Friday, June 29, 2007 6:20:22 AM(UTC)
Groups: Registered
Posts: 21
My understanding, though, after apply Modality LUT's, the pixel data becomes the HU. If that is the case, wouldn't ApplyLinearModalityLookupTableCommand take care of this? I have used that class and the numbers are close to the real ones (within 150 approximately).
#11
Posted
:
Tuesday, July 3, 2007 4:46:20 AM(UTC)
Groups: Registered, Tech Support
Posts: 207
Was thanked: 3 time(s) in 3 post(s)
I've looked over this post and the issue looks like you are switching the X,Y value you pass into GetPixelColor or GetPixelData. These function parameters expect Row, Column. The Row is the Y coodinate. The Column is the X. So if you are using the MouseCoordinate you must pass GetPixelColor(Y, X) or GetPixelData(Y,X).
Also, if you are using the mouse coordinate remember to adjust the ClientCoordinates to BitmapCoordinates like this:
private void ClientToBitmapPt(RasterImageViewer viewer, ref Point ptBmp, PointF ptClient)
{
// Convert Client Coordinates to Bitmap Coordinates
Transformer t = new Transformer(viewer.Transform);
// Convert to compensate for view size mode, scale, scroll, etc...
ptBmp = Point.Round(t.PointToLogical(ptClient));
// This is always a TopLeft, so convert to image view perspective
// ptBmp = viewer.Image.PointToImage(RasterViewPerspective.TopLeft, ptBmp);
ptBmp = viewer.Image.PointToImage(RasterViewPerspective.TopLeft, ptBmp);
}
I have attached a sample which updates the Title of the window with the color located under the mouse.
Travis Montgomery
Senior Sales Engineer
#12
Posted
:
Tuesday, July 3, 2007 5:48:28 AM(UTC)
Groups: Registered
Posts: 21
Hi Travis,
Thanks so much! I think I have it working now!
I am a little confused on the point of the Transformation of client coordinates, however. I have tried it with raw mouse coordinates, and running it through the code you provided in ClientToBitmapPt. The raw mouse coordinates seem to give the correct data, and once transforming it, it becomes incorrect data (well, I'm guessing it's actually now looking up data from another point).
Any thoughts?
Again, thank you SO much!!!
Will
#13
Posted
:
Tuesday, July 3, 2007 11:03:17 AM(UTC)
Groups: Registered, Tech Support
Posts: 207
Was thanked: 3 time(s) in 3 post(s)
The ClientToBitmapPt function accounts for the View Perspective of the image too. Check with the image I sent and see if it works with that. It did when I tested here, but if we do not have the same DLLs, you could be getting a different result. Let me know.
Travis Montgomery
Senior Sales Engineer
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.