scikit-image adalah paket pengolah gambar Python yang bekerja dengan array numpy. Paket ini diimpor sebagai skimage.
Error muncul pada saat kita meng-import library skimage.
Berikut langkah-langkah memperbaiki error tersebut.
C:\WINDOWS\system32>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import skimage
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\pc-name\AppData\Roaming\Python\Python37\site-packages\skimage\__init__.py", line 127, in <module>
from .util.dtype import (img_as_float32,
File "C:\Users\pc-name\AppData\Roaming\Python\Python37\site-packages\skimage\util\__init__.py", line 12, in <module>
from ._montage import montage
File "C:\Users\pc-name\AppData\Roaming\Python\Python37\site-packages\skimage\util\_montage.py", line 2, in <module>
from .. import exposure
File "C:\Users\pc-name\AppData\Roaming\Python\Python37\site-packages\skimage\exposure\__init__.py", line 1, in <module>
from .exposure import histogram, equalize_hist, \
File "C:\Users\pc-name\AppData\Roaming\Python\Python37\site-packages\skimage\exposure\exposure.py", line 3, in <module>
from ..color import rgb2gray
File "C:\Users\pc-name\AppData\Roaming\Python\Python37\site-packages\skimage\color\__init__.py", line 1, in <module>
from .colorconv import (convert_colorspace,
File "C:\Users\pc-name\AppData\Roaming\Python\Python37\site-packages\skimage\color\colorconv.py", line 55, in <module>
from scipy import linalg
File "C:\Users\pc-name\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\linalg\__init__.py", line 195, in <module>
from .misc import *
File "C:\Users\pc-name\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\linalg\misc.py", line 5, in <module>
from .blas import get_blas_funcs
File "C:\Users\pc-name\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\linalg\blas.py", line 214, in <module>
from scipy.linalg import _fblas
ImportError: DLL load failed: The specified module could not be found.
Langkah Pertama :
C:\WINDOWS\system32>pip uninstall scipy
Uninstalling scipy-1.3.0:
Would remove:
c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages\scipy-1.3.0.dist-info\*
c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages\scipy\*
Proceed (y/n)? y
Successfully uninstalled scipy-1.3.0
Langkah Kedua :
C:\WINDOWS\system32>pip uninstall scikit-image
Uninstalling scikit-image-0.15.0:
Would remove:
c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages\scikit_image-0.15.0.dist-info\*
c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages\skimage\*
c:\users\pc-name\appdata\local\programs\python\python37-32\scripts\skivi.exe
Proceed (y/n)? y
Successfully uninstalled scikit-image-0.15.0
Langkah Ketiga :
C:\WINDOWS\system32>pip install scikit-image
Collecting scikit-image
Downloading https://files.pythonhosted.org/packages/68/49/46dc899a804fc4ed19f50708c64bcc6e7323529c960721dfe935c279f933/scikit_image-0.15.0-cp37-none-win32.whl (24.8MB)
|████████████████████████████████| 24.8MB 6.4MB/s
Requirement already satisfied: imageio>=2.0.1 in c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages (from scikit-image) (2.5.0)
Requirement already satisfied: PyWavelets>=0.4.0 in c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages (from scikit-image) (1.0.3)
Requirement already satisfied: networkx>=2.0 in c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages (from scikit-image) (2.3)
Requirement already satisfied: pillow>=4.3.0 in c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages (from scikit-image) (6.1.0)
Requirement already satisfied: numpy in c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages (from imageio>=2.0.1->scikit-image) (1.16.4)
Requirement already satisfied: decorator>=4.3.0 in c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages (from networkx>=2.0->scikit-image) (4.4.0)
Installing collected packages: scikit-image
Successfully installed scikit-image-0.15.0
Langkah Keempat :
C:\WINDOWS\system32>pip install scipy
Collecting scipy
Downloading https://files.pythonhosted.org/packages/be/cc/6f7842a4d9aa7f51155f849185631e1201df255742de84d724ac33bff723/scipy-1.3.0-cp37-cp37m-win32.whl (27.1MB)
|████████████████████████████████| 27.1MB 6.4MB/s
Requirement already satisfied: numpy>=1.13.3 in c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages (from scipy) (1.16.4)
Installing collected packages: scipy
Successfully installed scipy-1.3.0
HASIL, Berikut hasil eksekusi script dari command prompt, jika tidak ada error berarti proses intalasi kamu berhasil
C:\WINDOWS\system32>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import skimage
>>> from skimage import data
>>> coins = data.coins()
>>> hist, hist_centers = histogram(coins)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'histogram' is not defined
>>> from skimage.exposure import histogram
>>> hist, hist_centers = histogram(coins)
>>> from skimage.feature import canny
>>> edges = canny(coins/255.)
>>> from scipy import ndimage as ndi
>>> fill_coins = ndi.binary_fill_holes(edges)
>>> label_objects, nb_labels = ndi.label(fill_coins)
>>> sizes = np.bincount(label_objects.ravel())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'np' is not defined
>>> from scipy import ndimage as ndi
>>> fill_coins = ndi.binary_fill_holes(edges)
>>> import numpy
>>> fill_coins = ndi.binary_fill_holes(edges)
>>> sizes = np.bincount(label_objects.ravel())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'np' is not defined
>>> import numpy as np
>>> sizes = np.bincount(label_objects.ravel())
>>> mask_sizes = sizes > 20
>>> mask_sizes[0] = 0
>>> coins_cleaned = mask_sizes[label_objects]
>>> markers = np.zeros_like(coins)
>>> markers[coins < 30] = 1
>>> markers[coins > 150] = 2
>>> from skimage.filters import sobel
>>> elevation_map = sobel(coins)
>>> markers = np.zeros_like(coins)
>>> markers[coins < 30] = 1
>>> markers[coins > 150] = 2
>>> from skimage.morphology import watershed
>>> segmentation = watershed(elevation_map, markers)
>>> segmentation = ndi.binary_fill_holes(segmentation - 1)
>>> labeled_coins, _ = ndi.label(segmentation)
catatan :
C:\WINDOWS\system32>python -V
Python 3.7.4
C:\WINDOWS\system32>pip -V
pip 19.1.1 from c:\users\pc-name\appdata\local\programs\python\python37-32\lib\site-packages\pip (python 3.7)
script pythonnya :
from skimage import data
from skimage.exposure import histogram
from scipy import ndimage as ndi
import numpy as np
coins = data.coins()
hist, hist_centers = histogram(coins)
from skimage.feature import canny
edges = canny(coins/255.)
fill_coins = ndi.binary_fill_holes(edges)
label_objects, nb_labels = ndi.label(fill_coins)
sizes = np.bincount(label_objects.ravel())
mask_sizes = sizes > 20
mask_sizes[0] = 0
coins_cleaned = mask_sizes[label_objects]
markers = np.zeros_like(coins)
markers[coins < 30] = 1
markers[coins > 150] = 2
from skimage.filters import sobel
elevation_map = sobel(coins)
markers = np.zeros_like(coins)
markers[coins < 30] = 1
markers[coins > 150] = 2
from skimage.morphology import watershed
segmentation = watershed(elevation_map, markers)
segmentation = ndi.binary_fill_holes(segmentation - 1)
labeled_coins, _ = ndi.label(segmentation)