How the Ndarray array of numpy reshape into a fixed size

Source: Internet
Author: User

In the case of pulmonary nodule detection, the size varies after the Dicom file reshape is encountered. Because of the big, numpy.reshape can not be reshaped to a specified size. Finally, a solution was found in the code of a Daniel.

VL = np.load (R ' D:\pycharm\TEAMWORK\Preprocess_3D\imageOR.npy ')
# in my imageor, every file except for the 3-dimensional ndarray, which also holds the tag lab, is written in isometric_volume[0], so if you only have the array information, simply remove the following [0]
votal = []
For Isometric_volume in VL:
print (isometric_volume[0], ' first ')
mean = Np.mean (isometric_volume[0]). Astype (Np.float32)
std = np.std (isometric_volume[0]). Astype (Np.float32)
volume_resized = Scipy.ndimage.interpolation.zoom (isometric_volume[0],
np.divide (isometric_volume[0].shape),
mode= ' nearest ')
volume_resized = (Volume_resized.astype (np.float32)-mean)/(Std + 1e-7)
z0, z1 = VOLUME_RESIZED.SHAPE[0]//2, volume_resized.shape[0]
y0, y1 = 0, Volume_resized.shape[1]//2
volume_resized = Volume_resized[z0:z1, y0:y1,:]
Votal.append ([volume_resized, Isometric_volume[1]])
print (volume_resized, ' volume_resized ')
print (Volume_resized.shape)
print (votal, ' votal ')


np.save (' Newimage.npy ', votal)

How the Ndarray array of numpy reshape into a fixed size

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.