ljpeg-master
所属分类:文件格式
开发工具:Python
文件大小:201KB
下载次数:1
上传日期:2019-04-20 00:29:00
上 传 者:
mahdavipak
说明: Convert Ljpeg to jpg
文件列表:
LICENSE (1291, 2017-07-17)
__init__.py (0, 2017-07-17)
jpegdir (0, 2017-07-17)
jpegdir\CHANGES (2644, 2017-07-17)
jpegdir\PORTABILITY (365, 2017-07-17)
jpegdir\SETUP (2601, 2017-07-17)
jpegdir\blkint.jpg (2899, 2017-07-17)
jpegdir\blkint.jpg.1 (16384, 2017-07-17)
jpegdir\blkint.jpg.2 (8192, 2017-07-17)
jpegdir\blkint.jpg.3 (8192, 2017-07-17)
jpegdir\chendct.c (8528, 2017-07-17)
jpegdir\codec.c (14854, 2017-07-17)
jpegdir\csize.h (2147, 2017-07-17)
jpegdir\dct.h (4348, 2017-07-17)
jpegdir\doc.ps (474103, 2017-07-17)
jpegdir\globals.h (7281, 2017-07-17)
jpegdir\huffman.c (16802, 2017-07-17)
jpegdir\io.c (30497, 2017-07-17)
jpegdir\jpeg.1 (6494, 2017-07-17)
jpegdir\jpeg.c (67996, 2017-07-17)
jpegdir\leedct.c (9325, 2017-07-17)
jpegdir\lexer.l (28678, 2017-07-17)
jpegdir\makefile (1641, 2017-07-17)
jpegdir\marker.c (18008, 2017-07-17)
jpegdir\marker.h (1783, 2017-07-17)
jpegdir\nonint.jpg (2922, 2017-07-17)
jpegdir\param.h (3946, 2017-07-17)
jpegdir\prototypes.h (5108, 2017-07-17)
jpegdir\stream.c (24441, 2017-07-17)
jpegdir\stream.h (1548, 2017-07-17)
jpegdir\system.h (3678, 2017-07-17)
jpegdir\tables.h (4706, 2017-07-17)
jpegdir\test.3stream (625, 2017-07-17)
jpegdir\test.huff (3789, 2017-07-17)
jpegdir\test.q (593, 2017-07-17)
jpegdir\transform.c (11621, 2017-07-17)
ljpeg.py (2966, 2017-07-17)
... ...
Usage:
0. Install flex with
``` apt-get install flex```.
Building without flex will fail and pollute the codebase.
1. In your python project
```
git clone https://github.com/***lgo/ljpeg.git
```
Or if you are using git already:
```
git submodule add https://github.com/***lgo/ljpeg.git
```
2. Produce the jpeg binary.
```
cd jpegdir; make
```
3. In your python code:
```
from ljpeg import ljpeg
x = ljpeg.read(path)
```
The loaded is a matrix of type uint16. Typically you want to convert that
to float for subsequent processing.
```
x = ljpeg.read(path).astype('float')
```
The LJPEG format sometimes has wrong values for width and height (transposed).
One has to read the correct values of width and height from the associating .ics file.
Below is a sample snippet for this purpose:
```
W = None
H = None
# find the shape of image
for l in open(ics, 'r'):
l = l.strip().split(' ')
if len(l) < 7:
continue
if l[0] == name:
W = int(l[4])
H = int(l[2])
bps = int(l[6])
if bps != 12:
logging.warn('BPS != 12: %s' % path)
break
assert W != None
assert H != None
if W != image.shape[1]:
logging.warn('reshape: %s' % path)
image = image.reshape((H, W))
```
4. Using ljpeg.py standalone:
- Convert to TIFF (requires the .ics file in the same directory as LJPEG)
```
./ljpeg.py cases/benigns/benign_01/case0029/C_0029_1.LEFT_CC.LJPEG output.tiff
```
- Convert to TIFF and verify that no information has been lost
```
./ljpeg.py cases/benigns/benign_01/case0029/C_0029_1.LEFT_CC.LJPEG output.tiff --verify
```
- Convert to jpeg for visualization with down-sizing scale=0.3 (16-bit TIFF is not good for direct visualization)
```
./ljpeg.py cases/benigns/benign_01/case0029/C_0029_1.LEFT_CC.LJPEG output.jpg --visual --scale 0.3
```
Note that output file can be any format that's supported by OpenCV (which includes all common types). Most file formats only support 8-bit images, so directly saving into such file formats will cause problems. Add "--visual" to normalize color into 8-bit before saving to such file formats.
The Stanford ljpeg code is in public domain and is therefore OK to be
included here. I did minor modification to make the code compile under
modern Linux.
近期下载者:
相关文件:
收藏者: