Hi all, I want to scale up an image twice as big using Sitk C#:
var img = Sitk.ReadImage(file);
var scale = new ScaleTransform(2, new VectorDouble(2) { 0.5, 0.5 });
var imageScaled = Sitk.Resample(img, scale, InterpolatorEnum.sitkBSpline, 0.0 );
Sitk.WriteImage(imageScaled, dirOut + "resampled.png");
The imageScaled has the same width & height and spacing as the input image, it shows quarter of the original content, twice as big. How can I resize the whole image, so the result has width * 2, height * 2, and still show the full content? Seems a very simple problem but I just couldn’t get it work…
Commonly it is desirable to maintain the physical location of the image data while “scaling” up the image. This could be done by using the input image (img) as a reference image for the ResampleImageFilter, and then change the spacing and origin to match the desired resampling resolution and location.
Thanks! So does that mean Resample() etc. are designed to keep the physical location and change the spacing, other than those common paint or photo editing software just change the number of pixels?
Just for the completeness of this post, so the simplest way to do it in C#: var imgExpand = Sitk.Expand(img, new VectorUInt32(new uint[] { 2, 2 }), InterpolatorEnum.sitkLinear);