Skip to content

Commit

Permalink
use load_image
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Apr 30, 2024
1 parent 987cb6d commit 07945cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion jcvi/graphics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ def linear_shade(from_color, fraction=0.5):
return linear_blend(from_color, "w", fraction)


def load_image(filename):
def load_image(filename: str) -> np.ndarray:
"""
Load an image file and return as numpy array.
"""
img = plt.imread(filename)
if len(img.shape) == 2: # Gray-scale image, convert to RGB
# http://www.socouldanyone.com/2013/03/converting-grayscale-to-rgb-with-numpy.html
Expand Down
4 changes: 2 additions & 2 deletions jcvi/projects/jcvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ..assembly.hic import draw_hic_heatmap
from ..assembly.kmer import draw_ks_histogram
from ..compara.pedigree import Pedigree, calculate_inbreeding
from ..graphics.base import normalize_axes, panel_labels, plt, savefig
from ..graphics.base import load_image, normalize_axes, panel_labels, plt, savefig
from ..graphics.chromosome import draw_chromosomes
from ..graphics.landscape import draw_multi_depth

Expand Down Expand Up @@ -54,7 +54,7 @@ def diversity(args):
logger.info("Pedigree graph written to `%s`", pngfile)

# Show the image as is
ax1_root.imshow(plt.imread(pngfile))
ax1_root.imshow(load_image(pngfile))
ax1_root.set_axis_off()

# Panel B
Expand Down

0 comments on commit 07945cc

Please sign in to comment.