Java 使用jai imageio中的TIFFImageReader时如何设置图像分辨率
我正在使用jai imageio库1.3.1读取分辨率为1728*2164的多tiff图像 代码是:Java 使用jai imageio中的TIFFImageReader时如何设置图像分辨率,java,tiff,javax.imageio,jai,Java,Tiff,Javax.imageio,Jai,我正在使用jai imageio库1.3.1读取分辨率为1728*2164的多tiff图像 代码是: ImageInputStream is = ImageIO.createImageInputStream(new File(path)); Iterator<ImageReader> iterator = ImageIO.getImageReaders(is); TIFFImageReader reader = (TIFFImageReader) iterator.next(); r
ImageInputStream is = ImageIO.createImageInputStream(new File(path));
Iterator<ImageReader> iterator = ImageIO.getImageReaders(is);
TIFFImageReader reader = (TIFFImageReader) iterator.next();
reader.setInput(is);
我看到图像的高度只有1082px
如何读取全分辨率tiff图像,或者设置要读取的不同分辨率
这是我文件中的所有元数据
<TIFFField number="256" name="ImageWidth">
<TIFFLongs>
<TIFFLong value="1728"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="257" name="ImageLength">
<TIFFLongs>
<TIFFLong value="1082"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="258" name="BitsPerSample">
<TIFFShorts>
<TIFFShort value="1"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="259" name="Compression">
<TIFFShorts>
<TIFFShort value="3" description="CCITT T.4"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="262" name="PhotometricInterpretation">
<TIFFShorts>
<TIFFShort value="0" description="WhiteIsZero"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="266" name="FillOrder">
<TIFFShorts>
<TIFFShort value="1" description="LeftToRight"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="273" name="StripOffsets">
<TIFFLongs>
<TIFFLong value="210"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="277" name="SamplesPerPixel">
<TIFFShorts>
<TIFFShort value="1"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="278" name="RowsPerStrip">
<TIFFLongs>
<TIFFLong value="1082"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="279" name="StripByteCounts">
<TIFFLongs>
<TIFFLong value="23214"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="282" name="XResolution">
<TIFFRationals>
<TIFFRational value="200/1"/>
</TIFFRationals>
</TIFFField>
<TIFFField number="283" name="YResolution">
<TIFFRationals>
<TIFFRational value="100/1"/>
</TIFFRationals>
</TIFFField>
<TIFFField number="284" name="PlanarConfiguration">
<TIFFShorts>
<TIFFShort value="1" description="Chunky"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="292" name="T4Options">
<TIFFLongs>
<TIFFLong value="0" description="Default 1DCoding"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="296" name="ResolutionUnit">
<TIFFShorts>
<TIFFShort value="2" description="Inch"/>
</TIFFShorts>
</TIFFField>
</TIFFIFD>
</com_sun_media_imageio_plugins_tiff_image_1.0>
Format name: javax_imageio_1.0
<javax_imageio_1.0>
<Chroma>
<ColorSpaceType name="GRAY"/>
<BlackIsZero value="FALSE"/>
<NumChannels value="1"/>
</Chroma>
<Compression>
<CompressionTypeName value="CCITT T.4"/>
<Lossless value="TRUE"/>
<NumProgressiveScans value="1"/>
</Compression>
<Data>
<PlanarConfiguration value="PixelInterleaved"/>
<SampleFormat value="UnsignedIntegral"/>
<BitsPerSample value="1"/>
<SampleMSB value="7"/>
</Data>
<Dimension>
<PixelAspectRatio value="0.5"/>
<HorizontalPixelSize value="0.127"/>
<VerticalPixelSize value="0.254"/>
</Dimension>
<Document>
<FormatVersion value="6.0"/>
</Document>
<Transparency>
<Alpha value="none"/>
</Transparency>
</javax_imageio_1.0>
格式名称:javax_imageio_1.0
从TIFF标签可以看到图像的真实分辨率为1728x1082。这是一个分辨率为200x100的传真,因此像素需要垂直拉伸2倍才能在显示时看起来正确。嗨,BitBank,感谢您的澄清。
<TIFFField number="256" name="ImageWidth">
<TIFFLongs>
<TIFFLong value="1728"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="257" name="ImageLength">
<TIFFLongs>
<TIFFLong value="1082"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="258" name="BitsPerSample">
<TIFFShorts>
<TIFFShort value="1"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="259" name="Compression">
<TIFFShorts>
<TIFFShort value="3" description="CCITT T.4"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="262" name="PhotometricInterpretation">
<TIFFShorts>
<TIFFShort value="0" description="WhiteIsZero"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="266" name="FillOrder">
<TIFFShorts>
<TIFFShort value="1" description="LeftToRight"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="273" name="StripOffsets">
<TIFFLongs>
<TIFFLong value="210"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="277" name="SamplesPerPixel">
<TIFFShorts>
<TIFFShort value="1"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="278" name="RowsPerStrip">
<TIFFLongs>
<TIFFLong value="1082"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="279" name="StripByteCounts">
<TIFFLongs>
<TIFFLong value="23214"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="282" name="XResolution">
<TIFFRationals>
<TIFFRational value="200/1"/>
</TIFFRationals>
</TIFFField>
<TIFFField number="283" name="YResolution">
<TIFFRationals>
<TIFFRational value="100/1"/>
</TIFFRationals>
</TIFFField>
<TIFFField number="284" name="PlanarConfiguration">
<TIFFShorts>
<TIFFShort value="1" description="Chunky"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="292" name="T4Options">
<TIFFLongs>
<TIFFLong value="0" description="Default 1DCoding"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="296" name="ResolutionUnit">
<TIFFShorts>
<TIFFShort value="2" description="Inch"/>
</TIFFShorts>
</TIFFField>
</TIFFIFD>
</com_sun_media_imageio_plugins_tiff_image_1.0>
Format name: javax_imageio_1.0
<javax_imageio_1.0>
<Chroma>
<ColorSpaceType name="GRAY"/>
<BlackIsZero value="FALSE"/>
<NumChannels value="1"/>
</Chroma>
<Compression>
<CompressionTypeName value="CCITT T.4"/>
<Lossless value="TRUE"/>
<NumProgressiveScans value="1"/>
</Compression>
<Data>
<PlanarConfiguration value="PixelInterleaved"/>
<SampleFormat value="UnsignedIntegral"/>
<BitsPerSample value="1"/>
<SampleMSB value="7"/>
</Data>
<Dimension>
<PixelAspectRatio value="0.5"/>
<HorizontalPixelSize value="0.127"/>
<VerticalPixelSize value="0.254"/>
</Dimension>
<Document>
<FormatVersion value="6.0"/>
</Document>
<Transparency>
<Alpha value="none"/>
</Transparency>
</javax_imageio_1.0>