Как мне обработать массив numpy (img1) с помощью cv2? - PullRequest
0 голосов
/ 18 мая 2018

Как мне обработать img1 (массив numpy) с помощью cv2?Я пытался конвертировать его с помощью CreateMat. Но CreateMat не поддерживается cv2.

    # Load dimensions based on the number of rows, columns, and slices (along 
    the Z axis)
    ConstPixelDims = (int(RefDs.Rows), int(RefDs.Columns), len(lstFilesDCM))

    # Load spacing values (in mm)
    ConstPixelSpacing = (float(RefDs.PixelSpacing[0]), 
    float(RefDs.PixelSpacing[1]), float(RefDs.SliceThickness))

    x = np.arange(0.0, (ConstPixelDims[0]+1)*ConstPixelSpacing[0], 
    ConstPixelSpacing[0])
    y = np.arange(0.0, (ConstPixelDims[1]+1)*ConstPixelSpacing[1], 
    ConstPixelSpacing[1])
    z = np.arange(0.0, (ConstPixelDims[2]+1)*ConstPixelSpacing[2], 
    ConstPixelSpacing[2])

    # The array is sized based on 'ConstPixelDims'
    ArrayDicom = np.zeros(ConstPixelDims, 
    dtype=RefDs.pixel_array.dtype,np.float32)

    # loop through all the DICOM files
    for filenameDCM in lstFilesDCM:
    # read the file
    ds = dicom.read_file(filenameDCM)
    # store the raw image data
    ArrayDicom[:, :, lstFilesDCM.index(filenameDCM)] = ds.pixel_array

    #numpy array for the 11th image in the directory
    img1 = ArrayDicom[:, :, 10]

Есть ли способ конвертировать img1?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...