From 6d84099746e614b4712ad66a9b0d1c0a9e30a0b9 Mon Sep 17 00:00:00 2001 From: Zak Morgan Date: Thu, 24 Jul 2025 13:22:00 +0100 Subject: [PATCH 1/3] Update README.md Added windows instructions and updated dependcy versions --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2aaf26a..a4a736c 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ PyLBFGS is a Python 3 wrapper of the [libLBFGS][libLBFGS] library -- a C port (w At this time, only the Orthant-Wise Limited-memory Quasi-Newton (OWL-QN) algorithm is exposed (although very little work would be required to expose the full [libLBFGS][libLBFGS] implementation). -Also note that PyLBFGS has only been compiled and tested with Python 3 on a 64-bit Ubuntu machine. It should work in other environments... but tweaking the installation commands is a task left to the reader. +Also note that PyLBFGS has only been compiled and tested with Python 3 on a 64-bit Ubuntu machine and a 64-bit Windows machine. It should work in other environments... but tweaking the installation commands is a task left to the reader. +In order to compile on Windows one simply has to remove the "runtime_library_dirs" line in setup.py, and modify the library/include dirs to point to your install. You must also add the x64 build target when building libLBFGS in visual studio if compiling for a x64 machine and version of python. Install @@ -27,7 +28,7 @@ Install 3. Setup and activate a virtual environment (modify the Python version if necessary): - virtualenv -p python3.6 --prompt="(pylbfgs) " .venv + virtualenv -p python3.12.9 --prompt="(pylbfgs) " .venv . .venv/bin/activate 4. Install the project: @@ -83,7 +84,7 @@ Examples See the *example.py* script for an advanced example in which we use compressed sensing to reconstruct a sparsely sampled image. A more thorough example of compressed sensing (using PyLBFGS) can be found on my weblog [here][blog_post]. - pip install Pillow==5.0.0 scipy==1.0.0 matplotlib==2.1.2 + pip install Pillow==11.1.0 scipy==1.15.2 matplotlib==3.1.0 python example.py From 6c731a6067f4bc3fe186fe2f765f8dfcfa55378f Mon Sep 17 00:00:00 2001 From: Zak Morgan Date: Thu, 24 Jul 2025 13:24:54 +0100 Subject: [PATCH 2/3] Update example.py Replace deprecated and removed scipy.ndimage.imread --- example.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/example.py b/example.py index 2220b60..ce4683f 100755 --- a/example.py +++ b/example.py @@ -4,6 +4,7 @@ import numpy as np import scipy.fftpack as spfft import scipy.ndimage as spimg +import imageio import matplotlib.pyplot as plt from pylbfgs import owlqn @@ -178,8 +179,12 @@ def main(): global _b_vector, _A_matrix, _image_dims, _ri_vector - # read image in grayscale, then downscale it - Xorig = spimg.imread(ORIG_IMAGE_PATH, flatten=True, mode='L') + # read image in, then convert to grayscale and then downscale it + Xorig = imageio.imread(ORIG_IMAGE_PATH) + # Cast to float before grayscale conversion + Xorig = Xorig.astype(float) + # Preserving the behaviour of mode='L' from the deprecated scipy.ndimage.imread + Xorig = Xorig[:, :, 0] * 299/1000 + Xorig[:, :, 1] * 587/1000 + Xorig[:, :, 2] * 114/1000 X = spimg.zoom(Xorig, SCALE) ny, nx = X.shape From bdb21daca8abc56cf0ace772fcd2507fe3e30823 Mon Sep 17 00:00:00 2001 From: Zak Morgan Date: Thu, 24 Jul 2025 13:52:15 +0100 Subject: [PATCH 3/3] Update example.py Make sure all images displayed are sharing a common colour-range for the colourmap, otherwise you can be decieved as to the output looking less-similar than it actually is. --- example.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/example.py b/example.py index ce4683f..05a2ef9 100755 --- a/example.py +++ b/example.py @@ -269,9 +269,9 @@ def main(): # display the result f, ax = plt.subplots(1, 3, figsize=(14, 4)) - ax[0].imshow(X, cmap='hot', interpolation='none') - ax[1].imshow(Xm, cmap='hot', interpolation='none') - ax[2].imshow(Xa, cmap='hot', interpolation='none') + ax[0].imshow(X, cmap='hot', interpolation='none',vmin=0, vmax=255) + ax[1].imshow(Xm, cmap='hot', interpolation='none',vmin=0, vmax=255) + ax[2].imshow(Xa, cmap='hot', interpolation='none',vmin=0, vmax=255) plt.show()