簡體   English   中英

在枕頭庫中,BICUBIC 不起作用

[英]In pillow library, BICUBIC is not working

這是我的代碼。

import sys, os
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from scipy import *
sys.path.insert(0, 'C:/research')

im = Image.open('C:/research/1.jpg')
hei, wei = im.height, im.width

im_bicubic = im.resize((wei,hei), im.BICUBIC)

im.save('C:/research/1ori.jpg')            #original image
im_bicubic.save('C:/research/1bic.jpg')    #Images with bicubic applied

但我收到這個錯誤。

AttributeError: 'JpegImageFile' object has no attribute 'BICUBIC'

為什么會出現這條消息?

.bmp ,彈出相同的消息。

我該怎么辦?

您需要使用PIL.Image.BICUBIC而不是im.BICUBIC

所以你需要改變:

im_bicubic = im.resize((wei,hei), im.BICUBIC)

im.resize((wei,hei),PIL.Image.BICUBIC)

您還需要像這樣導入 pil:

import PIL

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM