2017-11-12 7 views
0

파이썬을 통해 8by8 블록 dct 변환을 수행하고 있습니다. 오류는 다음과 같은 오류 메시지가 같이있다 : 당신은 전치을 적용하기 전에 배열에 이미지 개체를 변환 할 필요가속성 오류 : 이미지 객체에 속성이 없습니다. T

from scipy.fftpack import dct 
from PIL import Image 
import glob 

def dct_2(img): 
    #Get 2D Cosine Transform of Image 

    return dct(dct(img.T, norm='ortho').T, norm='ortho') 

images = image_open(path) 

for i in range(0, len(images)): 
    box3 = (1,1,256,256) 
    a = images[i].crop(box3) 
    width , height = a.size 

    (y,cb,cr) = a.split() 

    for q in range(1, height-32 , 32): 
     for w in range(1 , width-32 ,32): 
      box1 =(q,w,q+63,w+63) 
      block = y.crop(box1) 

      for j in range(1,64,8): 
       for n in range(1,64,8): 
        box2 = (j,n,j+7,n+7) 
        temp = block.crop(box2) 

        dct_temp = dct_2(temp) 

답변

1

: 여기

AttributeError: 'Image' object has no attribute 'T' 

내 코드의 일부이다.

import numpy as np 

def dct_2(img): 
    #Get 2D Cosine Transform of Image 
    return dct(dct(np.asarray(img).T, norm='ortho').T, norm='ortho') 
+0

와우 작동합니다. 고마워요! – twi

+0

여기 초보자이며 질문을 완료로 표시하는 방법을 모르겠습니다. 여기에 완벽한 버튼이 있습니까? 또는 완성 된대로 제목을 씁니까? 나는 그 방법을 알고 있다면 나는 알 수 없다. 감사 – twi