Giter VIP home page Giter VIP logo

ljpeg3's Introduction

ljpeg3

Open ljpeg files as NumPy arrays

This is a wrapper around the Stanford ljpeg code, which is public domain and also included. It's loosely based on @aaalgo/ljpeg, updated for Python 3 and slightly refactored.

You probably would want to use it to open images from the DDSM Mammography Database, as they had the genius idea of using this near-extinct image format.

Installation

You should have NumPy installed:

pip3 install numpy

Clone this repository:

git clone https://github.com/olieidel/ljpeg3.git

Build the ljpeg stuff. Some warnings may appear, ignore them and hope for the best. I have no idea how to fix the C code if it doesn't work for you.

cd ljpeg3/jpegdir
make

Usage

In your python project, add ljpeg3 to your path and import it:

import sys
sys.path.append('/path_to/ljpeg3')
from ljpeg3 import ljpeg

Read a .ljpeg file. There should also be an .ics file in the same directory.

im = ljpeg.read('path_to/some_file.ljpeg')

Use NumPy for further processing. Good luck!

Notes

In most cases, the height and width information from the ljpeg file is swapped and the ics file is needed to correct it. Oh, and swapped height und width is not equivalent to simply transposing the matrix.. :)

If you don't have an .ics file and your image looks weird, try this:

im = ljpeg.read('path_to/some_file.ljpeg')
im = im.reshape((im.shape[1], im.shape[0]))  # swaps width and height

# im = im.T <-- this won't work

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.