|
ClearCanvas Community Forums
|
Dicom Print Help
Last Post 2010-08-09 12:12 PM by stewart. 10 Replies.
|
Sort:
|
|
Prev Next |
You are not authorized to post a reply. |
|
dicomprint Posts:12
 |
| 2010-06-28 11:33 AM |
|
Hi All,
I am generating a Big bitmap based on film size and DPI. If it is 14x17inch film my Print bitmap size is 14*200Dpi and 17*200dpi. After generating the bmp i am sending this bitmap data to the printer using Basic Grayscaleprint scu module by filling respective IODS(filmbox ,image box etc). While i print i am using the printer's magnification as as Bilinear.But no effect on printed film. even though i switch it to Cubic interpolation. what should i do to get the interpolation effect on printed film?
I am using DrawToBitmap function to generate Bitmap for DicomPrint.As far as i know DrawToBitmap is using Bilinear interpolation. Is it possible to set any interpolation factor using clear canvas sdk? So that i can get better quality bitmap.
can any one help me regarding this?
|
|
|
|
|
stewart
 Senior Member Posts:2033
 |
| 2010-07-12 12:28 PM |
|
Hi, the viewer has only one interpolation mode, which is bilinear. I suspect the reason you're not seeing any effect on the printer, as far as interpolation goes, is because the image you are sending is the right size for the film, and hence the printer doesn't have to do much interpolation; the viewer has done it already. I suggest you try drawing a bitmap that is the exact size of the real DICOM image (e.g. 512x512), which will pretty much eliminate interpolation on the workstation side, then set the interpolation mode to cubic on the printer. |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
stewart
 Senior Member Posts:2033
 |
| 2010-07-12 12:39 PM |
|
|
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
dicomprint Posts:12
 |
| 2010-07-14 10:52 AM |
|
Hi Stewart,
Thanks for your reply, but I am not able to see your post. It redirects to this forum
|
|
|
|
|
stewart
 Senior Member Posts:2033
 |
| 2010-07-14 11:30 AM |
|
Sorry, I actually meant to put that post in a different thread, pointing to my first post in this one. |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
dicomprint Posts:12
 |
| 2010-07-19 12:04 PM |
|
Hi Stewart,
Is there any possibility to change BILINEAR algorithm to CUBIC algorithm in DrawToBitmap function? Can i have the source code for BilinearInterpolation.dll? Is it based on DCMTK? Please help me regarding this?
|
|
|
|
|
sezerpal
 Veteran Member Posts:113
 |
| 2010-07-19 01:19 PM |
|
Hi Steward, Could you show us a way to develop a print DICOM Print plug in? Do you have any future plans for it. What are the resources? How people print from CC WS? Thanks, Sezer Pal |
|
|
|
|
stewart
 Senior Member Posts:2033
 |
| 2010-07-21 01:18 PM |
|
Hi, sorry but implementing a DICOM Print plugin is too complicated for me to explain in a forum post in a way that will actually be useful to you. All I can suggest is to start diving into the DICOM Toolkit's print-scu classes as well as the DICOM Standard to figure out how to do it. We don't have any plans to implement DICOM Print in the near future, so right now you cannot print. CC is pretty much a "digital review only" app. |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
stewart
 Senior Member Posts:2033
 |
| 2010-07-21 01:52 PM |
|
To answer your question, the bilinear interpolation source code is in the Trunk (ImageViewer/Rendering/BilinearInterpolation/BilinearInterpolation.cpp). I wrote it in C++, and it's my own implementation using fixed point arithmetic. You could pretty much copy the bilinear interpolation code and just replace the couple of functions that actually do the interpolation. Hope this helps, Stewart |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
dicomprint Posts:12
 |
