mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-08 08:47:58 +08:00
changed f to fig
This commit is contained in:
@@ -35,7 +35,7 @@ edges1 = filter.canny(im)
|
||||
edges2 = filter.canny(im, sigma=3)
|
||||
|
||||
# display results
|
||||
f, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(8, 3))
|
||||
fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(8, 3))
|
||||
|
||||
ax1.imshow(im, cmap=plt.cm.jet)
|
||||
ax1.axis('off')
|
||||
@@ -49,7 +49,7 @@ ax3.imshow(edges2, cmap=plt.cm.gray)
|
||||
ax3.axis('off')
|
||||
ax3.set_title('Canny filter, $\sigma=3$', fontsize=20)
|
||||
|
||||
f.subplots_adjust(wspace=0.02, hspace=0.02, top=0.9,
|
||||
fig.subplots_adjust(wspace=0.02, hspace=0.02, top=0.9,
|
||||
bottom=0.02, left=0.02, right=0.98)
|
||||
|
||||
plt.show()
|
||||
|
||||
@@ -29,7 +29,7 @@ r = np.sin(np.exp((np.sin(x)**3 + np.cos(y)**2)))
|
||||
contours = measure.find_contours(r, 0.8)
|
||||
|
||||
# Display the image and plot all contours found
|
||||
f, ax = plt.subplots()
|
||||
fig, ax = plt.subplots()
|
||||
ax.imshow(r, interpolation='nearest', cmap=plt.cm.gray)
|
||||
|
||||
for n, contour in enumerate(contours):
|
||||
|
||||
@@ -29,7 +29,7 @@ image[230:280, 60:110] = 1
|
||||
coords = corner_peaks(corner_harris(image), min_distance=5)
|
||||
coords_subpix = corner_subpix(image, coords, window_size=13)
|
||||
|
||||
f, ax = plt.subplots()
|
||||
fig, ax = plt.subplots()
|
||||
ax.imshow(image, interpolation='nearest', cmap=plt.cm.gray)
|
||||
ax.plot(coords[:, 1], coords[:, 0], '.b', markersize=3)
|
||||
ax.plot(coords_subpix[:, 1], coords_subpix[:, 0], '+r', markersize=15)
|
||||
|
||||
@@ -20,7 +20,7 @@ img = data.camera()
|
||||
descs, descs_img = daisy(img, step=180, radius=58, rings=2, histograms=6,
|
||||
orientations=8, visualize=True)
|
||||
|
||||
f, ax = plt.subplots()
|
||||
fig, ax = plt.subplots()
|
||||
ax.axis('off')
|
||||
ax.imshow(descs_img)
|
||||
descs_num = descs.shape[0] * descs.shape[1]
|
||||
|
||||
@@ -22,11 +22,11 @@ fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(10, 4))
|
||||
img0 = ax0.imshow(image, cmap=plt.cm.gray)
|
||||
ax0.set_title('Image')
|
||||
ax0.axis('off')
|
||||
plt.colorbar(img0, ax=ax0)
|
||||
fig.colorbar(img0, ax=ax0)
|
||||
|
||||
img1 = ax1.imshow(entropy(image, disk(5)), cmap=plt.cm.jet)
|
||||
ax1.set_title('Entropy')
|
||||
ax1.axis('off')
|
||||
plt.colorbar(img1, ax=ax1)
|
||||
fig.colorbar(img1, ax=ax1)
|
||||
|
||||
plt.show()
|
||||
|
||||
@@ -70,7 +70,7 @@ img_eq = exposure.equalize_hist(img)
|
||||
img_adapteq = exposure.equalize_adapthist(img, clip_limit=0.03)
|
||||
|
||||
# Display results
|
||||
f, axes = plt.subplots(nrows=2, ncols=4, figsize=(8, 5))
|
||||
fig, axes = plt.subplots(nrows=2, ncols=4, figsize=(8, 5))
|
||||
|
||||
ax_img, ax_hist, ax_cdf = plot_img_and_hist(img, axes[:, 0])
|
||||
ax_img.set_title('Low contrast image')
|
||||
@@ -92,5 +92,5 @@ ax_cdf.set_ylabel('Fraction of total intensity')
|
||||
ax_cdf.set_yticks(np.linspace(0, 1, 5))
|
||||
|
||||
# prevent overlap of y-axis labels
|
||||
f.subplots_adjust(wspace=0.4)
|
||||
fig.subplots_adjust(wspace=0.4)
|
||||
plt.show()
|
||||
|
||||
@@ -90,7 +90,7 @@ image = color.rgb2gray(data.lena())
|
||||
fd, hog_image = hog(image, orientations=8, pixels_per_cell=(16, 16),
|
||||
cells_per_block=(1, 1), visualise=True)
|
||||
|
||||
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4))
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4))
|
||||
|
||||
ax1.axis('off')
|
||||
ax1.imshow(image, cmap=plt.cm.gray)
|
||||
|
||||
@@ -23,7 +23,7 @@ image = rescale_intensity(image, in_range=(50, 200))
|
||||
|
||||
# convenience function for plotting images
|
||||
def imshow(image, title, **kwargs):
|
||||
f, ax = plt.subplots(figsize=(5, 4))
|
||||
fig, ax = plt.subplots(figsize=(5, 4))
|
||||
ax.imshow(image, **kwargs)
|
||||
ax.axis('off')
|
||||
ax.set_title(title)
|
||||
|
||||
@@ -61,7 +61,7 @@ h = rescale_intensity(ihc_hed[:, :, 0], out_range=(0, 1))
|
||||
d = rescale_intensity(ihc_hed[:, :, 2], out_range=(0, 1))
|
||||
zdh = np.dstack((np.zeros_like(h), d, h))
|
||||
|
||||
f, ax = plt.subplots()
|
||||
fig, ax = plt.subplots()
|
||||
ax.imshow(zdh)
|
||||
ax.set_title("Stain separated image (rescaled)")
|
||||
ax.axis('off')
|
||||
|
||||
@@ -77,7 +77,7 @@ image[idx, idx] = 255
|
||||
|
||||
h, theta, d = hough_line(image)
|
||||
|
||||
f, ax = plt.subplots(1, 3, figsize=(8, 4))
|
||||
fig, ax = plt.subplots(1, 3, figsize=(8, 4))
|
||||
|
||||
ax[0].imshow(image, cmap=plt.cm.gray)
|
||||
ax[0].set_title('Input image')
|
||||
@@ -108,7 +108,7 @@ image = data.camera()
|
||||
edges = canny(image, 2, 1, 25)
|
||||
lines = probabilistic_hough_line(edges, threshold=10, line_length=5, line_gap=3)
|
||||
|
||||
f2, ax = plt.subplots(1, 3, figsize=(8, 3))
|
||||
fig2, ax = plt.subplots(1, 3, figsize=(8, 3))
|
||||
|
||||
ax[0].imshow(image, cmap=plt.cm.gray)
|
||||
ax[0].set_title('Input image')
|
||||
|
||||
@@ -72,7 +72,7 @@ img_eq = rank.equalize(img, selem=selem)
|
||||
|
||||
|
||||
# Display results
|
||||
f, axes = plt.subplots(2, 3, figsize=(8, 5))
|
||||
fig, axes = plt.subplots(2, 3, figsize=(8, 5))
|
||||
|
||||
ax_img, ax_hist, ax_cdf = plot_img_and_hist(img, axes[:, 0])
|
||||
ax_img.set_title('Low contrast image')
|
||||
@@ -87,5 +87,5 @@ ax_cdf.set_ylabel('Fraction of total intensity')
|
||||
|
||||
|
||||
# prevent overlap of y-axis labels
|
||||
plt.subplots_adjust(wspace=0.4)
|
||||
fig.subplots_adjust(wspace=0.4)
|
||||
plt.show()
|
||||
|
||||
@@ -37,15 +37,15 @@ threshold_global_otsu = threshold_otsu(img)
|
||||
global_otsu = img >= threshold_global_otsu
|
||||
|
||||
|
||||
f, ax = plt.subplots(2, 2, figsize=(8, 5))
|
||||
fig, ax = plt.subplots(2, 2, figsize=(8, 5))
|
||||
ax1, ax2, ax3, ax4 = ax.ravel()
|
||||
|
||||
f.colorbar(ax1.imshow(img, cmap=plt.cm.gray),
|
||||
fig.colorbar(ax1.imshow(img, cmap=plt.cm.gray),
|
||||
ax=ax1, orientation='horizontal')
|
||||
ax1.set_title('Original')
|
||||
ax1.axis('off')
|
||||
|
||||
f.colorbar(ax2.imshow(local_otsu, cmap=plt.cm.gray),
|
||||
fig.colorbar(ax2.imshow(local_otsu, cmap=plt.cm.gray),
|
||||
ax=ax2, orientation='horizontal')
|
||||
ax2.set_title('Local Otsu (radius=%d)' % radius)
|
||||
ax2.axis('off')
|
||||
|
||||
@@ -55,12 +55,12 @@ skel, distance = medial_axis(data, return_distance=True)
|
||||
# Distance to the background for pixels of the skeleton
|
||||
dist_on_skel = distance * skel
|
||||
|
||||
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4))
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4))
|
||||
ax1.imshow(data, cmap=plt.cm.gray, interpolation='nearest')
|
||||
ax1.axis('off')
|
||||
ax2.imshow(dist_on_skel, cmap=plt.cm.spectral, interpolation='nearest')
|
||||
ax2.contour(data, [0.5], colors='w')
|
||||
ax2.axis('off')
|
||||
|
||||
f.subplots_adjust(hspace=0.01, wspace=0.01, top=1, bottom=0, left=0, right=1)
|
||||
fig.subplots_adjust(hspace=0.01, wspace=0.01, top=1, bottom=0, left=0, right=1)
|
||||
plt.show()
|
||||
|
||||
@@ -28,7 +28,7 @@ image = camera()
|
||||
thresh = threshold_otsu(image)
|
||||
binary = image > thresh
|
||||
|
||||
f, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(8, 2.5))
|
||||
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(8, 2.5))
|
||||
ax1.imshow(image, cmap=plt.cm.gray)
|
||||
ax1.set_title('Original')
|
||||
ax1.axis('off')
|
||||
|
||||
@@ -25,7 +25,7 @@ image_max = ndimage.maximum_filter(im, size=20, mode='constant')
|
||||
coordinates = peak_local_max(im, min_distance=20)
|
||||
|
||||
# display results
|
||||
f, ax = plt.subplots(1, 3, figsize=(8, 3))
|
||||
fig, ax = plt.subplots(1, 3, figsize=(8, 3))
|
||||
ax1, ax2, ax3 = ax.ravel()
|
||||
ax1.imshow(im, cmap=plt.cm.gray)
|
||||
ax1.axis('off')
|
||||
@@ -41,7 +41,7 @@ ax3.plot([p[1] for p in coordinates], [p[0] for p in coordinates], 'r.')
|
||||
ax3.axis('off')
|
||||
ax3.set_title('Peak local max')
|
||||
|
||||
f.subplots_adjust(wspace=0.02, hspace=0.02, top=0.9,
|
||||
fig.subplots_adjust(wspace=0.02, hspace=0.02, top=0.9,
|
||||
bottom=0.02, left=0.02, right=0.98)
|
||||
|
||||
plt.show()
|
||||
|
||||
@@ -26,19 +26,19 @@ image_wrapped = np.angle(np.exp(1j * image))
|
||||
# Perform phase unwrapping
|
||||
image_unwrapped = unwrap_phase(image_wrapped)
|
||||
|
||||
f, ax = plt.subplots(2, 2)
|
||||
fig, ax = plt.subplots(2, 2)
|
||||
ax1, ax2, ax3, ax4 = ax.ravel()
|
||||
|
||||
f.colorbar(ax1.imshow(image, cmap='gray', vmin=0, vmax=4 * np.pi), ax=ax1)
|
||||
fig.colorbar(ax1.imshow(image, cmap='gray', vmin=0, vmax=4 * np.pi), ax=ax1)
|
||||
ax1.set_title('Original')
|
||||
|
||||
f.colorbar(ax2.imshow(image_wrapped, cmap='gray', vmin=-np.pi, vmax=np.pi), ax=ax2)
|
||||
fig.colorbar(ax2.imshow(image_wrapped, cmap='gray', vmin=-np.pi, vmax=np.pi), ax=ax2)
|
||||
ax2.set_title('Wrapped phase')
|
||||
|
||||
f.colorbar(ax3.imshow(image_unwrapped, cmap='gray'), ax=ax3)
|
||||
fig.colorbar(ax3.imshow(image_unwrapped, cmap='gray'), ax=ax3)
|
||||
ax3.set_title('After phase unwrapping')
|
||||
|
||||
f.colorbar(ax4.imshow(image_unwrapped - image, cmap='gray'), ax=ax4)
|
||||
fig.colorbar(ax4.imshow(image_unwrapped - image, cmap='gray'), ax=ax4)
|
||||
ax4.set_title('Unwrapped minus original')
|
||||
|
||||
"""
|
||||
@@ -64,21 +64,21 @@ image_unwrapped_no_wrap_around = unwrap_phase(image_wrapped,
|
||||
image_unwrapped_wrap_around = unwrap_phase(image_wrapped,
|
||||
wrap_around=(True, False))
|
||||
|
||||
f, ax = plt.subplots(2, 2)
|
||||
fig, ax = plt.subplots(2, 2)
|
||||
ax1, ax2, ax3, ax4 = ax.ravel()
|
||||
|
||||
f.colorbar(ax1.imshow(np.ma.array(image, mask=mask), cmap='jet'), ax=ax1)
|
||||
fig.colorbar(ax1.imshow(np.ma.array(image, mask=mask), cmap='jet'), ax=ax1)
|
||||
ax1.set_title('Original')
|
||||
|
||||
f.colorbar(ax2.imshow(image_wrapped, cmap='jet', vmin=-np.pi, vmax=np.pi),
|
||||
fig.colorbar(ax2.imshow(image_wrapped, cmap='jet', vmin=-np.pi, vmax=np.pi),
|
||||
ax=ax2)
|
||||
ax2.set_title('Wrapped phase')
|
||||
|
||||
f.colorbar(ax3.imshow(image_unwrapped_no_wrap_around, cmap='jet'),
|
||||
fig.colorbar(ax3.imshow(image_unwrapped_no_wrap_around, cmap='jet'),
|
||||
ax=ax3)
|
||||
ax3.set_title('Unwrapped without wrap_around')
|
||||
|
||||
f.colorbar(ax4.imshow(image_unwrapped_wrap_around, cmap='jet'), ax=ax4)
|
||||
fig.colorbar(ax4.imshow(image_unwrapped_wrap_around, cmap='jet'), ax=ax4)
|
||||
ax4.set_title('Unwrapped with wrap_around')
|
||||
|
||||
plt.show()
|
||||
|
||||
@@ -35,7 +35,7 @@ out_rows = image.shape[0] - 1.5 * 50
|
||||
out_cols = cols
|
||||
out = warp(image, tform, output_shape=(out_rows, out_cols))
|
||||
|
||||
f, ax = plt.subplots()
|
||||
fig, ax = plt.subplots()
|
||||
ax.imshow(out)
|
||||
ax.plot(tform.inverse(src)[:, 0], tform.inverse(src)[:, 1], '.b')
|
||||
ax.axis((0, out_cols, out_rows, 0))
|
||||
|
||||
@@ -30,6 +30,6 @@ for p in pyramid[1:]:
|
||||
composite_image[i_row:i_row + n_rows, cols:cols + n_cols] = p
|
||||
i_row += n_rows
|
||||
|
||||
f, ax = plt.subplots()
|
||||
fig, ax = plt.subplots()
|
||||
ax.imshow(composite_image)
|
||||
plt.show()
|
||||
|
||||
@@ -60,7 +60,7 @@ from skimage.transform import radon, rescale
|
||||
image = imread(data_dir + "/phantom.png", as_grey=True)
|
||||
image = rescale(image, scale=0.4)
|
||||
|
||||
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4.5))
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4.5))
|
||||
|
||||
ax1.set_title("Original")
|
||||
ax1.imshow(image, cmap=plt.cm.Greys_r)
|
||||
@@ -73,7 +73,7 @@ ax2.set_ylabel("Projection position (pixels)")
|
||||
ax2.imshow(sinogram, cmap=plt.cm.Greys_r,
|
||||
extent=(0, 180, 0, sinogram.shape[0]), aspect='auto')
|
||||
|
||||
f.subplots_adjust(hspace=0.4, wspace=0.5)
|
||||
fig.subplots_adjust(hspace=0.4, wspace=0.5)
|
||||
plt.show()
|
||||
|
||||
"""
|
||||
@@ -101,7 +101,7 @@ error = reconstruction_fbp - image
|
||||
print('FBP rms reconstruction error: %.3g' % np.sqrt(np.mean(error**2)))
|
||||
|
||||
imkwargs = dict(vmin=-0.2, vmax=0.2)
|
||||
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4.5))
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4.5))
|
||||
ax1.set_title("Reconstruction\nFiltered back projection")
|
||||
ax1.imshow(reconstruction_fbp, cmap=plt.cm.Greys_r)
|
||||
ax2.set_title("Reconstruction error\nFiltered back projection")
|
||||
@@ -152,7 +152,7 @@ error = reconstruction_sart - image
|
||||
print('SART (1 iteration) rms reconstruction error: %.3g'
|
||||
% np.sqrt(np.mean(error**2)))
|
||||
|
||||
f, ax = plt.subplots(2, 2, figsize=(8, 8.5))
|
||||
fig, ax = plt.subplots(2, 2, figsize=(8, 8.5))
|
||||
ax1, ax2, ax3, ax4 = ax.ravel()
|
||||
ax1.set_title("Reconstruction\nSART")
|
||||
ax1.imshow(reconstruction_sart, cmap=plt.cm.Greys_r)
|
||||
|
||||
@@ -58,7 +58,7 @@ markers[data > 1.3] = 2
|
||||
labels = random_walker(data, markers, beta=10, mode='bf')
|
||||
|
||||
# Plot results
|
||||
f, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(8, 3.2))
|
||||
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(8, 3.2))
|
||||
ax1.imshow(data, cmap='gray', interpolation='nearest')
|
||||
ax1.axis('off')
|
||||
ax1.set_title('Noisy data')
|
||||
@@ -69,6 +69,6 @@ ax3.imshow(labels, cmap='gray', interpolation='nearest')
|
||||
ax3.axis('off')
|
||||
ax3.set_title('Segmentation')
|
||||
|
||||
f.subplots_adjust(hspace=0.01, wspace=0.01, top=1, bottom=0, left=0,
|
||||
fig.subplots_adjust(hspace=0.01, wspace=0.01, top=1, bottom=0, left=0,
|
||||
right=1)
|
||||
plt.show()
|
||||
|
||||
@@ -45,7 +45,7 @@ line_x = np.arange(-250, 250)
|
||||
line_y = model.predict_y(line_x)
|
||||
line_y_robust = model_robust.predict_y(line_x)
|
||||
|
||||
f, ax = plt.subplots()
|
||||
fig, ax = plt.subplots()
|
||||
ax.plot(data[inliers, 0], data[inliers, 1], '.b', alpha=0.6,
|
||||
label='Inlier data')
|
||||
ax.plot(data[outliers, 0], data[outliers, 1], '.r', alpha=0.6,
|
||||
|
||||
@@ -50,7 +50,7 @@ ax3.imshow(image - dilated)
|
||||
ax3.set_title('image - dilated')
|
||||
ax3.axis('off')
|
||||
|
||||
plt.tight_layout()
|
||||
fig.tight_layout()
|
||||
|
||||
"""
|
||||
|
||||
@@ -98,7 +98,7 @@ ax3.axhline(yslice, color='r', alpha=0.4)
|
||||
ax3.set_title('image - dilated')
|
||||
ax3.axis('off')
|
||||
|
||||
plt.tight_layout()
|
||||
fig.tight_layout()
|
||||
plt.show()
|
||||
|
||||
"""
|
||||
|
||||
@@ -26,7 +26,7 @@ image = rotate(image, angle=15, order=0)
|
||||
label_img = label(image)
|
||||
regions = regionprops(label_img)
|
||||
|
||||
f, ax = plt.subplots()
|
||||
fig, ax = plt.subplots()
|
||||
ax.imshow(image, cmap=plt.cm.gray)
|
||||
|
||||
for props in regions:
|
||||
|
||||
@@ -47,7 +47,7 @@ image[circle2] = 0
|
||||
skeleton = skeletonize(image)
|
||||
|
||||
# display results
|
||||
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4.5))
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4.5))
|
||||
|
||||
ax1.imshow(image, cmap=plt.cm.gray)
|
||||
ax1.axis('off')
|
||||
@@ -57,7 +57,7 @@ ax2.imshow(skeleton, cmap=plt.cm.gray)
|
||||
ax2.axis('off')
|
||||
ax2.set_title('skeleton', fontsize=20)
|
||||
|
||||
f.subplots_adjust(wspace=0.02, hspace=0.02, top=0.98,
|
||||
fig.subplots_adjust(wspace=0.02, hspace=0.02, top=0.98,
|
||||
bottom=0.02, left=0.02, right=0.98)
|
||||
|
||||
plt.show()
|
||||
|
||||
@@ -45,7 +45,7 @@ def mse(x, y):
|
||||
img_noise = img + noise
|
||||
img_const = img + abs(noise)
|
||||
|
||||
f, (ax0, ax1, ax2) = plt.subplots(nrows=1, ncols=3, figsize=(8, 4))
|
||||
fig, (ax0, ax1, ax2) = plt.subplots(nrows=1, ncols=3, figsize=(8, 4))
|
||||
|
||||
mse_none = mse(img, img)
|
||||
ssim_none = ssim(img, img, dynamic_range=img.max() - img.min())
|
||||
|
||||
@@ -74,7 +74,7 @@ from skimage.transform import swirl
|
||||
image = data.checkerboard()
|
||||
swirled = swirl(image, rotation=0, strength=10, radius=120, order=2)
|
||||
|
||||
f, (ax0, ax1) = plt.subplots(1, 2, figsize=(8, 3))
|
||||
fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(8, 3))
|
||||
|
||||
ax0.imshow(image, cmap=plt.cm.gray, interpolation='none')
|
||||
ax0.axis('off')
|
||||
|
||||
Reference in New Issue
Block a user