我正在尝试使用python枕头成像库来处理我的jp2图像。
我按照以下步骤操作:
brew install libjpeg
brew install openjpeg
sudo pip install pillow
我对.jp2文件有疑问。可能是什么问题?
我收到错误的代码:
JOptionPane.showMessageDialog (null, "This program calculates tidal volume.", "Tidal Volume Calculator", JOptionPane.INFORMATION_MESSAGE);
name = JOptionPane.showInputDialog("What is your name?");
while (flag3 == true)
{
sex = JOptionPane.showInputDialog("What is your sex?");
if(sex.equalsIgnoreCase("male") || sex.equalsIgnoreCase("m"))
{
while (flag2 == true)
{
height = Integer.parseInt(JOptionPane.showInputDialog("What is your height? (48-84 inches or 114-213 centimeters) \nEnter whole numbers only."));
if(height <= 84 && height >= 48)
{
malePbwInch = 50 + 2.3 * (height - 60);
JOptionPane.showMessageDialog(null, name + "'s predicted body weight is: " + malePbwInch);
flag2 = false;
flag3 = false;
}
if(height <= 213 && height >= 114)
{
malePbwCm = 50 + .91 * (height - 152.4);
JOptionPane.showMessageDialog(null, name + "'s predicted body weight is: " + malePbwCm);
flag2 = false;
flag3 = false;
}
if(height > 84 && height < 114 || height < 48 || height > 213)
{
JOptionPane.showMessageDialog(null, "Invalid height. Please try again.");
}
else
{
try
{
malePbwInch = Integer.parseInt(height);
}
catch(NumberFormatException e)
{
JOptionPane.showMessageDialog(null, "Invalid height. Please try again.");
}
}
}
}
当我尝试显示图像时,我收到了以下错误日志:
from PIL import Image
im = Image.open("sample_1.jp2")
im.show()
答案 0 :(得分:1)
我想我发现了这个问题......
Pillow installation on Mac OSX声明:
我们为车轮格式的每个受支持的Python版本提供OS X的二进制文件。这些包括对除OpenJPEG之外的所有可选库的支持。
我想唯一的解决方法是从源代码安装Pillow。
作为与问题没有直接关系的附注,从源代码安装后,我收到了不同的错误:
Nicolas$ python selftest.py
Traceback (most recent call last):
File "selftest.py", line 11, in <module>
from PIL import Image, ImageDraw, ImageFilter, ImageMath
File "/Users/Nicolas/Downloads/Pillow-3.1.0/PIL/Image.py", line 66, in <module>
from PIL import _imaging as core
ImportError: cannot import name _imaging
所以我不知道这是否有效。如果我设法让它工作,将会更新。