How do I plot a histogram's image from Pyimagej?

250 Views Asked by At
# Create an ImageJ gateway with the newest available version of ImageJ.
import imagej
import pathlib
import numpy
ij = imagej.init()
# Load an image.
img_path = pathlib.Path('C:/Users/Bernardo/TCC/thyroid/1_1.jpg')
image = ij.io().open(str(img_path))
ij.py.show(image, cmap='gray')

I wanna plot a histogram using pyimagej, after reading this image.

1

There are 1 best solutions below

0
On

well, you can just use matplotlib:

# Create an ImageJ gateway with the newest available version of ImageJ.
import imagej
import pathlib
import numpy
ij = imagej.init()
# Load an image.
img_path = pathlib.Path('C:/Users/Bernardo/TCC/thyroid/1_1.jpg')
image = ij.io().open(str(img_path))
ij.py.show(image, cmap='gray')

import matplotlib.pyplot as plt
plt.hist(image.flatten())