Unification ct scan voxel size by using interpolation in Python










1















I have used interp2 in Matlab, such as the following code, that is part of @rayryeng's answer in: Three dimensional (3D) matrix interpolation in Matlab:



d = size(volume_image)
[X,Y] = meshgrid(1:1/scaleCoeff(2):d(2), 1:1/scaleCoeff(1):d(1));
for ind = z
%Interpolate each slice via interp2
M2D(:,:,ind) = interp2(volume_image(:,:,ind), X, Y);
end


Example of Dimensions:



The image size is 512x512 and the number of slices is 133. So:
volume_image(rows, columns, slices in 3D dimenson) : 512x512x133 in 3D dimenson
X: 288x288
Y: 288x288
scaleCoeff(2): 0.5625
scaleCoeff(1): 0.5625
z = 1 up to 133 ,hence z: 1x133
ind: 1 up to 133
M2D(:,:,ind) finally is 288x288x133 in 3D dimenson


Aslo, Matlabs syntax for size: (rows, columns, slices in 3rd dimenson) and Python syntax for size: (slices in 3rd dim, rows, columns).
However, after convert the Matlab code to Python code occurred an error, ValueError: Invalid length for input z for non rectangular grid:



for ind in range(0, len(z)+1):
M2D[ind, :, :] = interpolate.interp2d(X, Y, volume_image[ind, :, :]) # ValueError: Invalid length for input z for non rectangular grid


What is wrong? Thank you so much.










share|improve this question
























  • How did you create volume_image? Usually, in Python, arrays are stored in C order, not F order like Matlab, so it would be volume_image[:, :, ind]. Also the range is wrong, you want to use for ind in range(len(z):.

    – Matthieu Brucher
    Oct 26 '18 at 8:12











  • @ Matthieu Brucher: I found out: Matlabs syntax for size: (x = rows, y = columns, z = slices in 3D dimenson) and Python syntax for size: [z = slices in 3D dim, x = rows, y = columns] and also, the range of for is the same as Matlab. I edited my example in the question.

    – eli
    Oct 26 '18 at 8:58












  • How did you read your image? You still have an error with len(z) and why is z not a vector but a matrix?.

    – Matthieu Brucher
    Oct 26 '18 at 8:59












  • @ Matthieu Brucher: I collect the images as volume_image[i, :, :] = dcm_image.pixel_array in a loop. z is number of slices in 3rd dimension.The error is because of interp2d and not len(z).

    – eli
    Oct 26 '18 at 9:16












  • You may want to use scikit.image instead. len(z) is an error, but I would say that the content of volume_image also doesn't allow a good interpolation. But we don't have its content.

    – Matthieu Brucher
    Oct 26 '18 at 9:24















1















I have used interp2 in Matlab, such as the following code, that is part of @rayryeng's answer in: Three dimensional (3D) matrix interpolation in Matlab:



d = size(volume_image)
[X,Y] = meshgrid(1:1/scaleCoeff(2):d(2), 1:1/scaleCoeff(1):d(1));
for ind = z
%Interpolate each slice via interp2
M2D(:,:,ind) = interp2(volume_image(:,:,ind), X, Y);
end


Example of Dimensions:



The image size is 512x512 and the number of slices is 133. So:
volume_image(rows, columns, slices in 3D dimenson) : 512x512x133 in 3D dimenson
X: 288x288
Y: 288x288
scaleCoeff(2): 0.5625
scaleCoeff(1): 0.5625
z = 1 up to 133 ,hence z: 1x133
ind: 1 up to 133
M2D(:,:,ind) finally is 288x288x133 in 3D dimenson


Aslo, Matlabs syntax for size: (rows, columns, slices in 3rd dimenson) and Python syntax for size: (slices in 3rd dim, rows, columns).
However, after convert the Matlab code to Python code occurred an error, ValueError: Invalid length for input z for non rectangular grid:



for ind in range(0, len(z)+1):
M2D[ind, :, :] = interpolate.interp2d(X, Y, volume_image[ind, :, :]) # ValueError: Invalid length for input z for non rectangular grid


What is wrong? Thank you so much.










share|improve this question
























  • How did you create volume_image? Usually, in Python, arrays are stored in C order, not F order like Matlab, so it would be volume_image[:, :, ind]. Also the range is wrong, you want to use for ind in range(len(z):.

    – Matthieu Brucher
    Oct 26 '18 at 8:12











  • @ Matthieu Brucher: I found out: Matlabs syntax for size: (x = rows, y = columns, z = slices in 3D dimenson) and Python syntax for size: [z = slices in 3D dim, x = rows, y = columns] and also, the range of for is the same as Matlab. I edited my example in the question.

    – eli
    Oct 26 '18 at 8:58












  • How did you read your image? You still have an error with len(z) and why is z not a vector but a matrix?.

    – Matthieu Brucher
    Oct 26 '18 at 8:59












  • @ Matthieu Brucher: I collect the images as volume_image[i, :, :] = dcm_image.pixel_array in a loop. z is number of slices in 3rd dimension.The error is because of interp2d and not len(z).

    – eli
    Oct 26 '18 at 9:16












  • You may want to use scikit.image instead. len(z) is an error, but I would say that the content of volume_image also doesn't allow a good interpolation. But we don't have its content.

    – Matthieu Brucher
    Oct 26 '18 at 9:24













1












1








1








I have used interp2 in Matlab, such as the following code, that is part of @rayryeng's answer in: Three dimensional (3D) matrix interpolation in Matlab:



d = size(volume_image)
[X,Y] = meshgrid(1:1/scaleCoeff(2):d(2), 1:1/scaleCoeff(1):d(1));
for ind = z
%Interpolate each slice via interp2
M2D(:,:,ind) = interp2(volume_image(:,:,ind), X, Y);
end


Example of Dimensions:



The image size is 512x512 and the number of slices is 133. So:
volume_image(rows, columns, slices in 3D dimenson) : 512x512x133 in 3D dimenson
X: 288x288
Y: 288x288
scaleCoeff(2): 0.5625
scaleCoeff(1): 0.5625
z = 1 up to 133 ,hence z: 1x133
ind: 1 up to 133
M2D(:,:,ind) finally is 288x288x133 in 3D dimenson


Aslo, Matlabs syntax for size: (rows, columns, slices in 3rd dimenson) and Python syntax for size: (slices in 3rd dim, rows, columns).
However, after convert the Matlab code to Python code occurred an error, ValueError: Invalid length for input z for non rectangular grid:



for ind in range(0, len(z)+1):
M2D[ind, :, :] = interpolate.interp2d(X, Y, volume_image[ind, :, :]) # ValueError: Invalid length for input z for non rectangular grid


What is wrong? Thank you so much.










share|improve this question
















I have used interp2 in Matlab, such as the following code, that is part of @rayryeng's answer in: Three dimensional (3D) matrix interpolation in Matlab:



d = size(volume_image)
[X,Y] = meshgrid(1:1/scaleCoeff(2):d(2), 1:1/scaleCoeff(1):d(1));
for ind = z
%Interpolate each slice via interp2
M2D(:,:,ind) = interp2(volume_image(:,:,ind), X, Y);
end


Example of Dimensions:



The image size is 512x512 and the number of slices is 133. So:
volume_image(rows, columns, slices in 3D dimenson) : 512x512x133 in 3D dimenson
X: 288x288
Y: 288x288
scaleCoeff(2): 0.5625
scaleCoeff(1): 0.5625
z = 1 up to 133 ,hence z: 1x133
ind: 1 up to 133
M2D(:,:,ind) finally is 288x288x133 in 3D dimenson


Aslo, Matlabs syntax for size: (rows, columns, slices in 3rd dimenson) and Python syntax for size: (slices in 3rd dim, rows, columns).
However, after convert the Matlab code to Python code occurred an error, ValueError: Invalid length for input z for non rectangular grid:



for ind in range(0, len(z)+1):
M2D[ind, :, :] = interpolate.interp2d(X, Y, volume_image[ind, :, :]) # ValueError: Invalid length for input z for non rectangular grid


What is wrong? Thank you so much.







python matlab interpolation dicom






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 26 '18 at 20:04







eli

















asked Oct 26 '18 at 8:07









elieli

716




716












  • How did you create volume_image? Usually, in Python, arrays are stored in C order, not F order like Matlab, so it would be volume_image[:, :, ind]. Also the range is wrong, you want to use for ind in range(len(z):.

    – Matthieu Brucher
    Oct 26 '18 at 8:12











  • @ Matthieu Brucher: I found out: Matlabs syntax for size: (x = rows, y = columns, z = slices in 3D dimenson) and Python syntax for size: [z = slices in 3D dim, x = rows, y = columns] and also, the range of for is the same as Matlab. I edited my example in the question.

    – eli
    Oct 26 '18 at 8:58












  • How did you read your image? You still have an error with len(z) and why is z not a vector but a matrix?.

    – Matthieu Brucher
    Oct 26 '18 at 8:59












  • @ Matthieu Brucher: I collect the images as volume_image[i, :, :] = dcm_image.pixel_array in a loop. z is number of slices in 3rd dimension.The error is because of interp2d and not len(z).

    – eli
    Oct 26 '18 at 9:16












  • You may want to use scikit.image instead. len(z) is an error, but I would say that the content of volume_image also doesn't allow a good interpolation. But we don't have its content.

    – Matthieu Brucher
    Oct 26 '18 at 9:24

















  • How did you create volume_image? Usually, in Python, arrays are stored in C order, not F order like Matlab, so it would be volume_image[:, :, ind]. Also the range is wrong, you want to use for ind in range(len(z):.

    – Matthieu Brucher
    Oct 26 '18 at 8:12











  • @ Matthieu Brucher: I found out: Matlabs syntax for size: (x = rows, y = columns, z = slices in 3D dimenson) and Python syntax for size: [z = slices in 3D dim, x = rows, y = columns] and also, the range of for is the same as Matlab. I edited my example in the question.

    – eli
    Oct 26 '18 at 8:58












  • How did you read your image? You still have an error with len(z) and why is z not a vector but a matrix?.

    – Matthieu Brucher
    Oct 26 '18 at 8:59












  • @ Matthieu Brucher: I collect the images as volume_image[i, :, :] = dcm_image.pixel_array in a loop. z is number of slices in 3rd dimension.The error is because of interp2d and not len(z).

    – eli
    Oct 26 '18 at 9:16












  • You may want to use scikit.image instead. len(z) is an error, but I would say that the content of volume_image also doesn't allow a good interpolation. But we don't have its content.

    – Matthieu Brucher
    Oct 26 '18 at 9:24
















How did you create volume_image? Usually, in Python, arrays are stored in C order, not F order like Matlab, so it would be volume_image[:, :, ind]. Also the range is wrong, you want to use for ind in range(len(z):.

– Matthieu Brucher
Oct 26 '18 at 8:12





How did you create volume_image? Usually, in Python, arrays are stored in C order, not F order like Matlab, so it would be volume_image[:, :, ind]. Also the range is wrong, you want to use for ind in range(len(z):.

– Matthieu Brucher
Oct 26 '18 at 8:12













@ Matthieu Brucher: I found out: Matlabs syntax for size: (x = rows, y = columns, z = slices in 3D dimenson) and Python syntax for size: [z = slices in 3D dim, x = rows, y = columns] and also, the range of for is the same as Matlab. I edited my example in the question.

– eli
Oct 26 '18 at 8:58






@ Matthieu Brucher: I found out: Matlabs syntax for size: (x = rows, y = columns, z = slices in 3D dimenson) and Python syntax for size: [z = slices in 3D dim, x = rows, y = columns] and also, the range of for is the same as Matlab. I edited my example in the question.

– eli
Oct 26 '18 at 8:58














How did you read your image? You still have an error with len(z) and why is z not a vector but a matrix?.

– Matthieu Brucher
Oct 26 '18 at 8:59






How did you read your image? You still have an error with len(z) and why is z not a vector but a matrix?.

– Matthieu Brucher
Oct 26 '18 at 8:59














@ Matthieu Brucher: I collect the images as volume_image[i, :, :] = dcm_image.pixel_array in a loop. z is number of slices in 3rd dimension.The error is because of interp2d and not len(z).

– eli
Oct 26 '18 at 9:16






@ Matthieu Brucher: I collect the images as volume_image[i, :, :] = dcm_image.pixel_array in a loop. z is number of slices in 3rd dimension.The error is because of interp2d and not len(z).

– eli
Oct 26 '18 at 9:16














You may want to use scikit.image instead. len(z) is an error, but I would say that the content of volume_image also doesn't allow a good interpolation. But we don't have its content.

– Matthieu Brucher
Oct 26 '18 at 9:24





You may want to use scikit.image instead. len(z) is an error, but I would say that the content of volume_image also doesn't allow a good interpolation. But we don't have its content.

– Matthieu Brucher
Oct 26 '18 at 9:24












2 Answers
2






active

oldest

votes


















2














In MATLAB, interp2 has as arguments:



result = interp2(input_x, input_y, input_z, output_x, output_y)


You are using only the latter 3 arguments, the first two are assumed to be input_x = 1:size(input_z,2) and input_y = 1:size(input_z,1).



In Python, scipy.interpolate.interp2 is quite different: it takes the first 3 input arguments of the MATLAB function, and returns an object that you can call to get interpolated values:



f = scipy.interpolate.interp2(input_x, input_y, input_z)
result = f(output_x, output_y)


Following the example from the documentation, I get to something like this:



from scipy import interpolate
x = np.arange(0, volume_image.shape[2])
y = np.arange(0, volume_image.shape[1])
f = interpolate.interp2d(x, y, volume_image[ind, :, :])
xnew = np.arange(0, volume_image.shape[2], 1/scaleCoeff[0])
ynew = np.arange(0, volume_image.shape[1], 1/scaleCoeff[1])
M2D[ind, :, :] = f(xnew, ynew)


[Code not tested, please let me know if there are errors.]






share|improve this answer























  • There is an error: ValueError: could not broadcast input array from shape (288,1024) into shape (288,288). I want to resize an image with the size of 512x512 to 288x288.

    – eli
    Oct 26 '18 at 20:35











  • @eli: Maybe I misinterpreted your definition of scaleCoeff. Make usre that xnew and ynew each have 288 elements.

    – Cris Luengo
    Oct 26 '18 at 20:44











  • Yes, it was because of scaleCoeff. My problem is solved. Thank you so much.

    – eli
    Oct 26 '18 at 20:56


















0














You might be interested in scipy.ndimage.zoom. If you are interpolating from one regular grid to another, it is much faster and easier to use than scipy.interpolate.interp2d.



See this answer for an example:
https://stackoverflow.com/a/16984081/1295595



You'd probably want something like:



import scipy.ndimage as ndimage
M2D = ndimage.zoom(volume_image, (1, scaleCoeff[0], scaleCoeff[1])





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53004228%2funification-ct-scan-voxel-size-by-using-interpolation-in-python%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    In MATLAB, interp2 has as arguments:



    result = interp2(input_x, input_y, input_z, output_x, output_y)


    You are using only the latter 3 arguments, the first two are assumed to be input_x = 1:size(input_z,2) and input_y = 1:size(input_z,1).



    In Python, scipy.interpolate.interp2 is quite different: it takes the first 3 input arguments of the MATLAB function, and returns an object that you can call to get interpolated values:



    f = scipy.interpolate.interp2(input_x, input_y, input_z)
    result = f(output_x, output_y)


    Following the example from the documentation, I get to something like this:



    from scipy import interpolate
    x = np.arange(0, volume_image.shape[2])
    y = np.arange(0, volume_image.shape[1])
    f = interpolate.interp2d(x, y, volume_image[ind, :, :])
    xnew = np.arange(0, volume_image.shape[2], 1/scaleCoeff[0])
    ynew = np.arange(0, volume_image.shape[1], 1/scaleCoeff[1])
    M2D[ind, :, :] = f(xnew, ynew)


    [Code not tested, please let me know if there are errors.]






    share|improve this answer























    • There is an error: ValueError: could not broadcast input array from shape (288,1024) into shape (288,288). I want to resize an image with the size of 512x512 to 288x288.

      – eli
      Oct 26 '18 at 20:35











    • @eli: Maybe I misinterpreted your definition of scaleCoeff. Make usre that xnew and ynew each have 288 elements.

      – Cris Luengo
      Oct 26 '18 at 20:44











    • Yes, it was because of scaleCoeff. My problem is solved. Thank you so much.

      – eli
      Oct 26 '18 at 20:56















    2














    In MATLAB, interp2 has as arguments:



    result = interp2(input_x, input_y, input_z, output_x, output_y)


    You are using only the latter 3 arguments, the first two are assumed to be input_x = 1:size(input_z,2) and input_y = 1:size(input_z,1).



    In Python, scipy.interpolate.interp2 is quite different: it takes the first 3 input arguments of the MATLAB function, and returns an object that you can call to get interpolated values:



    f = scipy.interpolate.interp2(input_x, input_y, input_z)
    result = f(output_x, output_y)


    Following the example from the documentation, I get to something like this:



    from scipy import interpolate
    x = np.arange(0, volume_image.shape[2])
    y = np.arange(0, volume_image.shape[1])
    f = interpolate.interp2d(x, y, volume_image[ind, :, :])
    xnew = np.arange(0, volume_image.shape[2], 1/scaleCoeff[0])
    ynew = np.arange(0, volume_image.shape[1], 1/scaleCoeff[1])
    M2D[ind, :, :] = f(xnew, ynew)


    [Code not tested, please let me know if there are errors.]






    share|improve this answer























    • There is an error: ValueError: could not broadcast input array from shape (288,1024) into shape (288,288). I want to resize an image with the size of 512x512 to 288x288.

      – eli
      Oct 26 '18 at 20:35











    • @eli: Maybe I misinterpreted your definition of scaleCoeff. Make usre that xnew and ynew each have 288 elements.

      – Cris Luengo
      Oct 26 '18 at 20:44











    • Yes, it was because of scaleCoeff. My problem is solved. Thank you so much.

      – eli
      Oct 26 '18 at 20:56













    2












    2








    2







    In MATLAB, interp2 has as arguments:



    result = interp2(input_x, input_y, input_z, output_x, output_y)


    You are using only the latter 3 arguments, the first two are assumed to be input_x = 1:size(input_z,2) and input_y = 1:size(input_z,1).



    In Python, scipy.interpolate.interp2 is quite different: it takes the first 3 input arguments of the MATLAB function, and returns an object that you can call to get interpolated values:



    f = scipy.interpolate.interp2(input_x, input_y, input_z)
    result = f(output_x, output_y)


    Following the example from the documentation, I get to something like this:



    from scipy import interpolate
    x = np.arange(0, volume_image.shape[2])
    y = np.arange(0, volume_image.shape[1])
    f = interpolate.interp2d(x, y, volume_image[ind, :, :])
    xnew = np.arange(0, volume_image.shape[2], 1/scaleCoeff[0])
    ynew = np.arange(0, volume_image.shape[1], 1/scaleCoeff[1])
    M2D[ind, :, :] = f(xnew, ynew)


    [Code not tested, please let me know if there are errors.]






    share|improve this answer













    In MATLAB, interp2 has as arguments:



    result = interp2(input_x, input_y, input_z, output_x, output_y)


    You are using only the latter 3 arguments, the first two are assumed to be input_x = 1:size(input_z,2) and input_y = 1:size(input_z,1).



    In Python, scipy.interpolate.interp2 is quite different: it takes the first 3 input arguments of the MATLAB function, and returns an object that you can call to get interpolated values:



    f = scipy.interpolate.interp2(input_x, input_y, input_z)
    result = f(output_x, output_y)


    Following the example from the documentation, I get to something like this:



    from scipy import interpolate
    x = np.arange(0, volume_image.shape[2])
    y = np.arange(0, volume_image.shape[1])
    f = interpolate.interp2d(x, y, volume_image[ind, :, :])
    xnew = np.arange(0, volume_image.shape[2], 1/scaleCoeff[0])
    ynew = np.arange(0, volume_image.shape[1], 1/scaleCoeff[1])
    M2D[ind, :, :] = f(xnew, ynew)


    [Code not tested, please let me know if there are errors.]







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 26 '18 at 20:04









    Cris LuengoCris Luengo

    19.4k51947




    19.4k51947












    • There is an error: ValueError: could not broadcast input array from shape (288,1024) into shape (288,288). I want to resize an image with the size of 512x512 to 288x288.

      – eli
      Oct 26 '18 at 20:35











    • @eli: Maybe I misinterpreted your definition of scaleCoeff. Make usre that xnew and ynew each have 288 elements.

      – Cris Luengo
      Oct 26 '18 at 20:44











    • Yes, it was because of scaleCoeff. My problem is solved. Thank you so much.

      – eli
      Oct 26 '18 at 20:56

















    • There is an error: ValueError: could not broadcast input array from shape (288,1024) into shape (288,288). I want to resize an image with the size of 512x512 to 288x288.

      – eli
      Oct 26 '18 at 20:35











    • @eli: Maybe I misinterpreted your definition of scaleCoeff. Make usre that xnew and ynew each have 288 elements.

      – Cris Luengo
      Oct 26 '18 at 20:44











    • Yes, it was because of scaleCoeff. My problem is solved. Thank you so much.

      – eli
      Oct 26 '18 at 20:56
















    There is an error: ValueError: could not broadcast input array from shape (288,1024) into shape (288,288). I want to resize an image with the size of 512x512 to 288x288.

    – eli
    Oct 26 '18 at 20:35





    There is an error: ValueError: could not broadcast input array from shape (288,1024) into shape (288,288). I want to resize an image with the size of 512x512 to 288x288.

    – eli
    Oct 26 '18 at 20:35













    @eli: Maybe I misinterpreted your definition of scaleCoeff. Make usre that xnew and ynew each have 288 elements.

    – Cris Luengo
    Oct 26 '18 at 20:44





    @eli: Maybe I misinterpreted your definition of scaleCoeff. Make usre that xnew and ynew each have 288 elements.

    – Cris Luengo
    Oct 26 '18 at 20:44













    Yes, it was because of scaleCoeff. My problem is solved. Thank you so much.

    – eli
    Oct 26 '18 at 20:56





    Yes, it was because of scaleCoeff. My problem is solved. Thank you so much.

    – eli
    Oct 26 '18 at 20:56













    0














    You might be interested in scipy.ndimage.zoom. If you are interpolating from one regular grid to another, it is much faster and easier to use than scipy.interpolate.interp2d.



    See this answer for an example:
    https://stackoverflow.com/a/16984081/1295595



    You'd probably want something like:



    import scipy.ndimage as ndimage
    M2D = ndimage.zoom(volume_image, (1, scaleCoeff[0], scaleCoeff[1])





    share|improve this answer



























      0














      You might be interested in scipy.ndimage.zoom. If you are interpolating from one regular grid to another, it is much faster and easier to use than scipy.interpolate.interp2d.



      See this answer for an example:
      https://stackoverflow.com/a/16984081/1295595



      You'd probably want something like:



      import scipy.ndimage as ndimage
      M2D = ndimage.zoom(volume_image, (1, scaleCoeff[0], scaleCoeff[1])





      share|improve this answer

























        0












        0








        0







        You might be interested in scipy.ndimage.zoom. If you are interpolating from one regular grid to another, it is much faster and easier to use than scipy.interpolate.interp2d.



        See this answer for an example:
        https://stackoverflow.com/a/16984081/1295595



        You'd probably want something like:



        import scipy.ndimage as ndimage
        M2D = ndimage.zoom(volume_image, (1, scaleCoeff[0], scaleCoeff[1])





        share|improve this answer













        You might be interested in scipy.ndimage.zoom. If you are interpolating from one regular grid to another, it is much faster and easier to use than scipy.interpolate.interp2d.



        See this answer for an example:
        https://stackoverflow.com/a/16984081/1295595



        You'd probably want something like:



        import scipy.ndimage as ndimage
        M2D = ndimage.zoom(volume_image, (1, scaleCoeff[0], scaleCoeff[1])






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 1:37









        craqcraq

        3691621




        3691621



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53004228%2funification-ct-scan-voxel-size-by-using-interpolation-in-python%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            政党

            天津地下鉄3号線