| 2010-07-27 10:50 AM |
|
Hi Stewart,
I have just modified the function InterpolateBilinearUnsigned16. I am calling BicubicInterPolatoin function with Pixelvalues from InterpolateBilinearUnsigned16
InterpolateBilinearUnsigned16.(I am handling only 16bit DICOM)
I am taking the Pixel Values as follows in the for Loop for (unsigned int x = 0; x < dstRegionWidth; ++x) of InterpolateBilinearUnsigned16
{
/// FirsRow Pixels
pSrcPixel00 = pRowSrcPixelData + (*pxPixel);
pSrcPixel01 = pSrcPixel00 + 1;
pSrcPixel02 = pSrcPixel00 + 2;
pSrcPixel03 = pSrcPixel00 + 3;
//Second Row Pixels
pSrcPixel10 = pSrcPixel00 + srcWidth;
pSrcPixel11 = pSrcPixel10 + 1;
pSrcPixel12 = pSrcPixel10 + 2;
pSrcPixel13 = pSrcPixel10 + 3;
// 3rd Row Pixels
pSrcPixel20 = pSrcPixel00 + srcWidth*2;
pSrcPixel21 = pSrcPixel20 + 1;
pSrcPixel22 = pSrcPixel20 + 2;
pSrcPixel23 = pSrcPixel20 + 3;
//4Th Row Pixels
pSrcPixel30 = pSrcPixel00 + srcWidth*3;
pSrcPixel31 = pSrcPixel30 + 1;
pSrcPixel32 = pSrcPixel30 + 2;
pSrcPixel33 = pSrcPixel30 + 3;
//Function call to Bicubic Interpolation
BicubicInterPolation(*pdxFixed,dyFixed,(int)*pSrcPixel00, (int)*pSrcPixel01,(int)*pSrcPixel02,(int)*pSrcPixel03,
(int)*pSrcPixel10, (int)*pSrcPixel11,(int)*pSrcPixel12,(int)*pSrcPixel13,
(int)*pSrcPixel20, (int)*pSrcPixel21,(int)*pSrcPixel22,(int)*pSrcPixel23,
(int)*pSrcPixel30, (int)*pSrcPixel31,(int)*pSrcPixel32,(int)*pSrcPixel33);
}
I have used your calculation of dyFixed and *pdxFixed
BicubicInterPolation(int dx,int dy,int C00, int C01, int C02, int C03,
int C10, int C11, int C12, int C13,
int C20, int C21, int C22, int C23,
int C30, int C31, int C32, int C33 )
{
int d0,d2,d3;
int a0,a1,a2,a3;
int Ca,Cb,Cc,Cd;
int Dx = dx;
int Dx2 = dx *dx;
int Dx3 = dx * dx *dx;
int Dy = dy;
int Dy2 = dy *dy;
int Dy3 = dy *dy*dy;
///Ca Calculation
d0 = C00-C01;
d2 = C02-C01;
d3 = C03-C01;
a0 = C01;
a1 = (int)(-(1/3)*(float)d0 + (float)d2 -(1/6)*(float)d3);
a2 = (int)((0.5)*d0 + 0.5*(float)d2);
a3 = (int)(-(1/6)*d0 -(0.5)*(float)(d2) + float((1/6))*float(d3));
Ca = a0 + a1 *Dy + a2*Dy2 + a3*Dy3;
///Cb Calculation
d0 = C10-C11;
d2 = C12-C11;
d3 = C13-C11;
a0 = C11;
a1 = (int)(-(1/3)*(float)d0 + (float)d2 -(1/6)*(float)d3);
a2 = (int)((0.5)*d0 + 0.5*(float)d2);
a3 = (int)(-(1/6)*d0 -(0.5)*(float)(d2) + float((1/6))*float(d3));
Cb = a0 + a1*Dy + a2*Dy2 + a3*Dy3;
///Cc Calculation
d0 = C20-C21;
d2 = C22-C21;
d3 = C23-C21;
a0 = C21;
a1 = (int)(-(1/3)*(float)d0 + (float)d2 -(1/6)*(float)d3);
a2 = (int)((0.5)*d0 + 0.5*(float)d2);
a3 = (int)(-(float)(1/6)*(float)(d0) -(0.5)*(float)(d2) + float((1/6))*float(d3));
Cc = a0 + a1*Dy + a2*Dy2 + a3*Dy3;
///Cd Calculation
d0 = C30-C31;
d2 = C32-C31;
d3 = C33-C31;
a0 = C31;
a1 = (int)(-(1/3)*(float)d0 + (float)d2 -(1/6)*(float)d3);
a2 = (int)((0.5)*d0 + 0.5*(float)d2);
a3 = (int)(- (float)(1/6)*float(d0) -(0.5)*(float)(d2) + float((1/6))*float(d3));
Cd = a0 + a1*Dy+ a2*Dy2 + a3*Dy3;
d0 = Ca- Cb;
d2 = Cc -Cb;
d3 = Cd-Cb;
a0 = Cb;
a1 = (int)(-(float)(1/3)*(float)d0 + (float)d2 -(float)(1/6) * (float)d3);
a2 = (int)((0.5)*(float)d0 + 0.5*(float)d2);
a3 = (int)(- (float)(1/6)*float(d0) -(0.5)*(float)(d2) + float((1/6))*float(d3));
int interpolatedvalue = a0 + a1*Dx + a2*Dx2 + a3*Dx3;
}
My Problem is the interpolated value is very high. Should i do any modfication on calculating of Ca,Cb,Cc,Cd
You did some fixed point arithmetic in Bilinear , I dont know where to apply that. I am just modifiying BilinearInterpolateUnsigned16 function alone. Becoz i am handling
only this kind of DICOM only. Can you please help where should i use Fixed Point (>>FIXEDPRESION).All other calculation like pdxFixed,dyFixed are taken from your function.
Can you please help me regarding fixed Point arithemetic. I wrote the above function based on the attached pdf.
} |
Attachment: bicubic03042002.pdf
|
|
|
|
stewart
 Senior Member Posts:2033
 |
| 2010-08-09 12:12 PM |
|
I'm going to guess that you are casting to int too early. a1, a2, a3 should probably still be floats when you calculate Ca,b,c,d. Not sure, but you may also want to leave Ca,b,c,d as floats and do a final cast to int at the end (interpolatedvalue). As far as fixed point arithmetic goes, it's a bit hard to explain in a few sentences. There are some good articles out there that explain it - there's one on Wikipedia. As far as implementing it goes, what I remember is that every single time you do a multiplication, you need to right shift again before doing the next one. Every single float should be converted to a fixed point integer, including the fixed ones, like 1/3, 1/6, etc. When I wrote it, I remember it was very painstaking and tedious to get it right, and to get it so it actually gave the right answer. |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
| You are not authorized to post a reply. |
|
Active Forums 4.1
|
|
|
|
|