I am working on a project to fuse two DICOM Image by myself.
Image 1 (168x168) When the images of Image 2 (512x512) are combined, the two images do not match at all.
I don't think there's a problem with the merging script, but If you think the merging code is the problem, you can ask for it.
Image 2 (512x512)
Image 1 (168x168)
Upsizing is finished Image 1 (168x168) => Image 1 (512x512)Image
fusion result
The red part of the picture should match the gray part.
If you look closely at the picture, you can see that the scale is slightly small and does not exactly match up, down, left and right.
Problem (I guess)
When changing from 168 to 512, the decimal points are multiplied and the pixel values of small points are lost.
Since the 512x512 Image 1 is not fixed in the center, if I increase the scale and do not give a padding value, it will not fit.
it is resize code
public static Bitmap resizeImage(Bitmap image, int width, int height)
{
var destinationRect = new Rectangle(0, 0, width, height);
var destinationImage = new Bitmap(width, height);
destinationImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
using (var graphics = Graphics.FromImage(destinationImage))
{
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
using (var wrapMode = new ImageAttributes())
{
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
graphics.DrawImage(image, destinationRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
}
}
return destinationImage;
}
image 2
image 1
thankyou for nucleaR
i make
Value=pixelSpacingPT* 168 - pixelSpacingCT *512
cutPixel=Value/pixelSpacingPT;
The pixels to be cropped are now 20 pixels wide I found out that it is 20 pixels in height.